diff options
Diffstat (limited to 'src/displayapp/screens')
| -rw-r--r-- | src/displayapp/screens/ApplicationList.cpp | 1 | ||||
| -rw-r--r-- | src/displayapp/screens/Steps.cpp | 103 | ||||
| -rw-r--r-- | src/displayapp/screens/Steps.h | 44 | ||||
| -rw-r--r-- | src/displayapp/screens/WatchFaceDigital.cpp | 17 | ||||
| -rw-r--r-- | src/displayapp/screens/settings/SettingSteps.cpp | 92 | ||||
| -rw-r--r-- | src/displayapp/screens/settings/SettingSteps.h | 29 | ||||
| -rw-r--r-- | src/displayapp/screens/settings/Settings.cpp | 2 |
7 files changed, 1 insertions, 287 deletions
diff --git a/src/displayapp/screens/ApplicationList.cpp b/src/displayapp/screens/ApplicationList.cpp index b1fdbfd..5daafd1 100644 --- a/src/displayapp/screens/ApplicationList.cpp +++ b/src/displayapp/screens/ApplicationList.cpp @@ -36,7 +36,6 @@ bool ApplicationList::OnTouchEvent(Pinetime::Applications::TouchEvents event) { std::unique_ptr<Screen> ApplicationList::CreateScreen1() { std::array<Screens::Tile::Applications, 6> applications {{ - {Symbols::shoe, Apps::Steps}, {Symbols::clock, Apps::Alarm}, }}; diff --git a/src/displayapp/screens/Steps.cpp b/src/displayapp/screens/Steps.cpp deleted file mode 100644 index 3e7f820..0000000 --- a/src/displayapp/screens/Steps.cpp +++ /dev/null @@ -1,103 +0,0 @@ -#include "displayapp/screens/Steps.h" -#include <lvgl/lvgl.h> -#include "displayapp/DisplayApp.h" -#include "displayapp/screens/Symbols.h" - -using namespace Pinetime::Applications::Screens; - -static void lap_event_handler(lv_obj_t* obj, lv_event_t event) { - auto* steps = static_cast<Steps*>(obj->user_data); - steps->lapBtnEventHandler(event); -} - -Steps::Steps(Pinetime::Applications::DisplayApp* app, - Controllers::MotionController& motionController, - Controllers::Settings& settingsController) - : Screen(app), motionController {motionController}, settingsController {settingsController} { - - stepsArc = lv_arc_create(lv_scr_act(), nullptr); - - lv_obj_set_style_local_bg_opa(stepsArc, LV_ARC_PART_BG, LV_STATE_DEFAULT, LV_OPA_0); - lv_obj_set_style_local_border_width(stepsArc, LV_ARC_PART_BG, LV_STATE_DEFAULT, 2); - lv_obj_set_style_local_radius(stepsArc, LV_ARC_PART_BG, LV_STATE_DEFAULT, 0); - lv_obj_set_style_local_line_color(stepsArc, LV_ARC_PART_INDIC, LV_STATE_DEFAULT, lv_color_hex(0x0000FF)); - lv_arc_set_end_angle(stepsArc, 200); - lv_obj_set_size(stepsArc, 240, 240); - lv_arc_set_range(stepsArc, 0, 500); - lv_obj_align(stepsArc, nullptr, LV_ALIGN_CENTER, 0, 0); - - stepsCount = motionController.NbSteps(); - currentTripSteps = stepsCount - motionController.GetTripSteps(); - - lv_arc_set_value(stepsArc, int16_t(500 * stepsCount / settingsController.GetStepsGoal())); - - lSteps = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_color(lSteps, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00FF00)); - lv_obj_set_style_local_text_font(lSteps, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42); - lv_label_set_text_fmt(lSteps, "%li", stepsCount); - lv_obj_align(lSteps, nullptr, LV_ALIGN_CENTER, 0, -40); - - lv_obj_t* lstepsL = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_color(lstepsL, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x111111)); - lv_label_set_text_static(lstepsL, "Steps"); - lv_obj_align(lstepsL, lSteps, LV_ALIGN_OUT_BOTTOM_MID, 0, 5); - - lv_obj_t* lstepsGoal = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_color(lstepsGoal, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_CYAN); - lv_label_set_text_fmt(lstepsGoal, "Goal: %5lu", settingsController.GetStepsGoal()); - lv_label_set_align(lstepsGoal, LV_LABEL_ALIGN_CENTER); - lv_obj_align(lstepsGoal, lSteps, LV_ALIGN_OUT_BOTTOM_MID, 0, 40); - - 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, ""); - - resetBtn = lv_btn_create(lv_scr_act(), nullptr); - resetBtn->user_data = this; - lv_obj_set_event_cb(resetBtn, lap_event_handler); - lv_obj_set_height(resetBtn, 50); - lv_obj_set_width(resetBtn, 115); - lv_obj_align(resetBtn, lv_scr_act(), LV_ALIGN_IN_BOTTOM_MID, 0, 0); - resetButtonLabel = lv_label_create(resetBtn, nullptr); - lv_label_set_text(resetButtonLabel, "Reset"); - - currentTripSteps = motionController.GetTripSteps(); - - tripLabel = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_color(tripLabel, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_YELLOW); - lv_label_set_text_fmt(tripLabel, "Trip: %5li", currentTripSteps); - lv_obj_align(tripLabel, lstepsGoal, LV_ALIGN_IN_LEFT_MID, 0, 20); - - taskRefresh = lv_task_create(RefreshTaskCallback, 100, LV_TASK_PRIO_MID, this); -} - -Steps::~Steps() { - lv_task_del(taskRefresh); - lv_obj_clean(lv_scr_act()); -} - -void Steps::Refresh() { - stepsCount = motionController.NbSteps(); - currentTripSteps = motionController.GetTripSteps(); - - lv_label_set_text_fmt(lSteps, "%li", stepsCount); - lv_obj_align(lSteps, nullptr, LV_ALIGN_CENTER, 0, -40); - - if (currentTripSteps < 100000) { - lv_label_set_text_fmt(tripLabel, "Trip: %5li", currentTripSteps); - } else { - lv_label_set_text_fmt(tripLabel, "Trip: 99999+"); - } - lv_arc_set_value(stepsArc, int16_t(500 * stepsCount / settingsController.GetStepsGoal())); -} - -void Steps::lapBtnEventHandler(lv_event_t event) { - if (event != LV_EVENT_CLICKED) { - return; - } - stepsCount = motionController.NbSteps(); - motionController.ResetTrip(); - Refresh(); -} diff --git a/src/displayapp/screens/Steps.h b/src/displayapp/screens/Steps.h deleted file mode 100644 index f109e0f..0000000 --- a/src/displayapp/screens/Steps.h +++ /dev/null @@ -1,44 +0,0 @@ -#pragma once - -#include <cstdint> -#include <lvgl/lvgl.h> -#include "displayapp/screens/Screen.h" -#include <components/motion/MotionController.h> - -namespace Pinetime { - - namespace Controllers { - class Settings; - } - - namespace Applications { - namespace Screens { - - class Steps : public Screen { - public: - Steps(DisplayApp* app, Controllers::MotionController& motionController, Controllers::Settings& settingsController); - ~Steps() override; - - void Refresh() override; - void lapBtnEventHandler(lv_event_t event); - - private: - Controllers::MotionController& motionController; - Controllers::Settings& settingsController; - - uint32_t currentTripSteps = 0; - - lv_obj_t* lSteps; - lv_obj_t* lStepsIcon; - lv_obj_t* stepsArc; - lv_obj_t* resetBtn; - lv_obj_t* resetButtonLabel; - lv_obj_t* tripLabel; - - uint32_t stepsCount; - - lv_task_t* taskRefresh; - }; - } - } -} diff --git a/src/displayapp/screens/WatchFaceDigital.cpp b/src/displayapp/screens/WatchFaceDigital.cpp index 053957e..6720318 100644 --- a/src/displayapp/screens/WatchFaceDigital.cpp +++ b/src/displayapp/screens/WatchFaceDigital.cpp @@ -69,16 +69,6 @@ WatchFaceDigital::WatchFaceDigital(DisplayApp* app, lv_obj_set_pos(backgroundLabel, 0, 0); lv_label_set_text_static(backgroundLabel, ""); - stepValue = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_color(stepValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00FFE7)); - lv_label_set_text_static(stepValue, "0"); - lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0); - - stepIcon = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_color(stepIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00FFE7)); - lv_label_set_text_static(stepIcon, Symbols::shoe); - lv_obj_align(stepIcon, stepValue, LV_ALIGN_OUT_LEFT_MID, -5, 0); - taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this); Refresh(); } @@ -175,11 +165,4 @@ void WatchFaceDigital::Refresh() { } } - stepCount = motionController.NbSteps(); - motionSensorOk = motionController.IsSensorOk(); - if (stepCount.IsUpdated() || motionSensorOk.IsUpdated()) { - lv_label_set_text_fmt(stepValue, "%lu", stepCount.Get()); - lv_obj_realign(stepValue); - lv_obj_realign(stepIcon); - } } diff --git a/src/displayapp/screens/settings/SettingSteps.cpp b/src/displayapp/screens/settings/SettingSteps.cpp deleted file mode 100644 index 5ca3eec..0000000 --- a/src/displayapp/screens/settings/SettingSteps.cpp +++ /dev/null @@ -1,92 +0,0 @@ -#include "displayapp/screens/settings/SettingSteps.h" -#include <lvgl/lvgl.h> -#include "displayapp/DisplayApp.h" -#include "displayapp/screens/Symbols.h" - -using namespace Pinetime::Applications::Screens; - -namespace { - void event_handler(lv_obj_t* obj, lv_event_t event) { - SettingSteps* screen = static_cast<SettingSteps*>(obj->user_data); - screen->UpdateSelected(obj, event); - } -} - -SettingSteps::SettingSteps( - Pinetime::Applications::DisplayApp *app, Pinetime::Controllers::Settings &settingsController) : - Screen(app), - settingsController{settingsController} -{ - - lv_obj_t * container1 = lv_cont_create(lv_scr_act(), nullptr); - - //lv_obj_set_style_local_bg_color(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x111111)); - lv_obj_set_style_local_bg_opa(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_TRANSP); - lv_obj_set_style_local_pad_all(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 10); - lv_obj_set_style_local_pad_inner(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 5); - lv_obj_set_style_local_border_width(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 0); - lv_obj_set_pos(container1, 30, 60); - lv_obj_set_width(container1, LV_HOR_RES - 50); - lv_obj_set_height(container1, LV_VER_RES - 60); - lv_cont_set_layout(container1, LV_LAYOUT_COLUMN_LEFT); - - lv_obj_t* title = lv_label_create(lv_scr_act(), nullptr); - lv_label_set_text_static(title,"Daily steps goal"); - lv_label_set_align(title, LV_LABEL_ALIGN_CENTER); - lv_obj_align(title, lv_scr_act(), LV_ALIGN_IN_TOP_MID, 15, 15); - - lv_obj_t* icon = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_color(icon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_ORANGE); - - lv_label_set_text_static(icon, Symbols::shoe); - lv_label_set_align(icon, LV_LABEL_ALIGN_CENTER); - lv_obj_align(icon, title, LV_ALIGN_OUT_LEFT_MID, -10, 0); - - stepValue = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_font(stepValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42); - lv_label_set_text_fmt(stepValue, "%lu", settingsController.GetStepsGoal()); - lv_label_set_align(stepValue, LV_LABEL_ALIGN_CENTER); - lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_CENTER, 0, -10); - - btnPlus = lv_btn_create(lv_scr_act(), nullptr); - btnPlus->user_data = this; - lv_obj_set_size(btnPlus, 80, 50); - lv_obj_align(btnPlus, lv_scr_act(), LV_ALIGN_CENTER, 55, 80); - lv_obj_set_style_local_value_str(btnPlus, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "+"); - lv_obj_set_event_cb(btnPlus, event_handler); - - btnMinus = lv_btn_create(lv_scr_act(), nullptr); - btnMinus->user_data = this; - lv_obj_set_size(btnMinus, 80, 50); - lv_obj_set_event_cb(btnMinus, event_handler); - lv_obj_align(btnMinus, lv_scr_act(), LV_ALIGN_CENTER, -55, 80); - lv_obj_set_style_local_value_str(btnMinus, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "-"); - -} - -SettingSteps::~SettingSteps() { - lv_obj_clean(lv_scr_act()); - settingsController.SaveSettings(); -} - -void SettingSteps::UpdateSelected(lv_obj_t *object, lv_event_t event) { - uint32_t value = settingsController.GetStepsGoal(); - if(object == btnPlus && (event == LV_EVENT_PRESSED)) { - value += 1000; - if ( value <= 500000 ) { - settingsController.SetStepsGoal(value); - lv_label_set_text_fmt(stepValue, "%lu", settingsController.GetStepsGoal()); - lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_CENTER, 0, -10); - } - } - - if(object == btnMinus && (event == LV_EVENT_PRESSED)) { - value -= 1000; - if ( value >= 1000 ) { - settingsController.SetStepsGoal(value); - lv_label_set_text_fmt(stepValue, "%lu", settingsController.GetStepsGoal()); - lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_CENTER, 0, -10); - } - } - -} diff --git a/src/displayapp/screens/settings/SettingSteps.h b/src/displayapp/screens/settings/SettingSteps.h deleted file mode 100644 index 5fc05de..0000000 --- a/src/displayapp/screens/settings/SettingSteps.h +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once - -#include <cstdint> -#include <lvgl/lvgl.h> -#include "components/settings/Settings.h" -#include "displayapp/screens/Screen.h" - -namespace Pinetime { - - namespace Applications { - namespace Screens { - - class SettingSteps : public Screen { - public: - SettingSteps(DisplayApp* app, Pinetime::Controllers::Settings& settingsController); - ~SettingSteps() override; - - void UpdateSelected(lv_obj_t* object, lv_event_t event); - - private: - Controllers::Settings& settingsController; - - lv_obj_t* stepValue; - lv_obj_t* btnPlus; - lv_obj_t* btnMinus; - }; - } - } -} diff --git a/src/displayapp/screens/settings/Settings.cpp b/src/displayapp/screens/settings/Settings.cpp index d2475f8..01dd534 100644 --- a/src/displayapp/screens/settings/Settings.cpp +++ b/src/displayapp/screens/settings/Settings.cpp @@ -37,7 +37,7 @@ std::unique_ptr<Screen> Settings::CreateScreen1() { {Symbols::sun, "Display", Apps::SettingDisplay}, {Symbols::eye, "Wake Up", Apps::SettingWakeUp}, {Symbols::clock, "Time format", Apps::SettingTimeFormat}, - {Symbols::shoe, "Steps", Apps::SettingSteps} + {Symbols::none, "None", Apps::None} }}; return std::make_unique<Screens::List>(0, 1, app, settingsController, applications); |
