InfiniTime.git

commit 8a8c8aa86312840a84533318bff92fdb6c42b8de

Author: JF <jf@codingfield.com>

Handle error code when calling TwiMaster::Read().

 src/drivers/Cst816s.cpp | 4 +++-
 src/drivers/Cst816s.h | 14 +++++++-------


diff --git a/src/drivers/Cst816s.cpp b/src/drivers/Cst816s.cpp
index f6816545f80d134bd98982c4d9b85dbdc593841e..94db3b34b23b98be53b266635eaa341b6134ed6c 100644
--- a/src/drivers/Cst816s.cpp
+++ b/src/drivers/Cst816s.cpp
@@ -37,7 +37,9 @@
 Cst816S::TouchInfos Cst816S::GetTouchInfo() {
   Cst816S::TouchInfos info;
 
-  twiMaster.Read(twiAddress, 0, touchData, 63);
+  auto ret = twiMaster.Read(twiAddress, 0, touchData, 63);
+  if(ret != TwiMaster::ErrorCodes::NoError) return {};
+
   auto nbTouchPoints = touchData[2] & 0x0f;
 
 //  uint8_t i = 0;




diff --git a/src/drivers/Cst816s.h b/src/drivers/Cst816s.h
index b115a6880978316e014e2a2079f201bda880c0f6..4569e82fa6a8782e8016dd734dada3ad0dc3ba8a 100644
--- a/src/drivers/Cst816s.h
+++ b/src/drivers/Cst816s.h
@@ -18,13 +18,13 @@             DoubleTap = 0x0B,
             LongPress = 0x0C
         };
         struct TouchInfos {
-          uint16_t x;
-          uint16_t y;
-          uint8_t action;
-          uint8_t finger;
-          uint8_t pressure;
-          uint8_t area;
-          Gestures gesture;
+          uint16_t x = 0;
+          uint16_t y = 0;
+          uint8_t action = 0;
+          uint8_t finger = 0;
+          uint8_t pressure = 0;
+          uint8_t area = 0;
+          Gestures gesture = Gestures::None;
           bool isTouch = false;
         };