summaryrefslogtreecommitdiff
path: root/src/displayapp/screens
diff options
context:
space:
mode:
authorKieran Cawthray <kieranc@gmail.com>2021-08-15 14:05:21 +0200
committerKieran Cawthray <kieranc@gmail.com>2021-08-15 14:05:21 +0200
commit16ea069d55e4bcbba097cf499901eddf1a3828db (patch)
tree7f34639b018e5b36c92050f00c1eaf64cc71ad9e /src/displayapp/screens
parentc0bb88799c2de0ab8de5d38b3eb511f4f80029d7 (diff)
Remove duplicate code, minor fixes
Diffstat (limited to 'src/displayapp/screens')
-rw-r--r--src/displayapp/screens/settings/SettingPineTimeStyle.cpp52
1 files changed, 19 insertions, 33 deletions
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);