mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-28 21:26:33 +00:00
step 4 - compile option for range
This commit is contained in:
parent
501b643c3f
commit
33b3a4b88a
@ -622,6 +622,8 @@
|
||||
#define USE_ADE7953 // [I2cDriver7] Enable ADE7953 Energy monitor as used on Shelly 2.5 (I2C address 0x38) (+1k5)
|
||||
// #define USE_VL53L0X // [I2cDriver31] Enable VL53L0x time of flight sensor (I2C address 0x29) (+4k code)
|
||||
// #define USE_VL53L1X // [I2cDriver54] Enable VL53L1X time of flight sensor (I2C address 0x29) using Pololu VL53L1X library (+2k9 code)
|
||||
// #define VL53L1X_DISTANCE_MODE Long // VL53L1X distance mode : Long | Medium | Short
|
||||
// #define VL53LXX_XSHUT_ADDRESS 0x78 // VL53L1X base address when used with XSHUT control
|
||||
// #define USE_TOF10120 // [I2cDriver57] Enable TOF10120 time of flight sensor (I2C address 0x52) (+0k6 code)
|
||||
// #define USE_MLX90614 // [I2cDriver32] Enable MLX90614 ir temp sensor (I2C address 0x5a) (+0.6k code)
|
||||
// #define USE_CHIRP // [I2cDriver33] Enable CHIRP soil moisture sensor (variable I2C address, default 0x20)
|
||||
|
@ -37,10 +37,15 @@
|
||||
VL53L1X vl53l1x_device[VL53LXX_MAX_SENSORS];
|
||||
|
||||
#define VL53LXX_ADDRESS 0x29
|
||||
#ifndef VL53LXX_ADDRESS_MOVED
|
||||
#define VL53LXX_ADDRESS_MOVED 0x78
|
||||
#ifndef VL53LXX_XSHUT_ADDRESS
|
||||
#define VL53LXX_XSHUT_ADDRESS 0x78
|
||||
#endif
|
||||
|
||||
#ifndef VL53L1X_DISTANCE_MODE
|
||||
#define VL53L1X_DISTANCE_MODE Long
|
||||
#endif
|
||||
|
||||
|
||||
struct {
|
||||
uint16_t distance = 0;
|
||||
} vl53l1x_data[VL53LXX_MAX_SENSORS];
|
||||
@ -60,28 +65,23 @@ void Vl53l1Detect(void) {
|
||||
VL53L1X_xshut |= xshut;
|
||||
}
|
||||
}
|
||||
//Serial.print("VL0531X: xshut ");Serial.println(VL53L1X_xshut,HEX);
|
||||
|
||||
for (i = 0, xshut = 1 ; i < VL53LXX_MAX_SENSORS ; i++, xshut <<= 1) {
|
||||
if (xshut & VL53L1X_xshut) {
|
||||
digitalWrite(Pin(GPIO_VL53LXX_XSHUT1, i), 1);
|
||||
delay(2);
|
||||
}
|
||||
//Serial.print("VL0531X: A ");Serial.print(I2cSetDevice(VL53LXX_ADDRESS));Serial.print(' ');Serial.println(I2cSetDevice(VL53LXX_ADDRESS_MOVED+i));
|
||||
if (!I2cSetDevice(VL53LXX_ADDRESS) && !I2cSetDevice((uint8_t)(VL53LXX_ADDRESS_MOVED+i))) { continue; } // Detection for unconfigured OR configured sensor
|
||||
if (!I2cSetDevice(VL53LXX_ADDRESS) && !I2cSetDevice((uint8_t)(VL53LXX_XSHUT_ADDRESS+i))) { continue; } // Detection for unconfigured OR configured sensor
|
||||
if (vl53l1x_device[i].init()) {
|
||||
if (VL53L1X_xshut) {
|
||||
//Serial.println("VL0531X: D");
|
||||
vl53l1x_device[i].setAddress((uint8_t)(VL53LXX_ADDRESS_MOVED+i));
|
||||
vl53l1x_device[i].setAddress((uint8_t)(VL53LXX_XSHUT_ADDRESS+i));
|
||||
}
|
||||
uint8_t addr = vl53l1x_device[i].getAddress();
|
||||
//Serial.print("VL0531X: E ");Serial.println(addr,HEX);
|
||||
vl53l1x_device[i].setTimeout(500);
|
||||
vl53l1x_device[i].setDistanceMode(VL53L1X::Long); // could be Short, Medium, Long
|
||||
vl53l1x_device[i].setDistanceMode(VL53L1X::VL53L1X_DISTANCE_MODE); // could be Short, Medium, Long
|
||||
vl53l1x_device[i].setMeasurementTimingBudget(140000);
|
||||
vl53l1x_device[i].startContinuous(50);
|
||||
VL53L1X_detected |= xshut;
|
||||
//Serial.println("VL0531X: F");
|
||||
|
||||
if (VL53L1X_xshut) {
|
||||
I2cSetActive(addr);
|
||||
@ -89,7 +89,6 @@ void Vl53l1Detect(void) {
|
||||
} else {
|
||||
I2cSetActiveFound(addr, "VL53L1X");
|
||||
}
|
||||
//Serial.println("VL0531X: G");
|
||||
} // if init
|
||||
if (0 == VL53L1X_xshut) break;
|
||||
} // for
|
||||
|
Loading…
x
Reference in New Issue
Block a user