diff options
Diffstat (limited to 'src/displayapp/screens')
| -rw-r--r-- | src/displayapp/screens/BatteryInfo.cpp | 80 | ||||
| -rw-r--r-- | src/displayapp/screens/BatteryInfo.h | 37 | ||||
| -rw-r--r-- | src/displayapp/screens/settings/Settings.cpp | 43 | ||||
| -rw-r--r-- | src/displayapp/screens/settings/Settings.h | 4 |
4 files changed, 9 insertions, 155 deletions
diff --git a/src/displayapp/screens/BatteryInfo.cpp b/src/displayapp/screens/BatteryInfo.cpp deleted file mode 100644 index e17de9a..0000000 --- a/src/displayapp/screens/BatteryInfo.cpp +++ /dev/null @@ -1,80 +0,0 @@ -#include "displayapp/screens/BatteryInfo.h" -#include "displayapp/DisplayApp.h" -#include "components/battery/BatteryController.h" - -using namespace Pinetime::Applications::Screens; - -BatteryInfo::BatteryInfo(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Battery& batteryController) - : Screen(app), batteryController {batteryController} { - - batteryPercent = batteryController.PercentRemaining(); - batteryVoltage = batteryController.Voltage(); - - charging_bar = lv_bar_create(lv_scr_act(), nullptr); - lv_obj_set_size(charging_bar, 200, 15); - lv_bar_set_range(charging_bar, 0, 100); - lv_obj_align(charging_bar, nullptr, LV_ALIGN_CENTER, 0, 10); - lv_bar_set_anim_time(charging_bar, 1000); - lv_obj_set_style_local_radius(charging_bar, LV_BAR_PART_BG, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE); - lv_obj_set_style_local_bg_color(charging_bar, LV_BAR_PART_BG, LV_STATE_DEFAULT, lv_color_hex(0x222222)); - lv_obj_set_style_local_bg_opa(charging_bar, LV_BAR_PART_BG, LV_STATE_DEFAULT, LV_OPA_100); - lv_obj_set_style_local_bg_color(charging_bar, LV_BAR_PART_INDIC, LV_STATE_DEFAULT, lv_color_hex(0xFF0000)); - lv_bar_set_value(charging_bar, batteryPercent, LV_ANIM_ON); - - status = lv_label_create(lv_scr_act(), nullptr); - lv_label_set_text_static(status, "Reading Battery status"); - lv_label_set_align(status, LV_LABEL_ALIGN_CENTER); - lv_obj_align(status, charging_bar, LV_ALIGN_OUT_BOTTOM_MID, 0, 20); - - percent = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_font(percent, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_76); - lv_label_set_text_fmt(percent, "%02i%%", batteryPercent); - lv_label_set_align(percent, LV_LABEL_ALIGN_LEFT); - lv_obj_align(percent, nullptr, LV_ALIGN_CENTER, 0, -60); - - voltage = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_color(voltage, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xC6A600)); - lv_label_set_text_fmt(voltage, "%1i.%02i volts", batteryVoltage / 1000, batteryVoltage % 1000 / 10); - lv_label_set_align(voltage, LV_LABEL_ALIGN_CENTER); - lv_obj_align(voltage, nullptr, LV_ALIGN_CENTER, 0, 95); - - lv_obj_t* backgroundLabel = lv_label_create(lv_scr_act(), nullptr); - lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CROP); - lv_obj_set_size(backgroundLabel, 240, 240); - lv_obj_set_pos(backgroundLabel, 0, 0); - lv_label_set_text_static(backgroundLabel, ""); - - taskRefresh = lv_task_create(RefreshTaskCallback, 5000, LV_TASK_PRIO_MID, this); - Refresh(); -} - -BatteryInfo::~BatteryInfo() { - lv_task_del(taskRefresh); - lv_obj_clean(lv_scr_act()); -} - -void BatteryInfo::Refresh() { - - batteryPercent = batteryController.PercentRemaining(); - batteryVoltage = batteryController.Voltage(); - - if (batteryController.IsCharging()) { - lv_obj_set_style_local_bg_color(charging_bar, LV_BAR_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_RED); - lv_label_set_text_static(status, "Charging"); - } else if (batteryPercent == 100) { - lv_obj_set_style_local_bg_color(charging_bar, LV_BAR_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_BLUE); - lv_label_set_text_static(status, "Fully charged"); - } else if (batteryPercent < 10) { - lv_obj_set_style_local_bg_color(charging_bar, LV_BAR_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_YELLOW); - lv_label_set_text_static(status, "Battery low"); - } else { - lv_obj_set_style_local_bg_color(charging_bar, LV_BAR_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_GREEN); - lv_label_set_text_static(status, "Discharging"); - } - - lv_label_set_text_fmt(percent, "%02i%%", batteryPercent); - - lv_obj_align(status, charging_bar, LV_ALIGN_OUT_BOTTOM_MID, 0, 20); - lv_label_set_text_fmt(voltage, "%1i.%02i volts", batteryVoltage / 1000, batteryVoltage % 1000 / 10); - lv_bar_set_value(charging_bar, batteryPercent, LV_ANIM_ON); -} diff --git a/src/displayapp/screens/BatteryInfo.h b/src/displayapp/screens/BatteryInfo.h deleted file mode 100644 index de34cdf..0000000 --- a/src/displayapp/screens/BatteryInfo.h +++ /dev/null @@ -1,37 +0,0 @@ -#pragma once - -#include <cstdint> -#include "displayapp/screens/Screen.h" -#include <lvgl/lvgl.h> - -namespace Pinetime { - namespace Controllers { - class Battery; - } - - namespace Applications { - namespace Screens { - - class BatteryInfo : public Screen { - public: - BatteryInfo(DisplayApp* app, Pinetime::Controllers::Battery& batteryController); - ~BatteryInfo() override; - - void Refresh() override; - - private: - Pinetime::Controllers::Battery& batteryController; - - lv_obj_t* voltage; - lv_obj_t* percent; - lv_obj_t* charging_bar; - lv_obj_t* status; - - lv_task_t* taskRefresh; - - uint8_t batteryPercent = 0; - uint16_t batteryVoltage = 0; - }; - } - } -} diff --git a/src/displayapp/screens/settings/Settings.cpp b/src/displayapp/screens/settings/Settings.cpp index 7d259db..c819a38 100644 --- a/src/displayapp/screens/settings/Settings.cpp +++ b/src/displayapp/screens/settings/Settings.cpp @@ -13,18 +13,13 @@ Settings::Settings(Pinetime::Applications::DisplayApp* app, Pinetime::Controller settingsController {settingsController}, screens {app, settingsController.GetSettingsMenu(), - {[this]() -> std::unique_ptr<Screen> { + { + [this]() -> std::unique_ptr<Screen> { return CreateScreen1(); }, [this]() -> std::unique_ptr<Screen> { return CreateScreen2(); }, - [this]() -> std::unique_ptr<Screen> { - return CreateScreen3(); - }, - [this]() -> std::unique_ptr<Screen> { - return CreateScreen4(); - }, }, Screens::ScreenListModes::UpDown} { } @@ -42,42 +37,20 @@ std::unique_ptr<Screen> Settings::CreateScreen1() { {Symbols::sun, "Display", Apps::SettingDisplay}, {Symbols::eye, "Wake Up", Apps::SettingWakeUp}, {Symbols::clock, "Time format", Apps::SettingTimeFormat}, - {Symbols::none, "None", Apps::None} + {Symbols::shoe, "Steps", Apps::SettingSteps} }}; - return std::make_unique<Screens::List>(0, 4, app, settingsController, applications); + return std::make_unique<Screens::List>(0, 1, app, settingsController, applications); } std::unique_ptr<Screen> Settings::CreateScreen2() { std::array<Screens::List::Applications, 4> applications {{ - {Symbols::shoe, "Steps", Apps::SettingSteps}, - {Symbols::none, "None", Apps::None}, - {Symbols::none, "None", Apps::None}, - {Symbols::batteryHalf, "Battery", Apps::BatteryInfo}}}; - - return std::make_unique<Screens::List>(1, 4, app, settingsController, applications); -} - -std::unique_ptr<Screen> Settings::CreateScreen3() { - - std::array<Screens::List::Applications, 4> applications {{ - {Symbols::none, "None", Apps::None}, {Symbols::tachometer, "Shake Calib.", Apps::SettingShakeThreshold}, {Symbols::check, "Firmware", Apps::FirmwareValidation}, - {Symbols::airplane, "Airplane mode", Apps::SettingAirplaneMode} - }}; + {Symbols::airplane, "Airplane mode", Apps::SettingAirplaneMode}, + {Symbols::list, "About", Apps::SysInfo} +}}; - return std::make_unique<Screens::List>(2, 4, app, settingsController, applications); + return std::make_unique<Screens::List>(1, 2, app, settingsController, applications); } -std::unique_ptr<Screen> Settings::CreateScreen4() { - - std::array<Screens::List::Applications, 4> applications {{ - {Symbols::list, "About", Apps::SysInfo}, - {Symbols::none, "None", Apps::None}, - {Symbols::none, "None", Apps::None}, - {Symbols::none, "None", Apps::None} - }}; - - return std::make_unique<Screens::List>(3, 4, app, settingsController, applications); -} diff --git a/src/displayapp/screens/settings/Settings.h b/src/displayapp/screens/settings/Settings.h index be09007..02ccff6 100644 --- a/src/displayapp/screens/settings/Settings.h +++ b/src/displayapp/screens/settings/Settings.h @@ -19,12 +19,10 @@ namespace Pinetime { private: Controllers::Settings& settingsController; - ScreenList<4> screens; + ScreenList<2> screens; std::unique_ptr<Screen> CreateScreen1(); std::unique_ptr<Screen> CreateScreen2(); - std::unique_ptr<Screen> CreateScreen3(); - std::unique_ptr<Screen> CreateScreen4(); }; } } |
