From 8a8c8aa86312840a84533318bff92fdb6c42b8de Mon Sep 17 00:00:00 2001 From: JF Date: Tue, 27 Oct 2020 19:46:51 +0100 Subject: Handle error code when calling TwiMaster::Read(). --- src/drivers/Cst816s.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/drivers/Cst816s.cpp') 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; -- cgit v1.2.3-70-g09d2