diff options
Diffstat (limited to 'src/displayapp')
-rw-r--r-- | src/displayapp/Apps.h | 3 | ||||
-rw-r--r-- | src/displayapp/DisplayApp.cpp | 19 | ||||
-rw-r--r-- | src/displayapp/DisplayApp.h | 4 | ||||
-rw-r--r-- | src/displayapp/screens/Error.cpp | 50 | ||||
-rw-r--r-- | src/displayapp/screens/Error.h | 21 | ||||
-rw-r--r-- | src/displayapp/screens/SystemInfo.cpp | 12 | ||||
-rw-r--r-- | src/displayapp/screens/SystemInfo.h | 4 |
7 files changed, 103 insertions, 10 deletions
diff --git a/src/displayapp/Apps.h b/src/displayapp/Apps.h index e3aca8cf..b14fe687 100644 --- a/src/displayapp/Apps.h +++ b/src/displayapp/Apps.h @@ -32,7 +32,8 @@ namespace Pinetime { SettingDisplay, SettingWakeUp, SettingSteps, - SettingPineTimeStyle + SettingPineTimeStyle, + Error, }; } } diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp index 837082dd..491d2dc3 100644 --- a/src/displayapp/DisplayApp.cpp +++ b/src/displayapp/DisplayApp.cpp @@ -29,6 +29,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" @@ -110,11 +111,16 @@ DisplayApp::DisplayApp(Drivers::St7789& lcd, touchHandler {touchHandler} { } -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); @@ -309,6 +315,11 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction) motionController); break; + case Apps::Error: + currentScreen = std::make_unique<Screens::Error>(this, bootError); + ReturnApp(Apps::Clock, FullRefreshDirections::Down, TouchEvents::None); + break; + case Apps::FirmwareValidation: currentScreen = std::make_unique<Screens::FirmwareValidation>(this, validator); ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown); @@ -375,7 +386,7 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction) break; case Apps::SysInfo: currentScreen = std::make_unique<Screens::SystemInfo>( - this, dateTimeController, batteryController, brightnessController, bleController, watchdog, motionController); + this, dateTimeController, batteryController, brightnessController, bleController, watchdog, motionController, touchPanel); ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown); break; case Apps::FlashLight: diff --git a/src/displayapp/DisplayApp.h b/src/displayapp/DisplayApp.h index 63e898f0..a87cab0b 100644 --- a/src/displayapp/DisplayApp.h +++ b/src/displayapp/DisplayApp.h @@ -18,6 +18,7 @@ #include "touchhandler/TouchHandler.h" #include "Messages.h" +#include "BootErrors.h" namespace Pinetime { @@ -61,7 +62,7 @@ namespace Pinetime { Pinetime::Controllers::TimerController& timerController, Pinetime::Controllers::AlarmController& alarmController, Pinetime::Controllers::TouchHandler& touchHandler); - void Start(); + void Start(System::BootErrors error); void PushMessage(Display::Messages msg); void StartApp(Apps app, DisplayApp::FullRefreshDirections direction); @@ -116,6 +117,7 @@ namespace Pinetime { Apps nextApp = Apps::None; DisplayApp::FullRefreshDirections nextDirection; + System::BootErrors bootError; }; } } diff --git a/src/displayapp/screens/Error.cpp b/src/displayapp/screens/Error.cpp new file mode 100644 index 00000000..75946aba --- /dev/null +++ b/src/displayapp/screens/Error.cpp @@ -0,0 +1,50 @@ +#include "Error.h" + +using namespace Pinetime::Applications::Screens; + +namespace { + void ButtonEventCallback(lv_obj_t* obj, lv_event_t /*event*/) { + auto* errorScreen = static_cast<Error*>(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()); +} diff --git a/src/displayapp/screens/Error.h b/src/displayapp/screens/Error.h new file mode 100644 index 00000000..20dde7ee --- /dev/null +++ b/src/displayapp/screens/Error.h @@ -0,0 +1,21 @@ +#pragma once + +#include "Screen.h" +#include "BootErrors.h" +#include <lvgl/lvgl.h> + +namespace Pinetime { + namespace Applications { + namespace Screens { + class Error : public Screen { + public: + Error(DisplayApp* app, System::BootErrors error); + ~Error() override; + + void ButtonEventHandler(); + private: + lv_obj_t* btnOk; + }; + } + } +} diff --git a/src/displayapp/screens/SystemInfo.cpp b/src/displayapp/screens/SystemInfo.cpp index b7a4fc60..475fbb88 100644 --- a/src/displayapp/screens/SystemInfo.cpp +++ b/src/displayapp/screens/SystemInfo.cpp @@ -33,7 +33,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}, @@ -41,6 +42,7 @@ SystemInfo::SystemInfo(Pinetime::Applications::DisplayApp* app, bleController {bleController}, watchdog {watchdog}, motionController{motionController}, + touchPanel{touchPanel}, screens {app, 0, {[this]() -> std::unique_ptr<Screen> { @@ -141,7 +143,8 @@ std::unique_ptr<Screen> 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<uint8_t>(dateTimeController.Month()), dateTimeController.Year(), @@ -156,7 +159,10 @@ std::unique_ptr<Screen> 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<Screens::Label>(1, 5, app, label); } diff --git a/src/displayapp/screens/SystemInfo.h b/src/displayapp/screens/SystemInfo.h index 5eb7054d..bfcc3aa4 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 OnTouchEvent(TouchEvents event) override; @@ -39,6 +40,7 @@ namespace Pinetime { Pinetime::Controllers::Ble& bleController; Pinetime::Drivers::WatchdogView& watchdog; Pinetime::Controllers::MotionController& motionController; + Pinetime::Drivers::Cst816S& touchPanel; ScreenList<5> screens; |