diff --git a/BITs_tof_array.h b/BITs_tof_array.h index b75ed9bb6905923fe24dbbc2d86d11f2bcb7fb21..581494284b870470212e1726d2ce830c5cff4ef7 100644 --- a/BITs_tof_array.h +++ b/BITs_tof_array.h @@ -20,29 +20,31 @@ #define _println_tof_(x) #endif -const int TOFS = 5; // Anzahl der zu Verwendenden Time of Flight Sensoren -const int TOF_XSHUTS[TOFS] = {0, 9, 11, 31, A10}; // XShut Pins der einzelnen Time of Flight Sensoren -const int TOF_ADDRESSES[TOFS] = {0x30, 0x31, 0x32, 0x33, 0x34}; // Adresse der einzelnen Time of Flight Sensoren +const int TOFS_COUNT = 5; // Anzahl der zu Verwendenden Time of Flight Sensoren +const int TOF_XSHUTS[] = {0, 8, 9, 29, 23}; // XShut Pins der einzelnen Time of Flight Sensoren +const int TOF_ADDRESSES[] = {0x30, 0x31, 0x32, 0x33, 0x34}; // Adresse der einzelnen Time of Flight Sensoren class BITsTimeOfFlight { public: void init() { - for (int i = 0; i < COUNT_SENSORS; i++) + + + for (int i = 1; i < TOFS_COUNT; i++) { pinMode(sensors[i].shutdown_pin, OUTPUT); digitalWrite(sensors[i].shutdown_pin, LOW); } - bool found_any_sensors = false; - for (int i = 0; i < COUNT_SENSORS; i++) - digitalWrite(sensors[i].shutdown_pin, LOW); delay(10); + bool found_any_sensors = false; - for (int i = 0; i < COUNT_SENSORS; i++) + for (int i = 0; i < TOFS_COUNT; i++) { + if (i > 0){ digitalWrite(sensors[i].shutdown_pin, HIGH); + } delay(100); if (sensors[i].psensor->begin(sensors[i].id, false, sensors[i].pwire, sensors[i].sensor_config)) @@ -105,15 +107,15 @@ private: Adafruit_VL53L0X tof4; Adafruit_VL53L0X tof5; - sensorList_t sensors[TOFS] = + sensorList_t sensors[TOFS_COUNT] = { {&tof1, &Wire, TOF_ADDRESSES[0], TOF_XSHUTS[0], Adafruit_VL53L0X::VL53L0X_SENSE_HIGH_SPEED, 0, 0}, {&tof2, &Wire, TOF_ADDRESSES[1], TOF_XSHUTS[1], Adafruit_VL53L0X::VL53L0X_SENSE_HIGH_SPEED, 0, 0}, {&tof3, &Wire, TOF_ADDRESSES[2], TOF_XSHUTS[2], Adafruit_VL53L0X::VL53L0X_SENSE_HIGH_SPEED, 0, 0}, {&tof4, &Wire, TOF_ADDRESSES[3], TOF_XSHUTS[3], Adafruit_VL53L0X::VL53L0X_SENSE_HIGH_SPEED, 0, 0}, - {&tof5, &Wire, TOF_ADDRESSES[4], TOF_XSHUTS[4], Adafruit_VL53L0X::VL53L0X_SENSE_HIGH_SPEED, 0, 0}}; + {&tof5, &Wire, TOF_ADDRESSES[4], TOF_XSHUTS[4], Adafruit_VL53L0X::VL53L0X_SENSE_HIGH_SPEED, 0, 0} + }; - const int COUNT_SENSORS = sizeof(sensors) / sizeof(sensors[0]); }; #endif \ No newline at end of file