diff options
author | Kieran Cawthray <kieranc@gmail.com> | 2021-05-18 17:45:16 +0200 |
---|---|---|
committer | Kieran Cawthray <kieranc@gmail.com> | 2021-05-18 17:45:16 +0200 |
commit | 6a925292722be365f4efc288c64b023639f0c201 (patch) | |
tree | 0d60937546c41844ead44375d6fbee7e6cb3ea0b /src/displayapp/screens/Steps.cpp | |
parent | a4968b502990f4a9e848c5240be2ee73348dd38e (diff) |
Revert "Reset"
This reverts commit 378fa6b4016b65e2d7b128fdc3ce89c4ca779a4d.
Diffstat (limited to 'src/displayapp/screens/Steps.cpp')
-rw-r--r-- | src/displayapp/screens/Steps.cpp | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/src/displayapp/screens/Steps.cpp b/src/displayapp/screens/Steps.cpp new file mode 100644 index 00000000..b485c975 --- /dev/null +++ b/src/displayapp/screens/Steps.cpp @@ -0,0 +1,72 @@ +#include "Steps.h" +#include <lvgl/lvgl.h> +#include "../DisplayApp.h" +#include "Symbols.h" + +using namespace Pinetime::Applications::Screens; + +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, 220, 220); + lv_arc_set_range(stepsArc, 0, 500); + lv_obj_align(stepsArc, nullptr, LV_ALIGN_CENTER, 0, 0); + + stepsCount = motionController.NbSteps(); + + 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, -20); + + 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, 10); + + 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\n%i", settingsController.GetStepsGoal()); + lv_label_set_align(lstepsGoal, LV_LABEL_ALIGN_CENTER); + lv_obj_align(lstepsGoal, lSteps, LV_ALIGN_OUT_BOTTOM_MID, 0, 60); + + 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, ""); + +} + +Steps::~Steps() { + lv_obj_clean(lv_scr_act()); +} + +bool Steps::Refresh() { + + stepsCount = motionController.NbSteps(); + + lv_label_set_text_fmt(lSteps,"%li", stepsCount); + lv_obj_align(lSteps, nullptr, LV_ALIGN_CENTER, 0, -20); + + lv_arc_set_value(stepsArc, int16_t(500 * stepsCount / settingsController.GetStepsGoal())); + + return running; +} + + |