if GPIO_SR04_TRIG is not configured use single PIN mode with GPIO_SR04_ECHO only

enable single PIN mode for SR04 sensor.
If pin GPIO_SR04_TRIG is not configured, use sensor interface in single PIN mode with GPIO_SR04_ECHO only
See as depicted in newping library, see:  https://bitbucket.org/teckel12/arduino-new-ping/wiki/Home#!single-pin-sketch
This commit is contained in:
VanillaFord 2020-04-15 09:36:23 +02:00 committed by GitHub
parent 4f33d76669
commit 487f4a9191
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -47,7 +47,7 @@ uint8_t Sr04TModeDetect(void)
if (pin[GPIO_SR04_ECHO]>=99) return sr04_type;
sr04_echo_pin = pin[GPIO_SR04_ECHO];
sr04_trig_pin = (pin[GPIO_SR04_TRIG] < 99) ? pin[GPIO_SR04_TRIG] : -1;
sr04_trig_pin = (pin[GPIO_SR04_TRIG] < 99) ? pin[GPIO_SR04_TRIG] : pin[GPIO_SR04_ECHO]; // if GPIO_SR04_TRIG is not configured use single PIN mode with GPIO_SR04_ECHO only
sonar_serial = new TasmotaSerial(sr04_echo_pin, sr04_trig_pin, 1);
if (sonar_serial->begin(9600,1)) {