summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2023-07-31 11:09:31 +1000
committerjacqueline <me@jacqueline.id.au>2023-07-31 11:09:31 +1000
commit8f0b942cdd964f0bfa3d775e7d8c3269c8d59edc (patch)
treec88d91516461dab01212628ef8f7dc829264965e
parentcdaa2ac97ac663de7c0c2b0361871c97269b1675 (diff)
downloadtangara-fw-8f0b942cdd964f0bfa3d775e7d8c3269c8d59edc.tar.gz
Return zeroes when the touchwheel isn't connected
-rw-r--r--src/drivers/touchwheel.cpp7
1 files 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() {