From 8f0771183c3872343100a2e974f37c91237da277 Mon Sep 17 00:00:00 2001 From: Riku Isokoski Date: Wed, 15 Sep 2021 12:25:41 +0300 Subject: [PATCH] Fix Error screen and optimize GetTouchInfo --- src/displayapp/screens/Error.cpp | 4 ---- src/displayapp/screens/Error.h | 1 - src/drivers/Cst816s.cpp | 17 ++++++++--------- src/drivers/Cst816s.h | 1 - 4 files changed, 8 insertions(+), 15 deletions(-) diff --git a/src/displayapp/screens/Error.cpp b/src/displayapp/screens/Error.cpp index 7ad52ade..75946aba 100644 --- a/src/displayapp/screens/Error.cpp +++ b/src/displayapp/screens/Error.cpp @@ -48,7 +48,3 @@ void Error::ButtonEventHandler() { Error::~Error() { lv_obj_clean(lv_scr_act()); } - -bool Error::Refresh() { - return running; -} diff --git a/src/displayapp/screens/Error.h b/src/displayapp/screens/Error.h index 58016d82..20dde7ee 100644 --- a/src/displayapp/screens/Error.h +++ b/src/displayapp/screens/Error.h @@ -12,7 +12,6 @@ namespace Pinetime { Error(DisplayApp* app, System::BootErrors error); ~Error() override; - bool Refresh() override; void ButtonEventHandler(); private: lv_obj_t* btnOk; diff --git a/src/drivers/Cst816s.cpp b/src/drivers/Cst816s.cpp index 5feb17b0..49d6ed0e 100644 --- a/src/drivers/Cst816s.cpp +++ b/src/drivers/Cst816s.cpp @@ -71,6 +71,7 @@ bool Cst816S::Init() { Cst816S::TouchInfos Cst816S::GetTouchInfo() { Cst816S::TouchInfos info; + uint8_t touchData[7]; auto ret = twiMaster.Read(twiAddress, 0, touchData, sizeof(touchData)); if (ret != TwiMaster::ErrorCodes::NoError) { @@ -79,18 +80,16 @@ Cst816S::TouchInfos Cst816S::GetTouchInfo() { } // This can only be 0 or 1 - auto nbTouchPoints = touchData[touchPointNumIndex] & 0x0f; + uint8_t nbTouchPoints = touchData[touchPointNumIndex] & 0x0f; - auto xHigh = touchData[touchXHighIndex] & 0x0f; - auto xLow = touchData[touchXLowIndex]; - uint16_t x = (xHigh << 8) | xLow; + uint8_t xHigh = touchData[touchXHighIndex] & 0x0f; + uint8_t xLow = touchData[touchXLowIndex]; + info.x = (xHigh << 8) | xLow; - auto yHigh = touchData[touchYHighIndex] & 0x0f; - auto yLow = touchData[touchYLowIndex]; - uint16_t y = (yHigh << 8) | yLow; + uint8_t yHigh = touchData[touchYHighIndex] & 0x0f; + uint8_t yLow = touchData[touchYLowIndex]; + info.y = (yHigh << 8) | yLow; - info.x = x; - info.y = y; info.touching = (nbTouchPoints > 0); info.gesture = static_cast(touchData[gestureIndex]); diff --git a/src/drivers/Cst816s.h b/src/drivers/Cst816s.h index d15ce06d..0fec8419 100644 --- a/src/drivers/Cst816s.h +++ b/src/drivers/Cst816s.h @@ -58,7 +58,6 @@ namespace Pinetime { //static constexpr uint8_t touchXYIndex = 7; //static constexpr uint8_t touchMiscIndex = 8; - uint8_t touchData[7]; TwiMaster& twiMaster; uint8_t twiAddress;