1
0
Fork 0

Fix Error screen and optimize GetTouchInfo

This commit is contained in:
Riku Isokoski 2021-09-15 12:25:41 +03:00
parent f221f5d744
commit 8f0771183c
4 changed files with 8 additions and 15 deletions

View file

@ -48,7 +48,3 @@ void Error::ButtonEventHandler() {
Error::~Error() { Error::~Error() {
lv_obj_clean(lv_scr_act()); lv_obj_clean(lv_scr_act());
} }
bool Error::Refresh() {
return running;
}

View file

@ -12,7 +12,6 @@ namespace Pinetime {
Error(DisplayApp* app, System::BootErrors error); Error(DisplayApp* app, System::BootErrors error);
~Error() override; ~Error() override;
bool Refresh() override;
void ButtonEventHandler(); void ButtonEventHandler();
private: private:
lv_obj_t* btnOk; lv_obj_t* btnOk;

View file

@ -71,6 +71,7 @@ bool Cst816S::Init() {
Cst816S::TouchInfos Cst816S::GetTouchInfo() { Cst816S::TouchInfos Cst816S::GetTouchInfo() {
Cst816S::TouchInfos info; Cst816S::TouchInfos info;
uint8_t touchData[7];
auto ret = twiMaster.Read(twiAddress, 0, touchData, sizeof(touchData)); auto ret = twiMaster.Read(twiAddress, 0, touchData, sizeof(touchData));
if (ret != TwiMaster::ErrorCodes::NoError) { if (ret != TwiMaster::ErrorCodes::NoError) {
@ -79,18 +80,16 @@ Cst816S::TouchInfos Cst816S::GetTouchInfo() {
} }
// This can only be 0 or 1 // This can only be 0 or 1
auto nbTouchPoints = touchData[touchPointNumIndex] & 0x0f; uint8_t nbTouchPoints = touchData[touchPointNumIndex] & 0x0f;
auto xHigh = touchData[touchXHighIndex] & 0x0f; uint8_t xHigh = touchData[touchXHighIndex] & 0x0f;
auto xLow = touchData[touchXLowIndex]; uint8_t xLow = touchData[touchXLowIndex];
uint16_t x = (xHigh << 8) | xLow; info.x = (xHigh << 8) | xLow;
auto yHigh = touchData[touchYHighIndex] & 0x0f; uint8_t yHigh = touchData[touchYHighIndex] & 0x0f;
auto yLow = touchData[touchYLowIndex]; uint8_t yLow = touchData[touchYLowIndex];
uint16_t y = (yHigh << 8) | yLow; info.y = (yHigh << 8) | yLow;
info.x = x;
info.y = y;
info.touching = (nbTouchPoints > 0); info.touching = (nbTouchPoints > 0);
info.gesture = static_cast<Gestures>(touchData[gestureIndex]); info.gesture = static_cast<Gestures>(touchData[gestureIndex]);

View file

@ -58,7 +58,6 @@ namespace Pinetime {
//static constexpr uint8_t touchXYIndex = 7; //static constexpr uint8_t touchXYIndex = 7;
//static constexpr uint8_t touchMiscIndex = 8; //static constexpr uint8_t touchMiscIndex = 8;
uint8_t touchData[7];
TwiMaster& twiMaster; TwiMaster& twiMaster;
uint8_t twiAddress; uint8_t twiAddress;