Merge pull request #14499 from to-scho/development

fix for sr04 mode2
This commit is contained in:
Adrian Scillato 2022-01-18 14:34:25 -03:00 committed by GitHub
commit d432b44268
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -53,7 +53,7 @@ uint8_t Sr04TModeDetect(void)
if (sonar_serial->begin(9600)) {
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;
} else {
sr04_type = 2;
@ -65,7 +65,7 @@ uint8_t Sr04TModeDetect(void)
if (sr04_type < 2) {
delete sonar_serial;
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
}
sonar = new NewPing(sr04_trig_pin, sr04_echo_pin, SR04_MAX_SENSOR_DISTANCE);