From 8f0b942cdd964f0bfa3d775e7d8c3269c8d59edc Mon Sep 17 00:00:00 2001 From: jacqueline Date: Mon, 31 Jul 2023 11:09:31 +1000 Subject: [PATCH] Return zeroes when the touchwheel isn't connected --- src/drivers/touchwheel.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/drivers/touchwheel.cpp b/src/drivers/touchwheel.cpp index 2e44adfd..59c2911e 100644 --- a/src/drivers/touchwheel.cpp +++ b/src/drivers/touchwheel.cpp @@ -78,8 +78,11 @@ uint8_t TouchWheel::ReadRegister(uint8_t reg) { .write_addr(kTouchWheelAddress, I2C_MASTER_READ) .read(&res, I2C_MASTER_NACK) .stop(); - transaction.Execute(); - return res; + if (transaction.Execute() == ESP_OK) { + return res; + } else { + return 0; + } } void TouchWheel::Update() {