summaryrefslogtreecommitdiff
path: root/src/displayapp/screens/settings/SettingPineTimeStyle.cpp
diff options
context:
space:
mode:
authorKieran Cawthray <kieranc@gmail.com>2021-08-15 10:41:00 +0200
committerKieran Cawthray <kieranc@gmail.com>2021-08-15 10:41:00 +0200
commit477ff32edc3bc0997f45d943f90f68f8f0608468 (patch)
tree80ed627048a91db5c77d584f915ecd5d1f274e0a /src/displayapp/screens/settings/SettingPineTimeStyle.cpp
parent6bffc7d52840affc5c037d1bb783172b99d4731a (diff)
Add randomise button to color picker
Diffstat (limited to 'src/displayapp/screens/settings/SettingPineTimeStyle.cpp')
-rw-r--r--src/displayapp/screens/settings/SettingPineTimeStyle.cpp21
1 files changed, 21 insertions, 0 deletions
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