From 5bc40c9287f06d2c2bb24a5691175f1d29a17c1b Mon Sep 17 00:00:00 2001 From: Riku Isokoski Date: Wed, 14 Jul 2021 17:11:16 +0300 Subject: Update touchpad driver --- src/displayapp/DisplayApp.cpp | 4 ++-- src/displayapp/screens/SystemInfo.cpp | 12 ++++++++--- src/displayapp/screens/SystemInfo.h | 6 ++++-- src/drivers/Cst816s.cpp | 39 +++++++++++++++++++++-------------- src/drivers/Cst816s.h | 36 +++++++++++++++++++++----------- src/systemtask/SystemTask.cpp | 2 +- 6 files changed, 63 insertions(+), 36 deletions(-) (limited to 'src') diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp index 6d66afe5..7949e700 100644 --- a/src/displayapp/DisplayApp.cpp +++ b/src/displayapp/DisplayApp.cpp @@ -336,7 +336,7 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction) break; case Apps::SysInfo: currentScreen = - std::make_unique(this, dateTimeController, batteryController, brightnessController, bleController, watchdog, motionController); + std::make_unique(this, dateTimeController, batteryController, brightnessController, bleController, watchdog, motionController, touchPanel); ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown); break; case Apps::FlashLight: @@ -395,7 +395,7 @@ void DisplayApp::PushMessage(Messages msg) { TouchEvents DisplayApp::OnTouchEvent() { auto info = touchPanel.GetTouchInfo(); - if (info.isTouch) { + if (info.isValid) { switch (info.gesture) { case Pinetime::Drivers::Cst816S::Gestures::SingleTap: if (touchMode == TouchModes::Gestures) { diff --git a/src/displayapp/screens/SystemInfo.cpp b/src/displayapp/screens/SystemInfo.cpp index f5bf0cc9..d1df579c 100644 --- a/src/displayapp/screens/SystemInfo.cpp +++ b/src/displayapp/screens/SystemInfo.cpp @@ -31,7 +31,8 @@ SystemInfo::SystemInfo(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::BrightnessController& brightnessController, Pinetime::Controllers::Ble& bleController, Pinetime::Drivers::WatchdogView& watchdog, - Pinetime::Controllers::MotionController& motionController) + Pinetime::Controllers::MotionController& motionController, + Pinetime::Drivers::Cst816S& touchPanel) : Screen(app), dateTimeController {dateTimeController}, batteryController {batteryController}, @@ -39,6 +40,7 @@ SystemInfo::SystemInfo(Pinetime::Applications::DisplayApp* app, bleController {bleController}, watchdog {watchdog}, motionController{motionController}, + touchPanel{touchPanel}, screens {app, 0, {[this]() -> std::unique_ptr { @@ -151,7 +153,8 @@ std::unique_ptr SystemInfo::CreateScreen2() { "#444444 Battery# %d%%/%03imV\n" "#444444 Backlight# %s\n" "#444444 Last reset# %s\n" - "#444444 Accel.# %s\n", + "#444444 Accel.# %s\n" + "#444444 Touch.# %x.%x.%x\n", dateTimeController.Day(), static_cast(dateTimeController.Month()), dateTimeController.Year(), @@ -166,7 +169,10 @@ std::unique_ptr SystemInfo::CreateScreen2() { batteryController.Voltage(), brightnessController.ToString(), resetReason, - ToString(motionController.DeviceType())); + ToString(motionController.DeviceType()), + touchPanel.GetChipId(), + touchPanel.GetVendorId(), + touchPanel.GetFwVersion()); lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0); return std::make_unique(1, 5, app, label); } diff --git a/src/displayapp/screens/SystemInfo.h b/src/displayapp/screens/SystemInfo.h index 9d471f61..88984dfe 100644 --- a/src/displayapp/screens/SystemInfo.h +++ b/src/displayapp/screens/SystemInfo.h @@ -28,7 +28,8 @@ namespace Pinetime { Pinetime::Controllers::BrightnessController& brightnessController, Pinetime::Controllers::Ble& bleController, Pinetime::Drivers::WatchdogView& watchdog, - Pinetime::Controllers::MotionController& motionController); + Pinetime::Controllers::MotionController& motionController, + Pinetime::Drivers::Cst816S& touchPanel); ~SystemInfo() override; bool Refresh() override; bool OnButtonPushed() override; @@ -43,6 +44,7 @@ namespace Pinetime { Pinetime::Controllers::Ble& bleController; Pinetime::Drivers::WatchdogView& watchdog; Pinetime::Controllers::MotionController& motionController; + Pinetime::Drivers::Cst816S& touchPanel; ScreenList<5> screens; @@ -56,4 +58,4 @@ namespace Pinetime { }; } } -} \ No newline at end of file +} diff --git a/src/drivers/Cst816s.cpp b/src/drivers/Cst816s.cpp index fd9792b3..2a6809b1 100644 --- a/src/drivers/Cst816s.cpp +++ b/src/drivers/Cst816s.cpp @@ -40,38 +40,45 @@ void Cst816S::Init() { */ static constexpr uint8_t motionMask = 0b00000101; twiMaster.Write(twiAddress, 0xEC, &motionMask, 1); + + // There's mixed information about which register contains which information + if (twiMaster.Read(twiAddress, 0xA7, &chipId, 1) == TwiMaster::ErrorCodes::TransactionFailed) { + chipId = 0xFF; + } + if (twiMaster.Read(twiAddress, 0xA8, &vendorId, 1) == TwiMaster::ErrorCodes::TransactionFailed) { + vendorId = 0xFF; + } + if (twiMaster.Read(twiAddress, 0xA9, &fwVersion, 1) == TwiMaster::ErrorCodes::TransactionFailed) { + fwVersion = 0xFF; + } } Cst816S::TouchInfos Cst816S::GetTouchInfo() { Cst816S::TouchInfos info; auto ret = twiMaster.Read(twiAddress, 0, touchData, sizeof(touchData)); - if (ret != TwiMaster::ErrorCodes::NoError) - return {}; - - auto nbTouchPoints = touchData[2] & 0x0f; - - uint8_t i = 0; - - uint8_t pointId = (touchData[touchIdIndex + (touchStep * i)]) >> 4; - if (nbTouchPoints == 0 && pointId == lastTouchId) + if (ret != TwiMaster::ErrorCodes::NoError) { + info.isValid = false; return info; + } - info.isTouch = true; + // This can only be 0 or 1 + auto nbTouchPoints = touchData[touchPointNumIndex] & 0x0f; - auto xHigh = touchData[touchXHighIndex + (touchStep * i)] & 0x0f; - auto xLow = touchData[touchXLowIndex + (touchStep * i)]; + auto xHigh = touchData[touchXHighIndex] & 0x0f; + auto xLow = touchData[touchXLowIndex]; uint16_t x = (xHigh << 8) | xLow; - auto yHigh = touchData[touchYHighIndex + (touchStep * i)] & 0x0f; - auto yLow = touchData[touchYLowIndex + (touchStep * i)]; + auto yHigh = touchData[touchYHighIndex] & 0x0f; + auto yLow = touchData[touchYLowIndex]; uint16_t y = (yHigh << 8) | yLow; - auto action = touchData[touchEventIndex + (touchStep * i)] >> 6; /* 0 = Down, 1 = Up, 2 = contact*/ + auto action = touchData[touchEventIndex] >> 6; /* 0 = Down, 1 = Up, 2 = contact*/ info.x = x; info.y = y; info.action = action; + info.touching = (nbTouchPoints > 0); info.gesture = static_cast(touchData[gestureIndex]); return info; @@ -90,4 +97,4 @@ void Cst816S::Sleep() { void Cst816S::Wakeup() { Init(); NRF_LOG_INFO("[TOUCHPANEL] Wakeup"); -} \ No newline at end of file +} diff --git a/src/drivers/Cst816s.h b/src/drivers/Cst816s.h index 14c296ea..394cc40f 100644 --- a/src/drivers/Cst816s.h +++ b/src/drivers/Cst816s.h @@ -20,11 +20,9 @@ namespace Pinetime { uint16_t x = 0; uint16_t y = 0; uint8_t action = 0; - uint8_t finger = 0; - uint8_t pressure = 0; - uint8_t area = 0; + bool touching = false; Gestures gesture = Gestures::None; - bool isTouch = false; + bool isValid = true; }; Cst816S(TwiMaster& twiMaster, uint8_t twiAddress); @@ -38,26 +36,40 @@ namespace Pinetime { void Sleep(); void Wakeup(); + uint8_t GetChipId() const { + return chipId; + } + uint8_t GetVendorId() const { + return vendorId; + } + uint8_t GetFwVersion() const { + return fwVersion; + } private: static constexpr uint8_t pinIrq = 28; static constexpr uint8_t pinReset = 10; - static constexpr uint8_t lastTouchId = 0x0f; + + // Unused/Unavailable commented out + static constexpr uint8_t gestureIndex = 1; static constexpr uint8_t touchPointNumIndex = 2; - static constexpr uint8_t touchMiscIndex = 8; - static constexpr uint8_t touchXYIndex = 7; static constexpr uint8_t touchEventIndex = 3; static constexpr uint8_t touchXHighIndex = 3; static constexpr uint8_t touchXLowIndex = 4; + //static constexpr uint8_t touchIdIndex = 5; static constexpr uint8_t touchYHighIndex = 5; static constexpr uint8_t touchYLowIndex = 6; - static constexpr uint8_t touchIdIndex = 5; - static constexpr uint8_t touchStep = 6; - static constexpr uint8_t gestureIndex = 1; + //static constexpr uint8_t touchStep = 6; + //static constexpr uint8_t touchXYIndex = 7; + //static constexpr uint8_t touchMiscIndex = 8; - uint8_t touchData[10]; + uint8_t touchData[7]; TwiMaster& twiMaster; uint8_t twiAddress; + + uint8_t chipId; + uint8_t vendorId; + uint8_t fwVersion; }; } -} \ No newline at end of file +} diff --git a/src/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp index eb29638a..6a851e75 100644 --- a/src/systemtask/SystemTask.cpp +++ b/src/systemtask/SystemTask.cpp @@ -231,7 +231,7 @@ void SystemTask::Work() { twiMaster.Wakeup(); auto touchInfo = touchPanel.GetTouchInfo(); twiMaster.Sleep(); - if (touchInfo.isTouch and ((touchInfo.gesture == Pinetime::Drivers::Cst816S::Gestures::DoubleTap and + if (touchInfo.isValid and ((touchInfo.gesture == Pinetime::Drivers::Cst816S::Gestures::DoubleTap and settingsController.getWakeUpMode() == Pinetime::Controllers::Settings::WakeUpMode::DoubleTap) or (touchInfo.gesture == Pinetime::Drivers::Cst816S::Gestures::SingleTap and settingsController.getWakeUpMode() == Pinetime::Controllers::Settings::WakeUpMode::SingleTap))) { -- cgit v1.2.3 From 9c175e2f0cd90b56818953b748c8cad3eec2eb89 Mon Sep 17 00:00:00 2001 From: Riku Isokoski Date: Tue, 17 Aug 2021 16:01:18 +0300 Subject: Fix after merge --- src/displayapp/DisplayApp.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp index 4b73a201..7fe69397 100644 --- a/src/displayapp/DisplayApp.cpp +++ b/src/displayapp/DisplayApp.cpp @@ -54,7 +54,7 @@ namespace { } TouchEvents Convert(Pinetime::Drivers::Cst816S::TouchInfos info) { - if (info.isTouch) { + if (info.isValid) { switch (info.gesture) { case Pinetime::Drivers::Cst816S::Gestures::SingleTap: return TouchEvents::Tap; -- cgit v1.2.3 From 780a811f0559a9abd000f36d3fe49cbbb233b632 Mon Sep 17 00:00:00 2001 From: Riku Isokoski Date: Wed, 18 Aug 2021 15:23:30 +0300 Subject: Automatic error detection --- src/BootErrors.h | 10 ++++++++ src/CMakeLists.txt | 1 + src/displayapp/Apps.h | 3 ++- src/displayapp/DisplayApp.cpp | 17 ++++++++++--- src/displayapp/DisplayApp.h | 5 +++- src/displayapp/screens/Error.cpp | 54 ++++++++++++++++++++++++++++++++++++++++ src/displayapp/screens/Error.h | 22 ++++++++++++++++ src/drivers/Cst816s.cpp | 7 +++++- src/drivers/Cst816s.h | 2 +- src/systemtask/SystemTask.cpp | 9 +++++-- 10 files changed, 121 insertions(+), 9 deletions(-) create mode 100644 src/BootErrors.h create mode 100644 src/displayapp/screens/Error.cpp create mode 100644 src/displayapp/screens/Error.h (limited to 'src') diff --git a/src/BootErrors.h b/src/BootErrors.h new file mode 100644 index 00000000..d00418cc --- /dev/null +++ b/src/BootErrors.h @@ -0,0 +1,10 @@ +#pragma once + +namespace Pinetime { + namespace System { + enum class BootErrors { + None, + TouchController, + }; + } +} diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 40e1f2a5..0d41a244 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -418,6 +418,7 @@ list(APPEND SOURCE_FILES displayapp/screens/BatteryInfo.cpp displayapp/screens/Steps.cpp displayapp/screens/Timer.cpp + displayapp/screens/Error.cpp ## Settings displayapp/screens/settings/QuickSettings.cpp diff --git a/src/displayapp/Apps.h b/src/displayapp/Apps.h index 684e3a46..0b102100 100644 --- a/src/displayapp/Apps.h +++ b/src/displayapp/Apps.h @@ -30,7 +30,8 @@ namespace Pinetime { SettingTimeFormat, SettingDisplay, SettingWakeUp, - SettingSteps + SettingSteps, + Error, }; } } diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp index 7fe69397..41fa7d80 100644 --- a/src/displayapp/DisplayApp.cpp +++ b/src/displayapp/DisplayApp.cpp @@ -28,6 +28,7 @@ #include "displayapp/screens/FlashLight.h" #include "displayapp/screens/BatteryInfo.h" #include "displayapp/screens/Steps.h" +#include "displayapp/screens/Error.h" #include "drivers/Cst816s.h" #include "drivers/St7789.h" @@ -107,11 +108,16 @@ DisplayApp::DisplayApp(Drivers::St7789& lcd, timerController {timerController} { } -void DisplayApp::Start() { +void DisplayApp::Start(System::BootErrors error) { msgQueue = xQueueCreate(queueSize, itemSize); - // Start clock when smartwatch boots - LoadApp(Apps::Clock, DisplayApp::FullRefreshDirections::None); + bootError = error; + + if (error == System::BootErrors::TouchController) { + LoadApp(Apps::Error, DisplayApp::FullRefreshDirections::None); + } else { + LoadApp(Apps::Clock, DisplayApp::FullRefreshDirections::None); + } if (pdPASS != xTaskCreate(DisplayApp::Process, "displayapp", 800, this, 0, &taskHandle)) { APP_ERROR_HANDLER(NRF_ERROR_NO_MEM); @@ -325,6 +331,11 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction) motionController); break; + case Apps::Error: + currentScreen = std::make_unique(this, bootError); + ReturnApp(Apps::Clock, FullRefreshDirections::Down, TouchEvents::None); + break; + case Apps::FirmwareValidation: currentScreen = std::make_unique(this, validator); ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown); diff --git a/src/displayapp/DisplayApp.h b/src/displayapp/DisplayApp.h index 574be63f..ba119133 100644 --- a/src/displayapp/DisplayApp.h +++ b/src/displayapp/DisplayApp.h @@ -15,6 +15,7 @@ #include "displayapp/screens/Screen.h" #include "components/timer/TimerController.h" #include "Messages.h" +#include "BootErrors.h" namespace Pinetime { @@ -56,7 +57,7 @@ namespace Pinetime { Pinetime::Controllers::MotorController& motorController, Pinetime::Controllers::MotionController& motionController, Pinetime::Controllers::TimerController& timerController); - void Start(); + void Start(System::BootErrors error); void PushMessage(Display::Messages msg); void StartApp(Apps app, DisplayApp::FullRefreshDirections direction); @@ -114,6 +115,8 @@ namespace Pinetime { Apps nextApp = Apps::None; DisplayApp::FullRefreshDirections nextDirection; TickType_t lastWakeTime; + + System::BootErrors bootError; }; } } diff --git a/src/displayapp/screens/Error.cpp b/src/displayapp/screens/Error.cpp new file mode 100644 index 00000000..7ad52ade --- /dev/null +++ b/src/displayapp/screens/Error.cpp @@ -0,0 +1,54 @@ +#include "Error.h" + +using namespace Pinetime::Applications::Screens; + +namespace { + void ButtonEventCallback(lv_obj_t* obj, lv_event_t /*event*/) { + auto* errorScreen = static_cast(obj->user_data); + errorScreen->ButtonEventHandler(); + } +} + +Error::Error(Pinetime::Applications::DisplayApp* app, System::BootErrors error) + : Screen(app) { + + lv_obj_t* warningLabel = lv_label_create(lv_scr_act(), nullptr); + lv_obj_set_style_local_text_color(warningLabel, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_ORANGE); + lv_label_set_text_static(warningLabel, "Warning"); + lv_obj_align(warningLabel, nullptr, LV_ALIGN_IN_TOP_MID, 0, 0); + + lv_obj_t* causeLabel = lv_label_create(lv_scr_act(), nullptr); + lv_label_set_long_mode(causeLabel, LV_LABEL_LONG_BREAK); + lv_obj_set_width(causeLabel, LV_HOR_RES); + lv_obj_align(causeLabel, warningLabel, LV_ALIGN_OUT_BOTTOM_MID, 0, 0); + + if (error == System::BootErrors::TouchController) { + lv_label_set_text_static(causeLabel, "Touch controller error detected."); + } + + lv_obj_t* tipLabel = lv_label_create(lv_scr_act(), nullptr); + lv_label_set_long_mode(tipLabel, LV_LABEL_LONG_BREAK); + lv_obj_set_width(tipLabel, LV_HOR_RES); + lv_label_set_text_static(tipLabel, "If you encounter problems and your device is under warranty, contact the devices seller."); + lv_obj_align(tipLabel, causeLabel, LV_ALIGN_OUT_BOTTOM_MID, 0, 0); + + btnOk = lv_btn_create(lv_scr_act(), nullptr); + btnOk->user_data = this; + lv_obj_set_event_cb(btnOk, ButtonEventCallback); + lv_obj_set_size(btnOk, LV_HOR_RES, 50); + lv_obj_align(btnOk, lv_scr_act(), LV_ALIGN_IN_BOTTOM_MID, 0, 0); + lv_obj_set_style_local_value_str(btnOk, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "Proceed"); + lv_obj_set_style_local_bg_color(btnOk, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_ORANGE); +} + +void Error::ButtonEventHandler() { + running = false; +} + +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 new file mode 100644 index 00000000..58016d82 --- /dev/null +++ b/src/displayapp/screens/Error.h @@ -0,0 +1,22 @@ +#pragma once + +#include "Screen.h" +#include "BootErrors.h" +#include + +namespace Pinetime { + namespace Applications { + namespace Screens { + class Error : public Screen { + public: + 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 2a6809b1..3db712e6 100644 --- a/src/drivers/Cst816s.cpp +++ b/src/drivers/Cst816s.cpp @@ -17,7 +17,7 @@ using namespace Pinetime::Drivers; Cst816S::Cst816S(TwiMaster& twiMaster, uint8_t twiAddress) : twiMaster {twiMaster}, twiAddress {twiAddress} { } -void Cst816S::Init() { +bool Cst816S::Init() { nrf_gpio_cfg_output(pinReset); nrf_gpio_pin_set(pinReset); vTaskDelay(50); @@ -44,13 +44,18 @@ void Cst816S::Init() { // There's mixed information about which register contains which information if (twiMaster.Read(twiAddress, 0xA7, &chipId, 1) == TwiMaster::ErrorCodes::TransactionFailed) { chipId = 0xFF; + return false; } if (twiMaster.Read(twiAddress, 0xA8, &vendorId, 1) == TwiMaster::ErrorCodes::TransactionFailed) { vendorId = 0xFF; + return false; } if (twiMaster.Read(twiAddress, 0xA9, &fwVersion, 1) == TwiMaster::ErrorCodes::TransactionFailed) { fwVersion = 0xFF; + return false; } + + return chipId == 0xb4 && vendorId == 0 && fwVersion == 1; } Cst816S::TouchInfos Cst816S::GetTouchInfo() { diff --git a/src/drivers/Cst816s.h b/src/drivers/Cst816s.h index 394cc40f..5b2e4e46 100644 --- a/src/drivers/Cst816s.h +++ b/src/drivers/Cst816s.h @@ -31,7 +31,7 @@ namespace Pinetime { Cst816S(Cst816S&&) = delete; Cst816S& operator=(Cst816S&&) = delete; - void Init(); + bool Init(); TouchInfos GetTouchInfo(); void Sleep(); void Wakeup(); diff --git a/src/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp index 500bc8b8..718e6ccd 100644 --- a/src/systemtask/SystemTask.cpp +++ b/src/systemtask/SystemTask.cpp @@ -22,6 +22,7 @@ #include "drivers/TwiMaster.h" #include "drivers/Hrs3300.h" #include "main.h" +#include "BootErrors.h" #include @@ -106,6 +107,8 @@ void SystemTask::Process(void* instance) { } void SystemTask::Work() { + BootErrors bootError = BootErrors::None; + watchdog.Setup(7); watchdog.Start(); NRF_LOG_INFO("Last reset reason : %s", Pinetime::Drivers::Watchdog::ResetReasonToString(watchdog.ResetReason())); @@ -124,7 +127,9 @@ void SystemTask::Work() { lcd.Init(); twiMaster.Init(); - touchPanel.Init(); + if (!touchPanel.Init()) { + bootError = BootErrors::TouchController; + } dateTimeController.Register(this); batteryController.Init(); motorController.Init(); @@ -141,7 +146,7 @@ void SystemTask::Work() { settingsController.Init(); displayApp.Register(this); - displayApp.Start(); + displayApp.Start(bootError); displayApp.PushMessage(Pinetime::Applications::Display::Messages::UpdateBatteryLevel); -- cgit v1.2.3 From 8f0771183c3872343100a2e974f37c91237da277 Mon Sep 17 00:00:00 2001 From: Riku Isokoski Date: Wed, 15 Sep 2021 12:25:41 +0300 Subject: 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(-) (limited to 'src') 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; -- cgit v1.2.3