From 38ab0add487183c2f7e0a1e545de49a8ad7b17e1 Mon Sep 17 00:00:00 2001 From: Kieran Cawthray Date: Thu, 24 Jun 2021 19:15:23 +0200 Subject: PineTimeStyle color picker initial commit --- .../screens/settings/SettingPineTimeStyle.cpp | 302 +++++++++++++++++++++ 1 file changed, 302 insertions(+) create mode 100644 src/displayapp/screens/settings/SettingPineTimeStyle.cpp (limited to 'src/displayapp/screens/settings/SettingPineTimeStyle.cpp') diff --git a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp new file mode 100644 index 00000000..3aceeb71 --- /dev/null +++ b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp @@ -0,0 +1,302 @@ +#include "SettingPineTimeStyle.h" +#include +#include "displayapp/DisplayApp.h" +#include "displayapp/screens/Symbols.h" + +using namespace Pinetime::Applications::Screens; + +namespace { + static void event_handler(lv_obj_t * obj, lv_event_t event) { + SettingPineTimeStyle* screen = static_cast(obj->user_data); + screen->UpdateSelected(obj, event); + } +} + +SettingPineTimeStyle::SettingPineTimeStyle( + Pinetime::Applications::DisplayApp *app, Pinetime::Controllers::Settings &settingsController) : + Screen(app), + settingsController{settingsController} +{ + + timebar = lv_obj_create(lv_scr_act(), nullptr); + lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000)); + lv_obj_set_style_local_radius(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0); + lv_obj_set_size(timebar, 200, 240); + lv_obj_align(timebar, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 5, 0); + + /* Display the time */ + + timeDD1 = lv_label_create(lv_scr_act(), nullptr); + lv_obj_set_style_local_text_font(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &open_sans_light); + lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x008080)); + lv_label_set_text(timeDD1, "12"); + lv_obj_align(timeDD1, timebar, LV_ALIGN_IN_TOP_MID, 5, 5); + + timeDD2 = lv_label_create(lv_scr_act(), nullptr); + lv_obj_set_style_local_text_font(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &open_sans_light); + lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x008080)); + lv_label_set_text(timeDD2, "34"); + lv_obj_align(timeDD2, timebar, LV_ALIGN_IN_BOTTOM_MID, 5, -5); + + timeAMPM = lv_label_create(lv_scr_act(), nullptr); + lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x008080)); + lv_obj_set_style_local_text_line_space(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, -3); + lv_label_set_text(timeAMPM, "A\nM"); + lv_obj_align(timeAMPM, timebar, LV_ALIGN_IN_BOTTOM_LEFT, 2, -20); + + /* Create a 40px wide bar down the right side of the screen */ + + sidebar = lv_obj_create(lv_scr_act(), nullptr); + lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x008080)); + lv_obj_set_style_local_radius(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0); + lv_obj_set_size(sidebar, 40, 240); + lv_obj_align(sidebar, lv_scr_act(), LV_ALIGN_IN_TOP_RIGHT, 0, 0); + + /* Display icons */ + + batteryIcon = lv_label_create(lv_scr_act(), nullptr); + lv_obj_set_style_local_text_color(batteryIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000)); + lv_label_set_text(batteryIcon, Symbols::batteryFull); + lv_obj_align(batteryIcon, sidebar, LV_ALIGN_IN_TOP_MID, 0, 2); + + bleIcon = lv_label_create(lv_scr_act(), nullptr); + lv_obj_set_style_local_text_color(bleIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000)); + lv_label_set_text(bleIcon, Symbols::bluetooth); + lv_obj_align(bleIcon, sidebar, LV_ALIGN_IN_TOP_MID, 0, 25); + + /* Calendar icon */ + + calendarOuter = lv_obj_create(lv_scr_act(), nullptr); + lv_obj_set_style_local_bg_color(calendarOuter, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000)); + lv_obj_set_style_local_radius(calendarOuter, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0); + lv_obj_set_size(calendarOuter, 34, 34); + lv_obj_align(calendarOuter, sidebar, LV_ALIGN_CENTER, 0, 0); + + calendarInner = lv_obj_create(lv_scr_act(), nullptr); + lv_obj_set_style_local_bg_color(calendarInner, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xffffff)); + lv_obj_set_style_local_radius(calendarInner, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0); + lv_obj_set_size(calendarInner, 27, 27); + lv_obj_align(calendarInner, calendarOuter, LV_ALIGN_CENTER, 0, 0); + + calendarBar1 = lv_obj_create(lv_scr_act(), nullptr); + lv_obj_set_style_local_bg_color(calendarBar1, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000)); + lv_obj_set_style_local_radius(calendarBar1, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0); + lv_obj_set_size(calendarBar1, 3, 12); + lv_obj_align(calendarBar1, calendarOuter, LV_ALIGN_IN_TOP_MID, -6, -3); + + calendarBar2 = lv_obj_create(lv_scr_act(), nullptr); + lv_obj_set_style_local_bg_color(calendarBar2, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000)); + lv_obj_set_style_local_radius(calendarBar2, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0); + lv_obj_set_size(calendarBar2, 3, 12); + lv_obj_align(calendarBar2, calendarOuter, LV_ALIGN_IN_TOP_MID, 6, -3); + + calendarCrossBar1 = lv_obj_create(lv_scr_act(), nullptr); + lv_obj_set_style_local_bg_color(calendarCrossBar1, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000)); + lv_obj_set_style_local_radius(calendarCrossBar1, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0); + lv_obj_set_size(calendarCrossBar1, 8, 3); + lv_obj_align(calendarCrossBar1, calendarBar1, LV_ALIGN_IN_BOTTOM_MID, 0, 0); + + calendarCrossBar2 = lv_obj_create(lv_scr_act(), nullptr); + lv_obj_set_style_local_bg_color(calendarCrossBar2, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000)); + lv_obj_set_style_local_radius(calendarCrossBar2, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0); + lv_obj_set_size(calendarCrossBar2, 8, 3); + lv_obj_align(calendarCrossBar2, calendarBar2, LV_ALIGN_IN_BOTTOM_MID, 0, 0); + + /* Display date */ + + dateDayOfWeek = lv_label_create(lv_scr_act(), nullptr); + lv_obj_set_style_local_text_color(dateDayOfWeek, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000)); + lv_label_set_text(dateDayOfWeek, "THU"); + lv_obj_align(dateDayOfWeek, sidebar, LV_ALIGN_CENTER, 0, -34); + + dateDay = lv_label_create(lv_scr_act(), nullptr); + lv_obj_set_style_local_text_color(dateDay, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000)); + lv_label_set_text(dateDay, "25"); + lv_obj_align(dateDay, sidebar, LV_ALIGN_CENTER, 0, 3); + + dateMonth = lv_label_create(lv_scr_act(), nullptr); + lv_obj_set_style_local_text_color(dateMonth, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000)); + lv_label_set_text(dateMonth, "MAR"); + lv_obj_align(dateMonth, sidebar, LV_ALIGN_CENTER, 0, 32); + + // Step count gauge + needle_colors[0] = LV_COLOR_WHITE; + stepGauge = lv_gauge_create(lv_scr_act(), nullptr); + lv_gauge_set_needle_count(stepGauge, 1, needle_colors); + lv_obj_set_size(stepGauge, 40, 40); + lv_obj_align(stepGauge, sidebar, LV_ALIGN_IN_BOTTOM_MID, 0, 0); + lv_gauge_set_scale(stepGauge, 360, 11, 0); + lv_gauge_set_angle_offset(stepGauge, 180); + lv_gauge_set_critical_value(stepGauge, (100)); + lv_gauge_set_range(stepGauge, 0, (100)); + lv_gauge_set_value(stepGauge, 0, 0); + + lv_obj_set_style_local_pad_right(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, 3); + lv_obj_set_style_local_pad_left(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, 3); + lv_obj_set_style_local_pad_bottom(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, 3); + lv_obj_set_style_local_line_opa(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_COVER); + lv_obj_set_style_local_scale_width(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, 4); + lv_obj_set_style_local_line_width(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, 4); + lv_obj_set_style_local_line_color(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK); + lv_obj_set_style_local_line_opa(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, LV_OPA_COVER); + lv_obj_set_style_local_line_width(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, 4); + lv_obj_set_style_local_pad_inner(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, 4); + +// lv_style_copy(&style_button, &lv_style_plain_color); +// style_button.body.opa = LV_OPA_50; + btnNextTime = lv_btn_create(lv_scr_act(), nullptr); + btnNextTime->user_data = this; + lv_obj_set_size(btnNextTime, 50, 50); + lv_obj_align(btnNextTime, lv_scr_act(), LV_ALIGN_CENTER, 55, -80); + lv_obj_set_style_local_value_str(btnNextTime, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, ">"); + lv_obj_set_event_cb(btnNextTime, event_handler); + + btnPrevTime = lv_btn_create(lv_scr_act(), nullptr); + btnPrevTime->user_data = this; + lv_obj_set_size(btnPrevTime, 50, 50); + lv_obj_align(btnPrevTime, lv_scr_act(), LV_ALIGN_CENTER, -55, -80); + lv_obj_set_style_local_value_str(btnPrevTime, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "<"); + lv_obj_set_event_cb(btnPrevTime, event_handler); + + btnNextBar = lv_btn_create(lv_scr_act(), nullptr); + btnNextBar->user_data = this; + lv_obj_set_size(btnNextBar, 50, 50); + lv_obj_align(btnNextBar, lv_scr_act(), LV_ALIGN_CENTER, 55, 0); + lv_obj_set_style_local_value_str(btnNextBar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, ">"); + lv_obj_set_event_cb(btnNextBar, event_handler); + + btnPrevBar = lv_btn_create(lv_scr_act(), nullptr); + btnPrevBar->user_data = this; + lv_obj_set_size(btnPrevBar, 50, 50); + lv_obj_align(btnPrevBar, lv_scr_act(), LV_ALIGN_CENTER, -55, 0); + lv_obj_set_style_local_value_str(btnPrevBar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "<"); + lv_obj_set_event_cb(btnPrevBar, event_handler); + + btnNextBG = lv_btn_create(lv_scr_act(), nullptr); + btnNextBG->user_data = this; + lv_obj_set_size(btnNextBG, 50, 50); + lv_obj_align(btnNextBG, lv_scr_act(), LV_ALIGN_CENTER, 55, 80); + lv_obj_set_style_local_value_str(btnNextBG, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, ">"); + lv_obj_set_event_cb(btnNextBG, event_handler); + + btnPrevBG = lv_btn_create(lv_scr_act(), nullptr); + btnPrevBG->user_data = this; + lv_obj_set_size(btnPrevBG, 50, 50); + lv_obj_align(btnPrevBG, lv_scr_act(), LV_ALIGN_CENTER, -55, 80); + lv_obj_set_style_local_value_str(btnPrevBG, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "<"); + lv_obj_set_event_cb(btnPrevBG, event_handler); + + backgroundLabel = lv_label_create(lv_scr_act(), nullptr); + lv_obj_set_click(backgroundLabel, true); + 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(backgroundLabel, ""); + + +/* + + 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,"%i", 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, "-"); +*/ +} + +SettingPineTimeStyle::~SettingPineTimeStyle() { + lv_obj_clean(lv_scr_act()); + settingsController.SaveSettings(); +} + +bool SettingPineTimeStyle::Refresh() { + return running; +} + +void SettingPineTimeStyle::UpdateSelected(lv_obj_t *object, lv_event_t event) { + uint8_t value = 0; + lv_color_t pts_colors[17] = {LV_COLOR_WHITE, LV_COLOR_SILVER, LV_COLOR_GRAY, LV_COLOR_BLACK, + LV_COLOR_RED, LV_COLOR_MAROON, LV_COLOR_YELLOW, LV_COLOR_OLIVE, + LV_COLOR_LIME, LV_COLOR_GREEN, LV_COLOR_CYAN, LV_COLOR_TEAL, + LV_COLOR_BLUE, LV_COLOR_NAVY, LV_COLOR_MAGENTA, LV_COLOR_PURPLE, + LV_COLOR_ORANGE}; + + if((object == btnNextBar) && (event == LV_EVENT_PRESSED)) { + if ( value < 16 ) { + value += 1; + lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[value]); + } + } + if((object == btnPrevBar) && (event == LV_EVENT_PRESSED)) { + if ( value > 0 ) { + value -= 1; + lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[value]); + } + } + if((object == btnNextTime) && (event == LV_EVENT_PRESSED)) { + if ( value < 16 ) { + value += 1; + lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[value]); + lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[value]); + lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[value]); + } + } + if((object == btnPrevTime) && (event == LV_EVENT_PRESSED)) { + if ( value > 0 ) { + value -= 1; + lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[value]); + lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[value]); + lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[value]); + } + } + if((object == btnNextBG) && (event == LV_EVENT_PRESSED)) { + if ( value < 16 ) { + value += 1; + lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[value]); + } + } + + if((object == btnPrevBG) && (event == LV_EVENT_PRESSED)) { + if ( value > 0 ) { + value -= 1; + lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[value]); + } + } + + + +/* + 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,"%i", 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,"%i", settingsController.GetStepsGoal()); + lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_CENTER, 0, -10); + } + } +*/ +} \ No newline at end of file -- cgit v1.2.3-70-g09d2 From 7edfc534819ba7b9a14523d84df62952852a0fe3 Mon Sep 17 00:00:00 2001 From: Kieran Cawthray Date: Thu, 24 Jun 2021 21:49:04 +0200 Subject: PineTimeStyle color picker add settings integration --- src/components/settings/Settings.h | 31 +++++++ .../screens/settings/SettingPineTimeStyle.cpp | 98 ++++++++++++---------- 2 files changed, 84 insertions(+), 45 deletions(-) (limited to 'src/displayapp/screens/settings/SettingPineTimeStyle.cpp') diff --git a/src/components/settings/Settings.h b/src/components/settings/Settings.h index 4409425b..69e28e5b 100644 --- a/src/components/settings/Settings.h +++ b/src/components/settings/Settings.h @@ -27,6 +27,33 @@ namespace Pinetime { return settings.clockFace; }; + void SetPTSColorTime(uint8_t colorTime) { + if (colorTime != settings.PTSColorTime) + settingsChanged = true; + settings.PTSColorTime = colorTime; + }; + uint8_t GetPTSColorTime() const { + return settings.PTSColorTime; + }; + + void SetPTSColorBar(uint8_t colorBar) { + if (colorBar != settings.PTSColorBar) + settingsChanged = true; + settings.PTSColorBar = colorBar; + }; + uint8_t GetPTSColorBar() const { + return settings.PTSColorBar; + }; + + void SetPTSColorBG(uint8_t colorBG) { + if (colorBG != settings.PTSColorBG) + settingsChanged = true; + settings.PTSColorBG = colorBG; + }; + uint8_t GetPTSColorBG() const { + return settings.PTSColorBG; + }; + void SetAppMenu(uint8_t menu) { appMenu = menu; }; @@ -103,6 +130,10 @@ namespace Pinetime { uint8_t clockFace = 0; + uint8_t PTSColorTime = 11; + uint8_t PTSColorBar = 11; + uint8_t PTSColorBG = 3; + uint32_t stepsGoal = 10000; uint32_t screenTimeOut = 15000; diff --git a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp index 3aceeb71..3673e79c 100644 --- a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp +++ b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp @@ -12,6 +12,12 @@ namespace { } } +lv_color_t pts_colors[17] = {LV_COLOR_WHITE, LV_COLOR_SILVER, LV_COLOR_GRAY, LV_COLOR_BLACK, + LV_COLOR_RED, LV_COLOR_MAROON, LV_COLOR_YELLOW, LV_COLOR_OLIVE, + LV_COLOR_LIME, LV_COLOR_GREEN, LV_COLOR_CYAN, LV_COLOR_TEAL, + LV_COLOR_BLUE, LV_COLOR_NAVY, LV_COLOR_MAGENTA, LV_COLOR_PURPLE, + LV_COLOR_ORANGE}; + SettingPineTimeStyle::SettingPineTimeStyle( Pinetime::Applications::DisplayApp *app, Pinetime::Controllers::Settings &settingsController) : Screen(app), @@ -19,7 +25,7 @@ SettingPineTimeStyle::SettingPineTimeStyle( { timebar = lv_obj_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000)); + lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK); lv_obj_set_style_local_radius(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0); lv_obj_set_size(timebar, 200, 240); lv_obj_align(timebar, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 5, 0); @@ -28,18 +34,18 @@ SettingPineTimeStyle::SettingPineTimeStyle( timeDD1 = lv_label_create(lv_scr_act(), nullptr); lv_obj_set_style_local_text_font(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &open_sans_light); - lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x008080)); + lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_TEAL); lv_label_set_text(timeDD1, "12"); lv_obj_align(timeDD1, timebar, LV_ALIGN_IN_TOP_MID, 5, 5); timeDD2 = lv_label_create(lv_scr_act(), nullptr); lv_obj_set_style_local_text_font(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &open_sans_light); - lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x008080)); + lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_TEAL); lv_label_set_text(timeDD2, "34"); lv_obj_align(timeDD2, timebar, LV_ALIGN_IN_BOTTOM_MID, 5, -5); timeAMPM = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x008080)); + lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_TEAL); lv_obj_set_style_local_text_line_space(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, -3); lv_label_set_text(timeAMPM, "A\nM"); lv_obj_align(timeAMPM, timebar, LV_ALIGN_IN_BOTTOM_LEFT, 2, -20); @@ -47,7 +53,7 @@ SettingPineTimeStyle::SettingPineTimeStyle( /* Create a 40px wide bar down the right side of the screen */ sidebar = lv_obj_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x008080)); + lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_TEAL); lv_obj_set_style_local_radius(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0); lv_obj_set_size(sidebar, 40, 240); lv_obj_align(sidebar, lv_scr_act(), LV_ALIGN_IN_TOP_RIGHT, 0, 0); @@ -142,6 +148,13 @@ SettingPineTimeStyle::SettingPineTimeStyle( lv_obj_set_style_local_line_width(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, 4); lv_obj_set_style_local_pad_inner(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, 4); + backgroundLabel = lv_label_create(lv_scr_act(), nullptr); + lv_obj_set_click(backgroundLabel, true); + 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(backgroundLabel, ""); + // lv_style_copy(&style_button, &lv_style_plain_color); // style_button.body.opa = LV_OPA_50; btnNextTime = lv_btn_create(lv_scr_act(), nullptr); @@ -186,14 +199,6 @@ SettingPineTimeStyle::SettingPineTimeStyle( lv_obj_set_style_local_value_str(btnPrevBG, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "<"); lv_obj_set_event_cb(btnPrevBG, event_handler); - backgroundLabel = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_click(backgroundLabel, true); - 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(backgroundLabel, ""); - - /* stepValue = lv_label_create(lv_scr_act(), nullptr); @@ -228,52 +233,55 @@ bool SettingPineTimeStyle::Refresh() { } void SettingPineTimeStyle::UpdateSelected(lv_obj_t *object, lv_event_t event) { - uint8_t value = 0; - lv_color_t pts_colors[17] = {LV_COLOR_WHITE, LV_COLOR_SILVER, LV_COLOR_GRAY, LV_COLOR_BLACK, - LV_COLOR_RED, LV_COLOR_MAROON, LV_COLOR_YELLOW, LV_COLOR_OLIVE, - LV_COLOR_LIME, LV_COLOR_GREEN, LV_COLOR_CYAN, LV_COLOR_TEAL, - LV_COLOR_BLUE, LV_COLOR_NAVY, LV_COLOR_MAGENTA, LV_COLOR_PURPLE, - LV_COLOR_ORANGE}; + uint8_t valueTime = settingsController.GetPTSColorTime(); + uint8_t valueBar = settingsController.GetPTSColorBar(); + uint8_t valueBG = settingsController.GetPTSColorBG(); - if((object == btnNextBar) && (event == LV_EVENT_PRESSED)) { - if ( value < 16 ) { - value += 1; - lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[value]); + if((object == btnNextTime) && (event == LV_EVENT_PRESSED)) { + if ( valueTime < 17 ) { + valueTime += 1; + settingsController.SetPTSColorTime(valueTime); + lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); + lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); + lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); } } - if((object == btnPrevBar) && (event == LV_EVENT_PRESSED)) { - if ( value > 0 ) { - value -= 1; - lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[value]); + if((object == btnPrevTime) && (event == LV_EVENT_PRESSED)) { + if ( valueTime > 0 ) { + valueTime -= 1; + settingsController.SetPTSColorTime(valueTime); + lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); + lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); + lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); } } - if((object == btnNextTime) && (event == LV_EVENT_PRESSED)) { - if ( value < 16 ) { - value += 1; - lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[value]); - lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[value]); - lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[value]); + if((object == btnNextBar) && (event == LV_EVENT_PRESSED)) { + if ( valueBar < 17 ) { + valueBar += 1; + settingsController.SetPTSColorBar(valueBar); + lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBar]); } } - if((object == btnPrevTime) && (event == LV_EVENT_PRESSED)) { - if ( value > 0 ) { - value -= 1; - lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[value]); - lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[value]); - lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[value]); + if((object == btnPrevBar) && (event == LV_EVENT_PRESSED)) { + if ( valueBar > 0 ) { + valueBar -= 1; + settingsController.SetPTSColorBar(valueBar); + lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBar]); } } if((object == btnNextBG) && (event == LV_EVENT_PRESSED)) { - if ( value < 16 ) { - value += 1; - lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[value]); + if ( valueBG < 17 ) { + valueBG += 1; + settingsController.SetPTSColorBG(valueBG); + lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBG]); } } if((object == btnPrevBG) && (event == LV_EVENT_PRESSED)) { - if ( value > 0 ) { - value -= 1; - lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[value]); + if ( valueBG > 0 ) { + valueBG -= 1; + settingsController.SetPTSColorBG(valueBG); + lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBG]); } } -- cgit v1.2.3-70-g09d2 From 8f16574992b1bb0f49b884f95cf9b7f5d709c6b6 Mon Sep 17 00:00:00 2001 From: Kieran Cawthray Date: Thu, 24 Jun 2021 21:51:23 +0200 Subject: PineTimeStyle color picker tidying --- .../screens/settings/SettingPineTimeStyle.cpp | 59 ++-------------------- .../screens/settings/SettingPineTimeStyle.h | 2 - 2 files changed, 5 insertions(+), 56 deletions(-) (limited to 'src/displayapp/screens/settings/SettingPineTimeStyle.cpp') diff --git a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp index 3673e79c..dcdd6700 100644 --- a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp +++ b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp @@ -30,7 +30,7 @@ SettingPineTimeStyle::SettingPineTimeStyle( lv_obj_set_size(timebar, 200, 240); lv_obj_align(timebar, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 5, 0); - /* Display the time */ + // Display the time timeDD1 = lv_label_create(lv_scr_act(), nullptr); lv_obj_set_style_local_text_font(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &open_sans_light); @@ -50,7 +50,7 @@ SettingPineTimeStyle::SettingPineTimeStyle( lv_label_set_text(timeAMPM, "A\nM"); lv_obj_align(timeAMPM, timebar, LV_ALIGN_IN_BOTTOM_LEFT, 2, -20); - /* Create a 40px wide bar down the right side of the screen */ + // Create a 40px wide bar down the right side of the screen sidebar = lv_obj_create(lv_scr_act(), nullptr); lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_TEAL); @@ -58,7 +58,7 @@ SettingPineTimeStyle::SettingPineTimeStyle( lv_obj_set_size(sidebar, 40, 240); lv_obj_align(sidebar, lv_scr_act(), LV_ALIGN_IN_TOP_RIGHT, 0, 0); - /* Display icons */ + // Display icons batteryIcon = lv_label_create(lv_scr_act(), nullptr); lv_obj_set_style_local_text_color(batteryIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000)); @@ -70,7 +70,7 @@ SettingPineTimeStyle::SettingPineTimeStyle( lv_label_set_text(bleIcon, Symbols::bluetooth); lv_obj_align(bleIcon, sidebar, LV_ALIGN_IN_TOP_MID, 0, 25); - /* Calendar icon */ + // Calendar icon calendarOuter = lv_obj_create(lv_scr_act(), nullptr); lv_obj_set_style_local_bg_color(calendarOuter, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000)); @@ -108,7 +108,7 @@ SettingPineTimeStyle::SettingPineTimeStyle( lv_obj_set_size(calendarCrossBar2, 8, 3); lv_obj_align(calendarCrossBar2, calendarBar2, LV_ALIGN_IN_BOTTOM_MID, 0, 0); - /* Display date */ + // Display date dateDayOfWeek = lv_label_create(lv_scr_act(), nullptr); lv_obj_set_style_local_text_color(dateDayOfWeek, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000)); @@ -155,8 +155,6 @@ SettingPineTimeStyle::SettingPineTimeStyle( lv_obj_set_pos(backgroundLabel, 0, 0); lv_label_set_text(backgroundLabel, ""); -// lv_style_copy(&style_button, &lv_style_plain_color); -// style_button.body.opa = LV_OPA_50; btnNextTime = lv_btn_create(lv_scr_act(), nullptr); btnNextTime->user_data = this; lv_obj_set_size(btnNextTime, 50, 50); @@ -198,29 +196,6 @@ SettingPineTimeStyle::SettingPineTimeStyle( lv_obj_align(btnPrevBG, lv_scr_act(), LV_ALIGN_CENTER, -55, 80); lv_obj_set_style_local_value_str(btnPrevBG, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "<"); lv_obj_set_event_cb(btnPrevBG, event_handler); - -/* - - 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,"%i", 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, "-"); -*/ } SettingPineTimeStyle::~SettingPineTimeStyle() { @@ -276,7 +251,6 @@ void SettingPineTimeStyle::UpdateSelected(lv_obj_t *object, lv_event_t event) { lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBG]); } } - if((object == btnPrevBG) && (event == LV_EVENT_PRESSED)) { if ( valueBG > 0 ) { valueBG -= 1; @@ -284,27 +258,4 @@ void SettingPineTimeStyle::UpdateSelected(lv_obj_t *object, lv_event_t event) { lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBG]); } } - - - -/* - 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,"%i", 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,"%i", settingsController.GetStepsGoal()); - lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_CENTER, 0, -10); - } - } -*/ } \ No newline at end of file diff --git a/src/displayapp/screens/settings/SettingPineTimeStyle.h b/src/displayapp/screens/settings/SettingPineTimeStyle.h index 5b5e61bf..b8ec9e9e 100644 --- a/src/displayapp/screens/settings/SettingPineTimeStyle.h +++ b/src/displayapp/screens/settings/SettingPineTimeStyle.h @@ -19,7 +19,6 @@ namespace Pinetime { void UpdateSelected(lv_obj_t *object, lv_event_t event); private: - Controllers::Settings& settingsController; lv_obj_t * btnNextTime; @@ -51,7 +50,6 @@ namespace Pinetime { lv_obj_t * stepGauge; lv_color_t needle_colors[1]; lv_color_t pts_colors[17]; - }; } } -- cgit v1.2.3-70-g09d2 From 50b92e5dd6bd879b61e5038d3f064d486db864f6 Mon Sep 17 00:00:00 2001 From: Kieran Cawthray Date: Fri, 25 Jun 2021 14:47:56 +0200 Subject: Move array to member variable, retrieve colors from settings for display --- .../screens/settings/SettingPineTimeStyle.cpp | 17 +++++------------ src/displayapp/screens/settings/SettingPineTimeStyle.h | 6 +++++- 2 files changed, 10 insertions(+), 13 deletions(-) (limited to 'src/displayapp/screens/settings/SettingPineTimeStyle.cpp') diff --git a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp index dcdd6700..bad0fec2 100644 --- a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp +++ b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp @@ -12,20 +12,13 @@ namespace { } } -lv_color_t pts_colors[17] = {LV_COLOR_WHITE, LV_COLOR_SILVER, LV_COLOR_GRAY, LV_COLOR_BLACK, - LV_COLOR_RED, LV_COLOR_MAROON, LV_COLOR_YELLOW, LV_COLOR_OLIVE, - LV_COLOR_LIME, LV_COLOR_GREEN, LV_COLOR_CYAN, LV_COLOR_TEAL, - LV_COLOR_BLUE, LV_COLOR_NAVY, LV_COLOR_MAGENTA, LV_COLOR_PURPLE, - LV_COLOR_ORANGE}; - SettingPineTimeStyle::SettingPineTimeStyle( Pinetime::Applications::DisplayApp *app, Pinetime::Controllers::Settings &settingsController) : Screen(app), settingsController{settingsController} { - timebar = lv_obj_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK); + lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[settingsController.GetPTSColorBG()]); lv_obj_set_style_local_radius(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0); lv_obj_set_size(timebar, 200, 240); lv_obj_align(timebar, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 5, 0); @@ -34,18 +27,18 @@ SettingPineTimeStyle::SettingPineTimeStyle( timeDD1 = lv_label_create(lv_scr_act(), nullptr); lv_obj_set_style_local_text_font(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &open_sans_light); - lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_TEAL); + lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[settingsController.GetPTSColorTime()]); lv_label_set_text(timeDD1, "12"); lv_obj_align(timeDD1, timebar, LV_ALIGN_IN_TOP_MID, 5, 5); timeDD2 = lv_label_create(lv_scr_act(), nullptr); lv_obj_set_style_local_text_font(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &open_sans_light); - lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_TEAL); + lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[settingsController.GetPTSColorTime()]); lv_label_set_text(timeDD2, "34"); lv_obj_align(timeDD2, timebar, LV_ALIGN_IN_BOTTOM_MID, 5, -5); timeAMPM = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_TEAL); + lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[settingsController.GetPTSColorTime()]); lv_obj_set_style_local_text_line_space(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, -3); lv_label_set_text(timeAMPM, "A\nM"); lv_obj_align(timeAMPM, timebar, LV_ALIGN_IN_BOTTOM_LEFT, 2, -20); @@ -53,7 +46,7 @@ SettingPineTimeStyle::SettingPineTimeStyle( // Create a 40px wide bar down the right side of the screen sidebar = lv_obj_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_TEAL); + lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[settingsController.GetPTSColorBar()]); lv_obj_set_style_local_radius(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0); lv_obj_set_size(sidebar, 40, 240); lv_obj_align(sidebar, lv_scr_act(), LV_ALIGN_IN_TOP_RIGHT, 0, 0); diff --git a/src/displayapp/screens/settings/SettingPineTimeStyle.h b/src/displayapp/screens/settings/SettingPineTimeStyle.h index b8ec9e9e..9b20f9fb 100644 --- a/src/displayapp/screens/settings/SettingPineTimeStyle.h +++ b/src/displayapp/screens/settings/SettingPineTimeStyle.h @@ -49,7 +49,11 @@ namespace Pinetime { lv_obj_t * calendarCrossBar2; lv_obj_t * stepGauge; lv_color_t needle_colors[1]; - lv_color_t pts_colors[17]; + lv_color_t pts_colors[17] = {LV_COLOR_WHITE, LV_COLOR_SILVER, LV_COLOR_GRAY, LV_COLOR_BLACK, + LV_COLOR_RED, LV_COLOR_MAROON, LV_COLOR_YELLOW, LV_COLOR_OLIVE, + LV_COLOR_LIME, LV_COLOR_GREEN, LV_COLOR_CYAN, LV_COLOR_TEAL, + LV_COLOR_BLUE, LV_COLOR_NAVY, LV_COLOR_MAGENTA, LV_COLOR_PURPLE, + LV_COLOR_ORANGE}; }; } } -- cgit v1.2.3-70-g09d2 From be22a9b1b8a3ca43cbf9e79d0a4f722d88d87ded Mon Sep 17 00:00:00 2001 From: Kieran Cawthray Date: Fri, 25 Jun 2021 15:09:18 +0200 Subject: Fix off-by-one error, reduce step gauge needle width --- src/displayapp/screens/PineTimeStyle.cpp | 2 +- src/displayapp/screens/settings/SettingPineTimeStyle.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/displayapp/screens/settings/SettingPineTimeStyle.cpp') diff --git a/src/displayapp/screens/PineTimeStyle.cpp b/src/displayapp/screens/PineTimeStyle.cpp index c75931c4..cbabca6f 100644 --- a/src/displayapp/screens/PineTimeStyle.cpp +++ b/src/displayapp/screens/PineTimeStyle.cpp @@ -191,7 +191,7 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app, lv_obj_set_style_local_line_width(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, 4); lv_obj_set_style_local_line_color(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK); lv_obj_set_style_local_line_opa(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, LV_OPA_COVER); - lv_obj_set_style_local_line_width(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, 4); + lv_obj_set_style_local_line_width(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, 3); lv_obj_set_style_local_pad_inner(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, 4); backgroundLabel = lv_label_create(lv_scr_act(), nullptr); diff --git a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp index bad0fec2..876d2b40 100644 --- a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp +++ b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp @@ -138,7 +138,7 @@ SettingPineTimeStyle::SettingPineTimeStyle( lv_obj_set_style_local_line_width(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, 4); lv_obj_set_style_local_line_color(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK); lv_obj_set_style_local_line_opa(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, LV_OPA_COVER); - lv_obj_set_style_local_line_width(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, 4); + lv_obj_set_style_local_line_width(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, 3); lv_obj_set_style_local_pad_inner(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, 4); backgroundLabel = lv_label_create(lv_scr_act(), nullptr); @@ -206,7 +206,7 @@ void SettingPineTimeStyle::UpdateSelected(lv_obj_t *object, lv_event_t event) { uint8_t valueBG = settingsController.GetPTSColorBG(); if((object == btnNextTime) && (event == LV_EVENT_PRESSED)) { - if ( valueTime < 17 ) { + if ( valueTime < 16 ) { valueTime += 1; settingsController.SetPTSColorTime(valueTime); lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); @@ -224,7 +224,7 @@ void SettingPineTimeStyle::UpdateSelected(lv_obj_t *object, lv_event_t event) { } } if((object == btnNextBar) && (event == LV_EVENT_PRESSED)) { - if ( valueBar < 17 ) { + if ( valueBar < 16 ) { valueBar += 1; settingsController.SetPTSColorBar(valueBar); lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBar]); @@ -238,7 +238,7 @@ void SettingPineTimeStyle::UpdateSelected(lv_obj_t *object, lv_event_t event) { } } if((object == btnNextBG) && (event == LV_EVENT_PRESSED)) { - if ( valueBG < 17 ) { + if ( valueBG < 16 ) { valueBG += 1; settingsController.SetPTSColorBG(valueBG); lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBG]); -- cgit v1.2.3-70-g09d2 From f3b40cb7a62c4927fb9fe921fdaa3b38809163f5 Mon Sep 17 00:00:00 2001 From: Kieran Cawthray Date: Fri, 25 Jun 2021 19:04:29 +0200 Subject: Make it loop around when you get to the end of the list of colors --- .../screens/settings/SettingPineTimeStyle.cpp | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/displayapp/screens/settings/SettingPineTimeStyle.cpp') diff --git a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp index 876d2b40..5e1396ad 100644 --- a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp +++ b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp @@ -212,6 +212,12 @@ void SettingPineTimeStyle::UpdateSelected(lv_obj_t *object, lv_event_t event) { lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); + } else { + valueTime = 0; + settingsController.SetPTSColorTime(valueTime); + lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); + lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); + lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); } } if((object == btnPrevTime) && (event == LV_EVENT_PRESSED)) { @@ -221,6 +227,12 @@ void SettingPineTimeStyle::UpdateSelected(lv_obj_t *object, lv_event_t event) { lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); + } else { + valueTime = 16; + settingsController.SetPTSColorTime(valueTime); + lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); + lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); + lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); } } if((object == btnNextBar) && (event == LV_EVENT_PRESSED)) { @@ -228,6 +240,10 @@ void SettingPineTimeStyle::UpdateSelected(lv_obj_t *object, lv_event_t event) { valueBar += 1; settingsController.SetPTSColorBar(valueBar); lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBar]); + } else { + valueBar = 0; + settingsController.SetPTSColorBar(valueBar); + lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBar]); } } if((object == btnPrevBar) && (event == LV_EVENT_PRESSED)) { @@ -235,6 +251,10 @@ void SettingPineTimeStyle::UpdateSelected(lv_obj_t *object, lv_event_t event) { valueBar -= 1; settingsController.SetPTSColorBar(valueBar); lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBar]); + } else { + valueBar = 16; + settingsController.SetPTSColorBar(valueBar); + lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBar]); } } if((object == btnNextBG) && (event == LV_EVENT_PRESSED)) { @@ -242,6 +262,10 @@ void SettingPineTimeStyle::UpdateSelected(lv_obj_t *object, lv_event_t event) { valueBG += 1; settingsController.SetPTSColorBG(valueBG); lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBG]); + } else { + valueBG = 0; + settingsController.SetPTSColorBG(valueBG); + lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBG]); } } if((object == btnPrevBG) && (event == LV_EVENT_PRESSED)) { @@ -249,6 +273,10 @@ void SettingPineTimeStyle::UpdateSelected(lv_obj_t *object, lv_event_t event) { valueBG -= 1; settingsController.SetPTSColorBG(valueBG); lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBG]); + } else { + valueBG = 16; + settingsController.SetPTSColorBG(valueBG); + lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBG]); } } } \ No newline at end of file -- cgit v1.2.3-70-g09d2 From 660a8597f6edc66deec94782817613e1a4f84a6d Mon Sep 17 00:00:00 2001 From: Kieran Cawthray Date: Sun, 27 Jun 2021 15:24:17 +0200 Subject: Add reset button, reduce button opacity --- .../screens/settings/SettingPineTimeStyle.cpp | 48 ++++++++++++++++------ .../screens/settings/SettingPineTimeStyle.h | 1 + 2 files changed, 37 insertions(+), 12 deletions(-) (limited to 'src/displayapp/screens/settings/SettingPineTimeStyle.cpp') diff --git a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp index 5e1396ad..ae665464 100644 --- a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp +++ b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp @@ -150,45 +150,59 @@ SettingPineTimeStyle::SettingPineTimeStyle( btnNextTime = lv_btn_create(lv_scr_act(), nullptr); btnNextTime->user_data = this; - lv_obj_set_size(btnNextTime, 50, 50); - lv_obj_align(btnNextTime, lv_scr_act(), LV_ALIGN_CENTER, 55, -80); + lv_obj_set_size(btnNextTime, 60, 60); + lv_obj_align(btnNextTime, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, -15, -80); + lv_obj_set_style_local_bg_opa(btnNextTime, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_30); lv_obj_set_style_local_value_str(btnNextTime, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, ">"); lv_obj_set_event_cb(btnNextTime, event_handler); btnPrevTime = lv_btn_create(lv_scr_act(), nullptr); btnPrevTime->user_data = this; - lv_obj_set_size(btnPrevTime, 50, 50); - lv_obj_align(btnPrevTime, lv_scr_act(), LV_ALIGN_CENTER, -55, -80); + lv_obj_set_size(btnPrevTime, 60, 60); + lv_obj_align(btnPrevTime, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 15, -80); + lv_obj_set_style_local_bg_opa(btnPrevTime, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_30); lv_obj_set_style_local_value_str(btnPrevTime, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "<"); lv_obj_set_event_cb(btnPrevTime, event_handler); btnNextBar = lv_btn_create(lv_scr_act(), nullptr); btnNextBar->user_data = this; - lv_obj_set_size(btnNextBar, 50, 50); - lv_obj_align(btnNextBar, lv_scr_act(), LV_ALIGN_CENTER, 55, 0); + lv_obj_set_size(btnNextBar, 60, 60); + lv_obj_align(btnNextBar, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, -15, 0); + lv_obj_set_style_local_bg_opa(btnNextBar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_30); lv_obj_set_style_local_value_str(btnNextBar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, ">"); lv_obj_set_event_cb(btnNextBar, event_handler); btnPrevBar = lv_btn_create(lv_scr_act(), nullptr); btnPrevBar->user_data = this; - lv_obj_set_size(btnPrevBar, 50, 50); - lv_obj_align(btnPrevBar, lv_scr_act(), LV_ALIGN_CENTER, -55, 0); + lv_obj_set_size(btnPrevBar, 60, 60); + lv_obj_align(btnPrevBar, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 15, 0); + lv_obj_set_style_local_bg_opa(btnPrevBar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_30); lv_obj_set_style_local_value_str(btnPrevBar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "<"); lv_obj_set_event_cb(btnPrevBar, event_handler); btnNextBG = lv_btn_create(lv_scr_act(), nullptr); btnNextBG->user_data = this; - lv_obj_set_size(btnNextBG, 50, 50); - lv_obj_align(btnNextBG, lv_scr_act(), LV_ALIGN_CENTER, 55, 80); + lv_obj_set_size(btnNextBG, 60, 60); + lv_obj_align(btnNextBG, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, -15, 80); + lv_obj_set_style_local_bg_opa(btnNextBG, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_30); lv_obj_set_style_local_value_str(btnNextBG, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, ">"); lv_obj_set_event_cb(btnNextBG, event_handler); btnPrevBG = lv_btn_create(lv_scr_act(), nullptr); btnPrevBG->user_data = this; - lv_obj_set_size(btnPrevBG, 50, 50); - lv_obj_align(btnPrevBG, lv_scr_act(), LV_ALIGN_CENTER, -55, 80); + lv_obj_set_size(btnPrevBG, 60, 60); + lv_obj_align(btnPrevBG, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 15, 80); + lv_obj_set_style_local_bg_opa(btnPrevBG, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_30); lv_obj_set_style_local_value_str(btnPrevBG, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "<"); lv_obj_set_event_cb(btnPrevBG, event_handler); + + btnReset = lv_btn_create(lv_scr_act(), nullptr); + btnReset->user_data = this; + lv_obj_set_size(btnReset, 60, 60); + lv_obj_align(btnReset, lv_scr_act(), LV_ALIGN_CENTER, 0, 80); + lv_obj_set_style_local_bg_opa(btnReset, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_30); + lv_obj_set_style_local_value_str(btnReset, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "Rst"); + lv_obj_set_event_cb(btnReset, event_handler); } SettingPineTimeStyle::~SettingPineTimeStyle() { @@ -279,4 +293,14 @@ void SettingPineTimeStyle::UpdateSelected(lv_obj_t *object, lv_event_t event) { lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBG]); } } + if((object == btnReset) && (event == LV_EVENT_PRESSED)) { + settingsController.SetPTSColorTime(11); + lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[11]); + lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[11]); + lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[11]); + settingsController.SetPTSColorBar(11); + lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[11]); + settingsController.SetPTSColorBG(3); + lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[3]); + } } \ No newline at end of file diff --git a/src/displayapp/screens/settings/SettingPineTimeStyle.h b/src/displayapp/screens/settings/SettingPineTimeStyle.h index 9b20f9fb..fe449b2e 100644 --- a/src/displayapp/screens/settings/SettingPineTimeStyle.h +++ b/src/displayapp/screens/settings/SettingPineTimeStyle.h @@ -27,6 +27,7 @@ namespace Pinetime { lv_obj_t * btnPrevBar; lv_obj_t * btnNextBG; lv_obj_t * btnPrevBG; + lv_obj_t * btnReset; lv_obj_t * timeColor; lv_obj_t * barColor; lv_obj_t * bgColor; -- cgit v1.2.3-70-g09d2 From 477ff32edc3bc0997f45d943f90f68f8f0608468 Mon Sep 17 00:00:00 2001 From: Kieran Cawthray Date: Sun, 15 Aug 2021 10:41:00 +0200 Subject: Add randomise button to color picker --- .../screens/settings/SettingPineTimeStyle.cpp | 21 +++++++++++++++++++++ .../screens/settings/SettingPineTimeStyle.h | 1 + 2 files changed, 22 insertions(+) (limited to 'src/displayapp/screens/settings/SettingPineTimeStyle.cpp') diff --git a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp index ae665464..a32ce34d 100644 --- a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp +++ b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp @@ -203,6 +203,14 @@ SettingPineTimeStyle::SettingPineTimeStyle( lv_obj_set_style_local_bg_opa(btnReset, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_30); lv_obj_set_style_local_value_str(btnReset, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "Rst"); lv_obj_set_event_cb(btnReset, event_handler); + + btnRandom = lv_btn_create(lv_scr_act(), nullptr); + btnRandom->user_data = this; + lv_obj_set_size(btnRandom, 60, 60); + lv_obj_align(btnRandom, lv_scr_act(), LV_ALIGN_CENTER, 0, 0); + lv_obj_set_style_local_bg_opa(btnRandom, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_30); + lv_obj_set_style_local_value_str(btnRandom, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "Rnd"); + lv_obj_set_event_cb(btnRandom, event_handler); } SettingPineTimeStyle::~SettingPineTimeStyle() { @@ -303,4 +311,17 @@ void SettingPineTimeStyle::UpdateSelected(lv_obj_t *object, lv_event_t event) { settingsController.SetPTSColorBG(3); lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[3]); } + if((object == btnRandom) && (event == LV_EVENT_PRESSED)) { + uint8_t randTime = rand() % 17; + uint8_t randBar = rand() % 17; + uint8_t randBG = rand() % 17; + settingsController.SetPTSColorTime(randTime); + lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[randTime]); + lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[randTime]); + lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[randTime]); + settingsController.SetPTSColorBar(randBar); + lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[randBar]); + settingsController.SetPTSColorBG(randBG); + lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[randBG]); + } } \ No newline at end of file diff --git a/src/displayapp/screens/settings/SettingPineTimeStyle.h b/src/displayapp/screens/settings/SettingPineTimeStyle.h index fe449b2e..1a01ebbb 100644 --- a/src/displayapp/screens/settings/SettingPineTimeStyle.h +++ b/src/displayapp/screens/settings/SettingPineTimeStyle.h @@ -28,6 +28,7 @@ namespace Pinetime { lv_obj_t * btnNextBG; lv_obj_t * btnPrevBG; lv_obj_t * btnReset; + lv_obj_t * btnRandom; lv_obj_t * timeColor; lv_obj_t * barColor; lv_obj_t * bgColor; -- cgit v1.2.3-70-g09d2 From c0bb88799c2de0ab8de5d38b3eb511f4f80029d7 Mon Sep 17 00:00:00 2001 From: Kieran Cawthray Date: Sun, 15 Aug 2021 12:33:32 +0200 Subject: Add check for randomise button in case colors clash --- src/displayapp/screens/settings/SettingPineTimeStyle.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/displayapp/screens/settings/SettingPineTimeStyle.cpp') diff --git a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp index a32ce34d..007c1cff 100644 --- a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp +++ b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp @@ -315,6 +315,11 @@ void SettingPineTimeStyle::UpdateSelected(lv_obj_t *object, lv_event_t event) { uint8_t randTime = rand() % 17; uint8_t randBar = rand() % 17; uint8_t randBG = rand() % 17; + // Check if the time color is the same as its background, or if the sidebar is black. If so, change them to more useful values. + if ((randTime == randBG) || (randBar == 3)) { + randBG += 1; + randBar = randTime; + } settingsController.SetPTSColorTime(randTime); lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[randTime]); lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[randTime]); -- cgit v1.2.3-70-g09d2 From 16ea069d55e4bcbba097cf499901eddf1a3828db Mon Sep 17 00:00:00 2001 From: Kieran Cawthray Date: Sun, 15 Aug 2021 14:05:21 +0200 Subject: Remove duplicate code, minor fixes --- .../screens/settings/SettingPineTimeStyle.cpp | 52 ++++++++-------------- 1 file changed, 19 insertions(+), 33 deletions(-) (limited to 'src/displayapp/screens/settings/SettingPineTimeStyle.cpp') diff --git a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp index 007c1cff..dfa806a3 100644 --- a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp +++ b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp @@ -230,76 +230,60 @@ void SettingPineTimeStyle::UpdateSelected(lv_obj_t *object, lv_event_t event) { if((object == btnNextTime) && (event == LV_EVENT_PRESSED)) { if ( valueTime < 16 ) { valueTime += 1; - settingsController.SetPTSColorTime(valueTime); - lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); - lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); - lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); } else { valueTime = 0; - settingsController.SetPTSColorTime(valueTime); - lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); - lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); - lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); } + settingsController.SetPTSColorTime(valueTime); + lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); + lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); + lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); } if((object == btnPrevTime) && (event == LV_EVENT_PRESSED)) { if ( valueTime > 0 ) { valueTime -= 1; - settingsController.SetPTSColorTime(valueTime); - lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); - lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); - lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); } else { valueTime = 16; - settingsController.SetPTSColorTime(valueTime); - lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); - lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); - lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); } + settingsController.SetPTSColorTime(valueTime); + lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); + lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); + lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); } if((object == btnNextBar) && (event == LV_EVENT_PRESSED)) { if ( valueBar < 16 ) { valueBar += 1; - settingsController.SetPTSColorBar(valueBar); - lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBar]); } else { valueBar = 0; - settingsController.SetPTSColorBar(valueBar); - lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBar]); } + settingsController.SetPTSColorBar(valueBar); + lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBar]); } if((object == btnPrevBar) && (event == LV_EVENT_PRESSED)) { if ( valueBar > 0 ) { valueBar -= 1; - settingsController.SetPTSColorBar(valueBar); - lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBar]); } else { valueBar = 16; - settingsController.SetPTSColorBar(valueBar); - lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBar]); } + settingsController.SetPTSColorBar(valueBar); + lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBar]); } if((object == btnNextBG) && (event == LV_EVENT_PRESSED)) { if ( valueBG < 16 ) { valueBG += 1; - settingsController.SetPTSColorBG(valueBG); - lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBG]); } else { valueBG = 0; - settingsController.SetPTSColorBG(valueBG); - lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBG]); } + settingsController.SetPTSColorBG(valueBG); + lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBG]); } if((object == btnPrevBG) && (event == LV_EVENT_PRESSED)) { if ( valueBG > 0 ) { valueBG -= 1; - settingsController.SetPTSColorBG(valueBG); - lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBG]); } else { valueBG = 16; - settingsController.SetPTSColorBG(valueBG); - lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBG]); } + settingsController.SetPTSColorBG(valueBG); + lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBG]); } if((object == btnReset) && (event == LV_EVENT_PRESSED)) { settingsController.SetPTSColorTime(11); @@ -316,8 +300,10 @@ void SettingPineTimeStyle::UpdateSelected(lv_obj_t *object, lv_event_t event) { uint8_t randBar = rand() % 17; uint8_t randBG = rand() % 17; // Check if the time color is the same as its background, or if the sidebar is black. If so, change them to more useful values. - if ((randTime == randBG) || (randBar == 3)) { + if (randTime == randBG) { randBG += 1; + } + if (randBar == 3) { randBar = randTime; } settingsController.SetPTSColorTime(randTime); -- cgit v1.2.3-70-g09d2 From 5789f1527c5c8d1c31e78a6a88c6a2b6158eb671 Mon Sep 17 00:00:00 2001 From: Kieran Cawthray Date: Sun, 15 Aug 2021 14:42:30 +0200 Subject: Avoid setting the sidebar black --- src/displayapp/screens/settings/SettingPineTimeStyle.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/displayapp/screens/settings/SettingPineTimeStyle.cpp') diff --git a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp index dfa806a3..96b87800 100644 --- a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp +++ b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp @@ -252,6 +252,8 @@ void SettingPineTimeStyle::UpdateSelected(lv_obj_t *object, lv_event_t event) { if((object == btnNextBar) && (event == LV_EVENT_PRESSED)) { if ( valueBar < 16 ) { valueBar += 1; + // Avoid setting the sidebar black + if ( valueBar == 3 ) { valueBar += 1; } } else { valueBar = 0; } @@ -261,6 +263,8 @@ void SettingPineTimeStyle::UpdateSelected(lv_obj_t *object, lv_event_t event) { if((object == btnPrevBar) && (event == LV_EVENT_PRESSED)) { if ( valueBar > 0 ) { valueBar -= 1; + // Avoid setting the sidebar black + if ( valueBar == 3 ) { valueBar -= 1; } } else { valueBar = 16; } -- cgit v1.2.3-70-g09d2 From 639fd3a9bd9f4a1ada36a4b812b7199543d47457 Mon Sep 17 00:00:00 2001 From: Kieran Cawthray Date: Sun, 15 Aug 2021 15:00:54 +0200 Subject: More tidying following review --- .../screens/settings/SettingPineTimeStyle.cpp | 173 +++++++++++---------- 1 file changed, 88 insertions(+), 85 deletions(-) (limited to 'src/displayapp/screens/settings/SettingPineTimeStyle.cpp') diff --git a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp index 96b87800..979e4b66 100644 --- a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp +++ b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp @@ -6,17 +6,14 @@ using namespace Pinetime::Applications::Screens; namespace { - static void event_handler(lv_obj_t * obj, lv_event_t event) { - SettingPineTimeStyle* screen = static_cast(obj->user_data); + static void event_handler(lv_obj_t* obj, lv_event_t event) { + SettingPineTimeStyle* screen = static_cast(obj->user_data); screen->UpdateSelected(obj, event); } } -SettingPineTimeStyle::SettingPineTimeStyle( - Pinetime::Applications::DisplayApp *app, Pinetime::Controllers::Settings &settingsController) : - Screen(app), - settingsController{settingsController} -{ +SettingPineTimeStyle::SettingPineTimeStyle(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Settings& settingsController) + : Screen(app), settingsController {settingsController} { timebar = lv_obj_create(lv_scr_act(), nullptr); lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[settingsController.GetPTSColorBG()]); lv_obj_set_style_local_radius(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0); @@ -140,7 +137,7 @@ SettingPineTimeStyle::SettingPineTimeStyle( lv_obj_set_style_local_line_opa(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, LV_OPA_COVER); lv_obj_set_style_local_line_width(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, 3); lv_obj_set_style_local_pad_inner(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, 4); - + backgroundLabel = lv_label_create(lv_scr_act(), nullptr); lv_obj_set_click(backgroundLabel, true); lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CROP); @@ -222,74 +219,79 @@ bool SettingPineTimeStyle::Refresh() { return running; } -void SettingPineTimeStyle::UpdateSelected(lv_obj_t *object, lv_event_t event) { +void SettingPineTimeStyle::UpdateSelected(lv_obj_t* object, lv_event_t event) { uint8_t valueTime = settingsController.GetPTSColorTime(); uint8_t valueBar = settingsController.GetPTSColorBar(); uint8_t valueBG = settingsController.GetPTSColorBG(); - - if((object == btnNextTime) && (event == LV_EVENT_PRESSED)) { - if ( valueTime < 16 ) { - valueTime += 1; - } else { - valueTime = 0; + + if (event == LV_EVENT_CLICKED) { + if (object == btnNextTime) { + if (valueTime < 16) { + valueTime += 1; + } else { + valueTime = 0; + } + settingsController.SetPTSColorTime(valueTime); + lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); + lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); + lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); } - settingsController.SetPTSColorTime(valueTime); - lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); - lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); - lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); - } - if((object == btnPrevTime) && (event == LV_EVENT_PRESSED)) { - if ( valueTime > 0 ) { - valueTime -= 1; - } else { - valueTime = 16; + if (object == btnPrevTime) { + if (valueTime > 0) { + valueTime -= 1; + } else { + valueTime = 16; + } + settingsController.SetPTSColorTime(valueTime); + lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); + lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); + lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); } - settingsController.SetPTSColorTime(valueTime); - lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); - lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); - lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); - } - if((object == btnNextBar) && (event == LV_EVENT_PRESSED)) { - if ( valueBar < 16 ) { - valueBar += 1; - // Avoid setting the sidebar black - if ( valueBar == 3 ) { valueBar += 1; } - } else { - valueBar = 0; + if (object == btnNextBar) { + if (valueBar < 16) { + valueBar += 1; + // Avoid setting the sidebar black + if (valueBar == 3) { + valueBar += 1; + } + } else { + valueBar = 0; + } + settingsController.SetPTSColorBar(valueBar); + lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBar]); } - settingsController.SetPTSColorBar(valueBar); - lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBar]); - } - if((object == btnPrevBar) && (event == LV_EVENT_PRESSED)) { - if ( valueBar > 0 ) { - valueBar -= 1; - // Avoid setting the sidebar black - if ( valueBar == 3 ) { valueBar -= 1; } - } else { - valueBar = 16; + if (object == btnPrevBar) { + if (valueBar > 0) { + valueBar -= 1; + // Avoid setting the sidebar black + if (valueBar == 3) { + valueBar -= 1; + } + } else { + valueBar = 16; + } + settingsController.SetPTSColorBar(valueBar); + lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBar]); } - settingsController.SetPTSColorBar(valueBar); - lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBar]); - } - if((object == btnNextBG) && (event == LV_EVENT_PRESSED)) { - if ( valueBG < 16 ) { - valueBG += 1; - } else { - valueBG = 0; + if (object == btnNextBG) { + if (valueBG < 16) { + valueBG += 1; + } else { + valueBG = 0; + } + settingsController.SetPTSColorBG(valueBG); + lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBG]); } - settingsController.SetPTSColorBG(valueBG); - lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBG]); - } - if((object == btnPrevBG) && (event == LV_EVENT_PRESSED)) { - if ( valueBG > 0 ) { - valueBG -= 1; - } else { - valueBG = 16; + if (object == btnPrevBG) { + if (valueBG > 0) { + valueBG -= 1; + } else { + valueBG = 16; + } + settingsController.SetPTSColorBG(valueBG); + lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBG]); } - settingsController.SetPTSColorBG(valueBG); - lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBG]); - } - if((object == btnReset) && (event == LV_EVENT_PRESSED)) { + if (object == btnReset) { settingsController.SetPTSColorTime(11); lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[11]); lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[11]); @@ -298,25 +300,26 @@ void SettingPineTimeStyle::UpdateSelected(lv_obj_t *object, lv_event_t event) { lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[11]); settingsController.SetPTSColorBG(3); lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[3]); - } - if((object == btnRandom) && (event == LV_EVENT_PRESSED)) { - uint8_t randTime = rand() % 17; - uint8_t randBar = rand() % 17; - uint8_t randBG = rand() % 17; - // Check if the time color is the same as its background, or if the sidebar is black. If so, change them to more useful values. - if (randTime == randBG) { - randBG += 1; } - if (randBar == 3) { - randBar = randTime; + if (object == btnRandom) { + uint8_t randTime = rand() % 17; + uint8_t randBar = rand() % 17; + uint8_t randBG = rand() % 17; + // Check if the time color is the same as its background, or if the sidebar is black. If so, change them to more useful values. + if (randTime == randBG) { + randBG += 1; + } + if (randBar == 3) { + randBar = randTime; + } + settingsController.SetPTSColorTime(randTime); + lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[randTime]); + lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[randTime]); + lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[randTime]); + settingsController.SetPTSColorBar(randBar); + lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[randBar]); + settingsController.SetPTSColorBG(randBG); + lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[randBG]); } - settingsController.SetPTSColorTime(randTime); - lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[randTime]); - lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[randTime]); - lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[randTime]); - settingsController.SetPTSColorBar(randBar); - lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[randBar]); - settingsController.SetPTSColorBG(randBG); - lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[randBG]); } } \ No newline at end of file -- cgit v1.2.3-70-g09d2 From 9851ed33d84aa242dfb98c2c3714a20ddbc53f45 Mon Sep 17 00:00:00 2001 From: Kieran Cawthray Date: Sun, 15 Aug 2021 15:28:40 +0200 Subject: Fix potential edge case of sidebar being set black --- src/displayapp/screens/settings/SettingPineTimeStyle.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/displayapp/screens/settings/SettingPineTimeStyle.cpp') diff --git a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp index 979e4b66..e125c8a2 100644 --- a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp +++ b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp @@ -310,7 +310,7 @@ void SettingPineTimeStyle::UpdateSelected(lv_obj_t* object, lv_event_t event) { randBG += 1; } if (randBar == 3) { - randBar = randTime; + randBar -= 1; } settingsController.SetPTSColorTime(randTime); lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[randTime]); -- cgit v1.2.3-70-g09d2 From 31bc47d1cb397f5de0275d0d95aac7ca29cc7392 Mon Sep 17 00:00:00 2001 From: Jean-François Milants Date: Sat, 28 Aug 2021 21:02:11 +0200 Subject: Settings : use enums instead of ints to store colors. Group all PTS settings into a struct. PTS/SettingsPTS : Convert to/from LVGL color and Settings::Color, add functions to reduce code duplication. Adapt SettingPineTimeStyle with the last Screen Interface --- src/CMakeLists.txt | 2 + src/components/settings/Settings.h | 46 ++++--- src/displayapp/Colors.cpp | 27 ++++ src/displayapp/Colors.h | 10 ++ src/displayapp/screens/PineTimeStyle.cpp | 11 +- src/displayapp/screens/PineTimeStyle.h | 5 - .../screens/settings/SettingPineTimeStyle.cpp | 147 ++++++++++----------- .../screens/settings/SettingPineTimeStyle.h | 12 +- 8 files changed, 144 insertions(+), 116 deletions(-) create mode 100644 src/displayapp/Colors.cpp create mode 100644 src/displayapp/Colors.h (limited to 'src/displayapp/screens/settings/SettingPineTimeStyle.cpp') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 69c19367..a7242903 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -418,6 +418,7 @@ list(APPEND SOURCE_FILES displayapp/screens/BatteryInfo.cpp displayapp/screens/Steps.cpp displayapp/screens/Timer.cpp + displayapp/Colors.cpp ## Settings displayapp/screens/settings/QuickSettings.cpp @@ -611,6 +612,7 @@ set(INCLUDE_FILES displayapp/screens/Metronome.h displayapp/screens/Motion.h displayapp/screens/Timer.h + displayapp/Colors.h drivers/St7789.h drivers/SpiNorFlash.h drivers/SpiMaster.h diff --git a/src/components/settings/Settings.h b/src/components/settings/Settings.h index 40cafe9a..a294ab78 100644 --- a/src/components/settings/Settings.h +++ b/src/components/settings/Settings.h @@ -17,6 +17,14 @@ namespace Pinetime { DoubleTap = 1, RaiseWrist = 2, }; + enum class Colors : uint8_t { + White, Silver, Gray, Black, Red, Maroon, Yellow, Olive, Lime, Green, Cyan, Teal, Blue, Navy, Magenta, Purple, Orange + }; + struct PineTimeStyle { + Colors ColorTime = Colors::Teal; + Colors ColorBar = Colors::Teal; + Colors ColorBG = Colors::Black; + }; Settings(Pinetime::Controllers::FS& fs); @@ -33,37 +41,38 @@ namespace Pinetime { return settings.clockFace; }; - void SetPTSColorTime(uint8_t colorTime) { - if (colorTime != settings.PTSColorTime) + void SetPTSColorTime(Colors colorTime) { + if (colorTime != settings.PTS.ColorTime) settingsChanged = true; - settings.PTSColorTime = colorTime; + settings.PTS.ColorTime = colorTime; }; - uint8_t GetPTSColorTime() const { - return settings.PTSColorTime; + Colors GetPTSColorTime() const { + return settings.PTS.ColorTime; }; - void SetPTSColorBar(uint8_t colorBar) { - if (colorBar != settings.PTSColorBar) + void SetPTSColorBar(Colors colorBar) { + if (colorBar != settings.PTS.ColorBar) settingsChanged = true; - settings.PTSColorBar = colorBar; + settings.PTS.ColorBar = colorBar; }; - uint8_t GetPTSColorBar() const { - return settings.PTSColorBar; + Colors GetPTSColorBar() const { + return settings.PTS.ColorBar; }; - void SetPTSColorBG(uint8_t colorBG) { - if (colorBG != settings.PTSColorBG) + void SetPTSColorBG(Colors colorBG) { + if (colorBG != settings.PTS.ColorBG) settingsChanged = true; - settings.PTSColorBG = colorBG; + settings.PTS.ColorBG = colorBG; }; - uint8_t GetPTSColorBG() const { - return settings.PTSColorBG; + Colors GetPTSColorBG() const { + return settings.PTS.ColorBG; }; void SetAppMenu(uint8_t menu) { appMenu = menu; }; - uint8_t GetAppMenu() { + + uint8_t GetAppMenu() const { return appMenu; }; @@ -156,7 +165,6 @@ namespace Pinetime { static constexpr uint32_t settingsVersion = 0x0002; struct SettingsData { - uint32_t version = settingsVersion; uint32_t stepsGoal = 10000; uint32_t screenTimeOut = 15000; @@ -166,9 +174,7 @@ namespace Pinetime { uint8_t clockFace = 0; - uint8_t PTSColorTime = 11; - uint8_t PTSColorBar = 11; - uint8_t PTSColorBG = 3; + PineTimeStyle PTS; std::bitset<3> wakeUpMode {0}; diff --git a/src/displayapp/Colors.cpp b/src/displayapp/Colors.cpp new file mode 100644 index 00000000..f45f0722 --- /dev/null +++ b/src/displayapp/Colors.cpp @@ -0,0 +1,27 @@ +#include "Colors.h" + +using namespace Pinetime::Applications; +using namespace Pinetime::Controllers; + +lv_color_t Pinetime::Applications::Convert(Pinetime::Controllers::Settings::Colors color) { + switch (color) { + case Pinetime::Controllers::Settings::Colors::White: return LV_COLOR_WHITE; + case Pinetime::Controllers::Settings::Colors::Silver: return LV_COLOR_SILVER; + case Pinetime::Controllers::Settings::Colors::Gray: return LV_COLOR_GRAY; + case Pinetime::Controllers::Settings::Colors::Black: return LV_COLOR_BLACK; + case Pinetime::Controllers::Settings::Colors::Red: return LV_COLOR_RED; + case Pinetime::Controllers::Settings::Colors::Maroon: return LV_COLOR_MAROON; + case Pinetime::Controllers::Settings::Colors::Yellow: return LV_COLOR_YELLOW; + case Pinetime::Controllers::Settings::Colors::Olive: return LV_COLOR_OLIVE; + case Pinetime::Controllers::Settings::Colors::Lime: return LV_COLOR_LIME; + case Pinetime::Controllers::Settings::Colors::Green: return LV_COLOR_GREEN; + case Pinetime::Controllers::Settings::Colors::Cyan: return LV_COLOR_CYAN; + case Pinetime::Controllers::Settings::Colors::Teal: return LV_COLOR_TEAL; + case Pinetime::Controllers::Settings::Colors::Blue: return LV_COLOR_BLUE; + case Pinetime::Controllers::Settings::Colors::Navy: return LV_COLOR_NAVY; + case Pinetime::Controllers::Settings::Colors::Magenta: return LV_COLOR_MAGENTA; + case Pinetime::Controllers::Settings::Colors::Purple: return LV_COLOR_PURPLE; + case Pinetime::Controllers::Settings::Colors::Orange: return LV_COLOR_ORANGE; + default: return LV_COLOR_WHITE; + } +} diff --git a/src/displayapp/Colors.h b/src/displayapp/Colors.h new file mode 100644 index 00000000..9db7dd20 --- /dev/null +++ b/src/displayapp/Colors.h @@ -0,0 +1,10 @@ +#pragma once + +#include +#include + +namespace Pinetime { + namespace Applications { + lv_color_t Convert(Controllers::Settings::Colors color); + } +} \ No newline at end of file diff --git a/src/displayapp/screens/PineTimeStyle.cpp b/src/displayapp/screens/PineTimeStyle.cpp index 772e4612..7a712f43 100644 --- a/src/displayapp/screens/PineTimeStyle.cpp +++ b/src/displayapp/screens/PineTimeStyle.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include "BatteryIcon.h" #include "BleIcon.h" #include "NotificationIcon.h" @@ -63,7 +64,7 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app, //Create a 200px wide background rectangle timebar = lv_obj_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[settingsController.GetPTSColorBG()]); + lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorBG())); lv_obj_set_style_local_radius(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0); lv_obj_set_size(timebar, 200, 240); lv_obj_align(timebar, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 5, 0); @@ -71,25 +72,25 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app, // Display the time timeDD1 = lv_label_create(lv_scr_act(), nullptr); lv_obj_set_style_local_text_font(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &open_sans_light); - lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[settingsController.GetPTSColorTime()]); + lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime())); lv_label_set_text(timeDD1, "12"); lv_obj_align(timeDD1, timebar, LV_ALIGN_IN_TOP_MID, 5, 5); timeDD2 = lv_label_create(lv_scr_act(), nullptr); lv_obj_set_style_local_text_font(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &open_sans_light); - lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[settingsController.GetPTSColorTime()]); + lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime())); lv_label_set_text(timeDD2, "34"); lv_obj_align(timeDD2, timebar, LV_ALIGN_IN_BOTTOM_MID, 5, -5); timeAMPM = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[settingsController.GetPTSColorTime()]); + lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime())); lv_obj_set_style_local_text_line_space(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, -3); lv_label_set_text(timeAMPM, ""); lv_obj_align(timeAMPM, timebar, LV_ALIGN_IN_BOTTOM_LEFT, 2, -20); // Create a 40px wide bar down the right side of the screen sidebar = lv_obj_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[settingsController.GetPTSColorBar()]); + lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorBar())); lv_obj_set_style_local_radius(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0); lv_obj_set_size(sidebar, 40, 240); lv_obj_align(sidebar, lv_scr_act(), LV_ALIGN_IN_TOP_RIGHT, 0, 0); diff --git a/src/displayapp/screens/PineTimeStyle.h b/src/displayapp/screens/PineTimeStyle.h index 16b6de19..cb74ead5 100644 --- a/src/displayapp/screens/PineTimeStyle.h +++ b/src/displayapp/screens/PineTimeStyle.h @@ -68,11 +68,6 @@ namespace Pinetime { lv_obj_t* notificationIcon; lv_obj_t* stepGauge; lv_color_t needle_colors[1]; - lv_color_t pts_colors[17] = {LV_COLOR_WHITE, LV_COLOR_SILVER, LV_COLOR_GRAY, LV_COLOR_BLACK, - LV_COLOR_RED, LV_COLOR_MAROON, LV_COLOR_YELLOW, LV_COLOR_OLIVE, - LV_COLOR_LIME, LV_COLOR_GREEN, LV_COLOR_CYAN, LV_COLOR_TEAL, - LV_COLOR_BLUE, LV_COLOR_NAVY, LV_COLOR_MAGENTA, LV_COLOR_PURPLE, - LV_COLOR_ORANGE}; Controllers::DateTime& dateTimeController; Controllers::Battery& batteryController; diff --git a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp index e125c8a2..c9af19b6 100644 --- a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp +++ b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp @@ -1,5 +1,6 @@ #include "SettingPineTimeStyle.h" #include +#include #include "displayapp/DisplayApp.h" #include "displayapp/screens/Symbols.h" @@ -15,7 +16,7 @@ namespace { SettingPineTimeStyle::SettingPineTimeStyle(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Settings& settingsController) : Screen(app), settingsController {settingsController} { timebar = lv_obj_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[settingsController.GetPTSColorBG()]); + lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorBG())); lv_obj_set_style_local_radius(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0); lv_obj_set_size(timebar, 200, 240); lv_obj_align(timebar, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 5, 0); @@ -24,18 +25,18 @@ SettingPineTimeStyle::SettingPineTimeStyle(Pinetime::Applications::DisplayApp* a timeDD1 = lv_label_create(lv_scr_act(), nullptr); lv_obj_set_style_local_text_font(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &open_sans_light); - lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[settingsController.GetPTSColorTime()]); + lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime())); lv_label_set_text(timeDD1, "12"); lv_obj_align(timeDD1, timebar, LV_ALIGN_IN_TOP_MID, 5, 5); timeDD2 = lv_label_create(lv_scr_act(), nullptr); lv_obj_set_style_local_text_font(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &open_sans_light); - lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[settingsController.GetPTSColorTime()]); + lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime())); lv_label_set_text(timeDD2, "34"); lv_obj_align(timeDD2, timebar, LV_ALIGN_IN_BOTTOM_MID, 5, -5); timeAMPM = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[settingsController.GetPTSColorTime()]); + lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime())); lv_obj_set_style_local_text_line_space(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, -3); lv_label_set_text(timeAMPM, "A\nM"); lv_obj_align(timeAMPM, timebar, LV_ALIGN_IN_BOTTOM_LEFT, 2, -20); @@ -43,7 +44,7 @@ SettingPineTimeStyle::SettingPineTimeStyle(Pinetime::Applications::DisplayApp* a // Create a 40px wide bar down the right side of the screen sidebar = lv_obj_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[settingsController.GetPTSColorBar()]); + lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorBar())); lv_obj_set_style_local_radius(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0); lv_obj_set_size(sidebar, 40, 240); lv_obj_align(sidebar, lv_scr_act(), LV_ALIGN_IN_TOP_RIGHT, 0, 0); @@ -215,91 +216,60 @@ SettingPineTimeStyle::~SettingPineTimeStyle() { settingsController.SaveSettings(); } -bool SettingPineTimeStyle::Refresh() { - return running; -} - void SettingPineTimeStyle::UpdateSelected(lv_obj_t* object, lv_event_t event) { - uint8_t valueTime = settingsController.GetPTSColorTime(); - uint8_t valueBar = settingsController.GetPTSColorBar(); - uint8_t valueBG = settingsController.GetPTSColorBG(); + auto valueTime = settingsController.GetPTSColorTime(); + auto valueBar = settingsController.GetPTSColorBar(); + auto valueBG = settingsController.GetPTSColorBG(); if (event == LV_EVENT_CLICKED) { if (object == btnNextTime) { - if (valueTime < 16) { - valueTime += 1; - } else { - valueTime = 0; - } + valueTime = GetNext(valueTime); + settingsController.SetPTSColorTime(valueTime); - lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); - lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); - lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); + lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime)); + lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime)); + lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime)); } if (object == btnPrevTime) { - if (valueTime > 0) { - valueTime -= 1; - } else { - valueTime = 16; - } + valueTime = GetPrevious(valueTime); settingsController.SetPTSColorTime(valueTime); - lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); - lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); - lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); + lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime)); + lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime)); + lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime)); } if (object == btnNextBar) { - if (valueBar < 16) { - valueBar += 1; - // Avoid setting the sidebar black - if (valueBar == 3) { - valueBar += 1; - } - } else { - valueBar = 0; - } + valueBar = GetNext(valueBar); + if(valueBar == Controllers::Settings::Colors::Black) + valueBar = GetNext(valueBar); settingsController.SetPTSColorBar(valueBar); - lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBar]); + lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBar)); } if (object == btnPrevBar) { - if (valueBar > 0) { - valueBar -= 1; - // Avoid setting the sidebar black - if (valueBar == 3) { - valueBar -= 1; - } - } else { - valueBar = 16; - } + valueBar = GetPrevious(valueBar); + if(valueBar == Controllers::Settings::Colors::Black) + valueBar = GetPrevious(valueBar); settingsController.SetPTSColorBar(valueBar); - lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBar]); + lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBar)); } if (object == btnNextBG) { - if (valueBG < 16) { - valueBG += 1; - } else { - valueBG = 0; - } + valueBG = GetNext(valueBG); settingsController.SetPTSColorBG(valueBG); - lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBG]); + lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBG)); } if (object == btnPrevBG) { - if (valueBG > 0) { - valueBG -= 1; - } else { - valueBG = 16; - } + valueBG = GetPrevious(valueBG); settingsController.SetPTSColorBG(valueBG); - lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBG]); + lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBG)); } if (object == btnReset) { - settingsController.SetPTSColorTime(11); - lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[11]); - lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[11]); - lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[11]); - settingsController.SetPTSColorBar(11); - lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[11]); - settingsController.SetPTSColorBG(3); - lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[3]); + settingsController.SetPTSColorTime(Controllers::Settings::Colors::Teal); + lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(Controllers::Settings::Colors::Teal)); + lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(Controllers::Settings::Colors::Teal)); + lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(Controllers::Settings::Colors::Teal)); + settingsController.SetPTSColorBar(Controllers::Settings::Colors::Teal); + lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(Controllers::Settings::Colors::Teal)); + settingsController.SetPTSColorBG(Controllers::Settings::Colors::Black); + lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(Controllers::Settings::Colors::Black)); } if (object == btnRandom) { uint8_t randTime = rand() % 17; @@ -312,14 +282,37 @@ void SettingPineTimeStyle::UpdateSelected(lv_obj_t* object, lv_event_t event) { if (randBar == 3) { randBar -= 1; } - settingsController.SetPTSColorTime(randTime); - lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[randTime]); - lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[randTime]); - lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[randTime]); - settingsController.SetPTSColorBar(randBar); - lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[randBar]); - settingsController.SetPTSColorBG(randBG); - lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[randBG]); + settingsController.SetPTSColorTime(static_cast(randTime)); + lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(static_cast(randTime))); + lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(static_cast(randTime))); + lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(static_cast(randTime))); + settingsController.SetPTSColorBar(static_cast(randBar)); + lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(static_cast(randBar))); + settingsController.SetPTSColorBG(static_cast(randBG)); + lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(static_cast(randBG))); } } -} \ No newline at end of file +} + +Pinetime::Controllers::Settings::Colors SettingPineTimeStyle::GetNext(Pinetime::Controllers::Settings::Colors color) { + auto colorAsInt = static_cast(color); + Pinetime::Controllers::Settings::Colors nextColor; + if (colorAsInt < 16) { + nextColor = static_cast(colorAsInt + 1); + } else { + nextColor = static_cast(0); + } + return nextColor; +} + +Pinetime::Controllers::Settings::Colors SettingPineTimeStyle::GetPrevious(Pinetime::Controllers::Settings::Colors color) { + auto colorAsInt = static_cast(color); + Pinetime::Controllers::Settings::Colors prevColor; + + if (colorAsInt > 0) { + prevColor = static_cast(colorAsInt - 1); + } else { + prevColor = static_cast(16); + } + return prevColor; +} diff --git a/src/displayapp/screens/settings/SettingPineTimeStyle.h b/src/displayapp/screens/settings/SettingPineTimeStyle.h index 1a01ebbb..397bd86d 100644 --- a/src/displayapp/screens/settings/SettingPineTimeStyle.h +++ b/src/displayapp/screens/settings/SettingPineTimeStyle.h @@ -15,12 +15,14 @@ namespace Pinetime { SettingPineTimeStyle(DisplayApp* app, Pinetime::Controllers::Settings &settingsController); ~SettingPineTimeStyle() override; - bool Refresh() override; void UpdateSelected(lv_obj_t *object, lv_event_t event); private: Controllers::Settings& settingsController; + Pinetime::Controllers::Settings::Colors GetNext(Controllers::Settings::Colors color); + Pinetime::Controllers::Settings::Colors GetPrevious(Controllers::Settings::Colors color); + lv_obj_t * btnNextTime; lv_obj_t * btnPrevTime; lv_obj_t * btnNextBar; @@ -29,9 +31,6 @@ namespace Pinetime { lv_obj_t * btnPrevBG; lv_obj_t * btnReset; lv_obj_t * btnRandom; - lv_obj_t * timeColor; - lv_obj_t * barColor; - lv_obj_t * bgColor; lv_obj_t * timebar; lv_obj_t * sidebar; lv_obj_t * timeDD1; @@ -51,11 +50,6 @@ namespace Pinetime { lv_obj_t * calendarCrossBar2; lv_obj_t * stepGauge; lv_color_t needle_colors[1]; - lv_color_t pts_colors[17] = {LV_COLOR_WHITE, LV_COLOR_SILVER, LV_COLOR_GRAY, LV_COLOR_BLACK, - LV_COLOR_RED, LV_COLOR_MAROON, LV_COLOR_YELLOW, LV_COLOR_OLIVE, - LV_COLOR_LIME, LV_COLOR_GREEN, LV_COLOR_CYAN, LV_COLOR_TEAL, - LV_COLOR_BLUE, LV_COLOR_NAVY, LV_COLOR_MAGENTA, LV_COLOR_PURPLE, - LV_COLOR_ORANGE}; }; } } -- cgit v1.2.3-70-g09d2