summaryrefslogtreecommitdiff
path: root/src/drivers
diff options
context:
space:
mode:
authorJF <jf@codingfield.com>2020-10-27 19:46:51 +0100
committerJF <jf@codingfield.com>2020-10-27 19:46:51 +0100
commit8a8c8aa86312840a84533318bff92fdb6c42b8de (patch)
tree9b9b65f3f6c7ec6b11e8dd0a411d3075cb20065a /src/drivers
parent2f710d06f37b9ee964ad24dc1832d18ac321c664 (diff)
Handle error code when calling TwiMaster::Read().
Diffstat (limited to 'src/drivers')
-rw-r--r--src/drivers/Cst816s.cpp4
-rw-r--r--src/drivers/Cst816s.h14
2 files changed, 10 insertions, 8 deletions
diff --git a/src/drivers/Cst816s.cpp b/src/drivers/Cst816s.cpp
index f6816545..94db3b34 100644
--- a/src/drivers/Cst816s.cpp
+++ b/src/drivers/Cst816s.cpp
@@ -37,7 +37,9 @@ void Cst816S::Init() {
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 b115a688..4569e82f 100644
--- a/src/drivers/Cst816s.h
+++ b/src/drivers/Cst816s.h
@@ -18,13 +18,13 @@ namespace Pinetime {
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;
};