Skip to content
Snippets Groups Projects
Commit 018017f2 authored by Orhan-Timo Altan's avatar Orhan-Timo Altan
Browse files

Kommentare ergänzt

parent f10327e9
No related branches found
No related tags found
No related merge requests found
......@@ -6,18 +6,23 @@ bits_TimeOfFlightController::bits_TimeOfFlightController(const uint16_t max_dist
void bits_TimeOfFlightController::init() {
bool found_any_sensors = false;
// Deaktivieren aller Sensoren
for (int i = 0; i < SENSOR_COUNT; i++)
{
pinMode(sensors[i].shutdown_pin, OUTPUT);
digitalWrite(sensors[i].shutdown_pin, LOW);
}
delay(10);
// Die Sensoren nach einander aktivieren und initalisieren
for (int i = 0; i < SENSOR_COUNT; i++)
{
digitalWrite(sensors[i].shutdown_pin, HIGH);
delay(100);
if (sensors[i].psensor->begin(sensors[i].id, false, sensors[i].pwire, sensors[i].sensor_config))
{
found_any_sensors = true;
......@@ -31,6 +36,7 @@ void bits_TimeOfFlightController::init() {
if (!found_any_sensors)
{
_println_tof_("No valid sensors found");
while (1)
{
;
......@@ -44,6 +50,7 @@ int bits_TimeOfFlightController::get_distance_mm(int index) {
sensors[index].psensor->rangingTest(&measure, false); // 'true' um debug Informationen auszugeben
int distance;
if ((measure.RangeStatus != 4) && (measure.RangeMilliMeter < max_distance))
{
distance = measure.RangeMilliMeter;
......
/*
* Klasse: BITsTimeOfFlight
* Klasse: bits_TimeOfFlightController
*
* Zur erzeugung eines Arrays gefüllt mit Objekten für die Ansteuerung von mehreren VL53L0X Time of Flight Sensoren
*
......@@ -29,11 +29,12 @@ public:
int get_distance_mm(int index);
private:
const uint16_t max_distance = 4000;
static const int SENSOR_COUNT = 5;
const uint16_t max_distance = 4000; // Maximal messbare Distanz
static const int SENSOR_COUNT = 5; // Sensoren Anzahl
int TOF_XSHUTS [SENSOR_COUNT] = {0, 8, 9, 23, 29}; // XShut Pins der einzelnen Time of Flight Sensoren
int TOF_ADDRESSES [SENSOR_COUNT] = {0x30, 0x31, 0x32, 0x33, 0x34}; // Adresse der einzelnen Time of Flight Sensoren
// Struktur der Sensor Liste
typedef struct
{
Adafruit_VL53L0X *psensor; // Zeiger zum Objekt
......@@ -46,12 +47,14 @@ const uint16_t max_distance = 4000;
uint8_t sensor_status;
} sensorList_t;
// Sensor Objekte basierend auf der Adafruit Bibliothek
Adafruit_VL53L0X tof_sensor_1;
Adafruit_VL53L0X tof_sensor_2;
Adafruit_VL53L0X tof_sensor_3;
Adafruit_VL53L0X tof_sensor_4;
Adafruit_VL53L0X tof_sensor_5;
// Liste von Sensor Objekten
sensorList_t sensors [SENSOR_COUNT] =
{
{&tof_sensor_1, &Wire, TOF_ADDRESSES[0], TOF_XSHUTS[0], Adafruit_VL53L0X::VL53L0X_SENSE_DEFAULT, 0, 0},
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment