Remove duplicate code, minor fixes
This commit is contained in:
parent
c0bb88799c
commit
16ea069d55
|
@ -230,77 +230,61 @@ 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]);
|
||||
}
|
||||
}
|
||||
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]);
|
||||
}
|
||||
}
|
||||
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]);
|
||||
}
|
||||
}
|
||||
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]);
|
||||
}
|
||||
}
|
||||
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]);
|
||||
}
|
||||
}
|
||||
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]);
|
||||
}
|
||||
}
|
||||
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]);
|
||||
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue
Block a user