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((object == btnNextTime) && (event == LV_EVENT_PRESSED)) {
|
||||||
if ( valueTime < 16 ) {
|
if ( valueTime < 16 ) {
|
||||||
valueTime += 1;
|
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 {
|
} else {
|
||||||
valueTime = 0;
|
valueTime = 0;
|
||||||
|
}
|
||||||
settingsController.SetPTSColorTime(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(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(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(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if((object == btnPrevTime) && (event == LV_EVENT_PRESSED)) {
|
if((object == btnPrevTime) && (event == LV_EVENT_PRESSED)) {
|
||||||
if ( valueTime > 0 ) {
|
if ( valueTime > 0 ) {
|
||||||
valueTime -= 1;
|
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 {
|
} else {
|
||||||
valueTime = 16;
|
valueTime = 16;
|
||||||
|
}
|
||||||
settingsController.SetPTSColorTime(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(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(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(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if((object == btnNextBar) && (event == LV_EVENT_PRESSED)) {
|
if((object == btnNextBar) && (event == LV_EVENT_PRESSED)) {
|
||||||
if ( valueBar < 16 ) {
|
if ( valueBar < 16 ) {
|
||||||
valueBar += 1;
|
valueBar += 1;
|
||||||
settingsController.SetPTSColorBar(valueBar);
|
|
||||||
lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBar]);
|
|
||||||
} else {
|
} else {
|
||||||
valueBar = 0;
|
valueBar = 0;
|
||||||
|
}
|
||||||
settingsController.SetPTSColorBar(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, pts_colors[valueBar]);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if((object == btnPrevBar) && (event == LV_EVENT_PRESSED)) {
|
if((object == btnPrevBar) && (event == LV_EVENT_PRESSED)) {
|
||||||
if ( valueBar > 0 ) {
|
if ( valueBar > 0 ) {
|
||||||
valueBar -= 1;
|
valueBar -= 1;
|
||||||
settingsController.SetPTSColorBar(valueBar);
|
|
||||||
lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBar]);
|
|
||||||
} else {
|
} else {
|
||||||
valueBar = 16;
|
valueBar = 16;
|
||||||
|
}
|
||||||
settingsController.SetPTSColorBar(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, pts_colors[valueBar]);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if((object == btnNextBG) && (event == LV_EVENT_PRESSED)) {
|
if((object == btnNextBG) && (event == LV_EVENT_PRESSED)) {
|
||||||
if ( valueBG < 16 ) {
|
if ( valueBG < 16 ) {
|
||||||
valueBG += 1;
|
valueBG += 1;
|
||||||
settingsController.SetPTSColorBG(valueBG);
|
|
||||||
lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBG]);
|
|
||||||
} else {
|
} else {
|
||||||
valueBG = 0;
|
valueBG = 0;
|
||||||
|
}
|
||||||
settingsController.SetPTSColorBG(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, pts_colors[valueBG]);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if((object == btnPrevBG) && (event == LV_EVENT_PRESSED)) {
|
if((object == btnPrevBG) && (event == LV_EVENT_PRESSED)) {
|
||||||
if ( valueBG > 0 ) {
|
if ( valueBG > 0 ) {
|
||||||
valueBG -= 1;
|
valueBG -= 1;
|
||||||
settingsController.SetPTSColorBG(valueBG);
|
|
||||||
lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBG]);
|
|
||||||
} else {
|
} else {
|
||||||
valueBG = 16;
|
valueBG = 16;
|
||||||
|
}
|
||||||
settingsController.SetPTSColorBG(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, pts_colors[valueBG]);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if((object == btnReset) && (event == LV_EVENT_PRESSED)) {
|
if((object == btnReset) && (event == LV_EVENT_PRESSED)) {
|
||||||
settingsController.SetPTSColorTime(11);
|
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(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 randBar = rand() % 17;
|
||||||
uint8_t randBG = 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.
|
// 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;
|
randBG += 1;
|
||||||
|
}
|
||||||
|
if (randBar == 3) {
|
||||||
randBar = randTime;
|
randBar = randTime;
|
||||||
}
|
}
|
||||||
settingsController.SetPTSColorTime(randTime);
|
settingsController.SetPTSColorTime(randTime);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user