mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-23 10:46:31 +00:00
fix mode 2 detection of sr04
This commit is contained in:
parent
08b5691a41
commit
0930f4679c
@ -53,7 +53,7 @@ uint8_t Sr04TModeDetect(void)
|
|||||||
if (sonar_serial->begin(9600)) {
|
if (sonar_serial->begin(9600)) {
|
||||||
DEBUG_SENSOR_LOG(PSTR("SR4: Detect mode"));
|
DEBUG_SENSOR_LOG(PSTR("SR4: Detect mode"));
|
||||||
|
|
||||||
if (sr04_trig_pin != -1) {
|
if (! PinUsed(GPIO_SR04_TRIG)) {
|
||||||
sr04_type = (Sr04TMiddleValue(Sr04TMode3Distance(), Sr04TMode3Distance(), Sr04TMode3Distance()) != NO_ECHO) ? 3 : 1;
|
sr04_type = (Sr04TMiddleValue(Sr04TMode3Distance(), Sr04TMode3Distance(), Sr04TMode3Distance()) != NO_ECHO) ? 3 : 1;
|
||||||
} else {
|
} else {
|
||||||
sr04_type = 2;
|
sr04_type = 2;
|
||||||
@ -65,7 +65,7 @@ uint8_t Sr04TModeDetect(void)
|
|||||||
if (sr04_type < 2) {
|
if (sr04_type < 2) {
|
||||||
delete sonar_serial;
|
delete sonar_serial;
|
||||||
sonar_serial = nullptr;
|
sonar_serial = nullptr;
|
||||||
if (-1 == sr04_trig_pin) {
|
if (! PinUsed(GPIO_SR04_TRIG)) {
|
||||||
sr04_trig_pin = Pin(GPIO_SR04_ECHO); // if GPIO_SR04_TRIG is not configured use single PIN mode with GPIO_SR04_ECHO only
|
sr04_trig_pin = Pin(GPIO_SR04_ECHO); // if GPIO_SR04_TRIG is not configured use single PIN mode with GPIO_SR04_ECHO only
|
||||||
}
|
}
|
||||||
sonar = new NewPing(sr04_trig_pin, sr04_echo_pin, SR04_MAX_SENSOR_DISTANCE);
|
sonar = new NewPing(sr04_trig_pin, sr04_echo_pin, SR04_MAX_SENSOR_DISTANCE);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user