Closed xopxe closed 5 years ago
If you try to attach an encoder module with the switch pin set to nil (unused) the system crashes.
nil
Fixed with this:
diff --git a/components/sys/drivers/encoder.c b/components/sys/drivers/encoder.c index 786cbf2..20f4c1d 100644 --- a/components/sys/drivers/encoder.c +++ b/components/sys/drivers/encoder.c @@ -272,7 +272,7 @@ driver_error_t *encoder_setup(int8_t a, int8_t b, int8_t sw, encoder_h_t **h) { return driver_lock_error(ENCODER_DRIVER, lock_error); } - if ((lock_error = driver_lock(ENCODER_DRIVER, 0, GPIO_DRIVER, sw, 0, "SW"))) { + if ((sw >= 0) && (lock_error = driver_lock(ENCODER_DRIVER, 0, GPIO_DRIVER, sw, 0, "SW"))) { // Revoked lock on pin return driver_lock_error(ENCODER_DRIVER, lock_error); }
@xopxe,
Thanks for report this. Now I have recover encoders to test, and included in commit https://github.com/whitecatboard/Lua-RTOS-ESP32/commit/2dd0bff224f42e34056a648b0d65093c118091b6.
If you try to attach an encoder module with the switch pin set to
nil
(unused) the system crashes.Fixed with this: