diff options
author | Joaquim <joaquim.org@gmail.com> | 2021-02-01 12:14:49 +0000 |
---|---|---|
committer | Joaquim <joaquim.org@gmail.com> | 2021-02-01 12:14:49 +0000 |
commit | a4361de0cf467b3fc4fad1dffc18d9271ba4f439 (patch) | |
tree | 62e5355ff931eff6b4b2872308d7c91470f4e5ab /src/displayapp/screens | |
parent | ccd423bcef52b241fa0ced82d59fdb432b4347de (diff) |
Cleanup
Diffstat (limited to 'src/displayapp/screens')
-rw-r--r-- | src/displayapp/screens/ApplicationList.cpp | 15 | ||||
-rw-r--r-- | src/displayapp/screens/Gauge.cpp | 60 | ||||
-rw-r--r-- | src/displayapp/screens/Gauge.h | 30 | ||||
-rw-r--r-- | src/displayapp/screens/Modal.cpp | 85 | ||||
-rw-r--r-- | src/displayapp/screens/Modal.h | 36 | ||||
-rw-r--r-- | src/displayapp/screens/Tile.cpp | 3 | ||||
-rw-r--r-- | src/displayapp/screens/Tile.h | 5 |
7 files changed, 10 insertions, 224 deletions
diff --git a/src/displayapp/screens/ApplicationList.cpp b/src/displayapp/screens/ApplicationList.cpp index 0218182b..0f6be270 100644 --- a/src/displayapp/screens/ApplicationList.cpp +++ b/src/displayapp/screens/ApplicationList.cpp @@ -8,11 +8,14 @@ using namespace Pinetime::Applications::Screens; -ApplicationList::ApplicationList(Pinetime::Applications::DisplayApp *app) : Screen(app), - screens{app, { - [this]() -> std::unique_ptr<Screen> { return CreateScreen1(); }, [this]() -> std::unique_ptr<Screen> { return CreateScreen2(); }, - //[this]() -> std::unique_ptr<Screen> { return CreateScreen3(); } - }} +ApplicationList::ApplicationList(Pinetime::Applications::DisplayApp *app) : + Screen(app), + screens{app, { + [this]() -> std::unique_ptr<Screen> { return CreateScreen1(); }, + [this]() -> std::unique_ptr<Screen> { return CreateScreen2(); }, + //[this]() -> std::unique_ptr<Screen> { return CreateScreen3(); } + } + } { } @@ -72,7 +75,7 @@ std::unique_ptr<Screen> ApplicationList::CreateScreen3() { std::array<Screens::Tile::Applications, 6> applications{ {{"A", Apps::Meter}, - {"B", Apps::Gauge}, + {"B", Apps::None}, {"C", Apps::Clock}, {"D", Apps::Music}, {"E", Apps::SysInfo}, diff --git a/src/displayapp/screens/Gauge.cpp b/src/displayapp/screens/Gauge.cpp deleted file mode 100644 index b2e604d3..00000000 --- a/src/displayapp/screens/Gauge.cpp +++ /dev/null @@ -1,60 +0,0 @@ -#include "Gauge.h" -#include "../DisplayApp.h" - -using namespace Pinetime::Applications::Screens; - - -Gauge::Gauge(Pinetime::Applications::DisplayApp *app) : Screen(app) { - /*Create a style*/ - - // ##joaquimorg to FIX - //lv_style_copy(&style, &lv_style_pretty_color); - //style.body.main_color = LV_COLOR_CYAN; /*Line color at the beginning*/ - //style.body.grad_color = LV_COLOR_RED; /*Line color at the end*/ - //style.body.padding.left = 10; /*Scale line length*/ - //style.body.padding.inner = 8 ; /*Scale label padding*/ - //style.body.border.color = lv_color_hex3(0x333); /*Needle middle circle color*/ - //style.line.width = 3; - //style.text.color = LV_COLOR_WHITE; - //style.line.color = LV_COLOR_RED; /*Line color after the critical value*/ - - - /*Describe the color for the needles*/ - - needle_colors[0] = LV_COLOR_ORANGE; - - /*Create a gauge*/ - gauge1 = lv_gauge_create(lv_scr_act(), nullptr); - - // ##joaquimorg to FIX - //lv_gauge_set_style(gauge1, LV_GAUGE_STYLE_MAIN, &style); - - lv_gauge_set_needle_count(gauge1, 1, needle_colors); - lv_obj_set_size(gauge1, 180, 180); - lv_obj_align(gauge1, nullptr, LV_ALIGN_CENTER, 0, 0); - lv_gauge_set_scale(gauge1, 360, 60, 0); - lv_gauge_set_range(gauge1, 0, 59); - - /*Set the values*/ - lv_gauge_set_value(gauge1, 0, value); -} - -Gauge::~Gauge() { - - - lv_obj_clean(lv_scr_act()); -} - -bool Gauge::Refresh() { -// lv_lmeter_set_value(lmeter, value++); /*Set the current value*/ -// if(value>=60) value = 0; - - lv_gauge_set_value(gauge1, 0, value++); - if(value == 59) value = 0; - return running; -} - -bool Gauge::OnButtonPushed() { - running = false; - return true; -} diff --git a/src/displayapp/screens/Gauge.h b/src/displayapp/screens/Gauge.h deleted file mode 100644 index 2a6b8f83..00000000 --- a/src/displayapp/screens/Gauge.h +++ /dev/null @@ -1,30 +0,0 @@ -#pragma once - -#include <cstdint> -#include "Screen.h" -#include <lvgl/lvgl.h> - -namespace Pinetime { - namespace Applications { - namespace Screens { - - class Gauge : public Screen{ - public: - Gauge(DisplayApp* app); - ~Gauge() override; - - bool Refresh() override; - bool OnButtonPushed() override; - - private: - lv_style_t style; - lv_color_t needle_colors[3]; - lv_obj_t * gauge1; - - uint32_t value=30; - bool running = true; - - }; - } - } -} diff --git a/src/displayapp/screens/Modal.cpp b/src/displayapp/screens/Modal.cpp deleted file mode 100644 index 088456c7..00000000 --- a/src/displayapp/screens/Modal.cpp +++ /dev/null @@ -1,85 +0,0 @@ -#include "Modal.h" -#include <lvgl/lvgl.h> -#include "../DisplayApp.h" - -using namespace Pinetime::Applications::Screens; - -Modal::Modal(Pinetime::Applications::DisplayApp *app) : Screen(app) { - - -} - -Modal::~Modal() { - lv_obj_clean(lv_scr_act()); -} - -bool Modal::Refresh() { - - return running; -} - -bool Modal::OnButtonPushed() { - running = false; - return true; -} - -void Modal::Hide() { - /* Delete the parent modal background */ - lv_obj_del_async(lv_obj_get_parent(mbox)); - mbox = NULL; /* happens before object is actually deleted! */ - isVisible = false; -} - -void Modal::mbox_event_cb(lv_obj_t *obj, lv_event_t evt) { - auto* m = static_cast<Modal *>(obj->user_data); - m->OnEvent(obj, evt); -} - -void Modal::OnEvent(lv_obj_t *event_obj, lv_event_t evt) { - if(evt == LV_EVENT_DELETE && event_obj == mbox) { - Hide(); - } else if(evt == LV_EVENT_VALUE_CHANGED) { - /* A button was clicked */ - lv_msgbox_start_auto_close(mbox, 0); -// Hide(); - } -} - -void Modal::Show(const char* msg) { - if(isVisible) return; - isVisible = true; - - // ##joaquimorg to FIX - /*lv_style_copy(&modal_style, &lv_style_plain_color); - modal_style.body.main_color = modal_style.body.grad_color = LV_COLOR_BLACK; - modal_style.body.opa = LV_OPA_50;*/ - - obj = lv_obj_create(lv_scr_act(), nullptr); - // ##joaquimorg to FIX - //lv_obj_set_style(obj, &modal_style); - lv_obj_set_pos(obj, 0, 0); - lv_obj_set_size(obj, LV_HOR_RES, LV_VER_RES); - - // ##joaquimorg to FIX - //lv_obj_set_opa_scale_enable(obj, true); /* Enable opacity scaling for the animation */ - - static const char * btns2[] = {"Ok", ""}; - - /* Create the message box as a child of the modal background */ - mbox = lv_msgbox_create(obj, nullptr); - lv_msgbox_add_btns(mbox, btns2); - lv_msgbox_set_text(mbox, msg); - lv_obj_align(mbox, nullptr, LV_ALIGN_CENTER, 0, 0); - lv_obj_set_event_cb(mbox, Modal::mbox_event_cb); - - mbox->user_data = this; - - /* Fade the message box in with an animation */ - // ##joaquimorg to FIX - /*lv_anim_t a; - lv_anim_init(&a); - lv_anim_set_time(&a, 500, 0); - lv_anim_set_values(&a, LV_OPA_TRANSP, LV_OPA_COVER); - lv_anim_set_exec_cb(&a, obj, (lv_anim_exec_xcb_t)lv_obj_set_opa_scale); - lv_anim_create(&a);*/ -} diff --git a/src/displayapp/screens/Modal.h b/src/displayapp/screens/Modal.h deleted file mode 100644 index 9cc177f0..00000000 --- a/src/displayapp/screens/Modal.h +++ /dev/null @@ -1,36 +0,0 @@ -#pragma once - -#include "Screen.h" -#include <lvgl/src/lv_core/lv_style.h> -#include <lvgl/src/lv_core/lv_obj.h> - -namespace Pinetime { - namespace Applications { - namespace Screens { - - class Modal : public Screen{ - public: - Modal(DisplayApp* app); - ~Modal() override; - - void Show(const char* msg); - void Hide(); - - bool Refresh() override; - bool OnButtonPushed() override; - - static void mbox_event_cb(lv_obj_t *obj, lv_event_t evt); - private: - void OnEvent(lv_obj_t *event_obj, lv_event_t evt); - - lv_style_t modal_style; - lv_obj_t *obj; - lv_obj_t *mbox; - lv_obj_t *info; - bool running = true; - bool isVisible = false; - - }; - } - } -} diff --git a/src/displayapp/screens/Tile.cpp b/src/displayapp/screens/Tile.cpp index b17acbf2..3b82b060 100644 --- a/src/displayapp/screens/Tile.cpp +++ b/src/displayapp/screens/Tile.cpp @@ -20,9 +20,6 @@ Tile::Tile(DisplayApp* app, std::array<Applications, 6>& applications) : Screen( appIndex++; } } - - // ???? - //modal.reset(new Modal(app)); btnm1 = lv_btnmatrix_create(lv_scr_act(), nullptr); lv_btnmatrix_set_map(btnm1, btnm_map1); diff --git a/src/displayapp/screens/Tile.h b/src/displayapp/screens/Tile.h index 7edf67b2..791745dd 100644 --- a/src/displayapp/screens/Tile.h +++ b/src/displayapp/screens/Tile.h @@ -3,7 +3,6 @@ #include <lvgl/lvgl.h> #include <cstdint> #include <memory> -#include "Modal.h" #include "Screen.h" #include "../Apps.h" @@ -28,9 +27,7 @@ namespace Pinetime { private: lv_obj_t * btnm1; bool running = true; - - std::unique_ptr<Modal> modal; - + const char* btnm_map1[8]; Pinetime::Applications::Apps apps[6]; }; |