1
0
Fork 0

PineTimeStyle color picker add settings integration

This commit is contained in:
Kieran Cawthray 2021-06-24 21:49:04 +02:00
parent 38ab0add48
commit 7edfc53481
2 changed files with 86 additions and 47 deletions

View file

@ -27,6 +27,33 @@ namespace Pinetime {
return settings.clockFace; 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) { void SetAppMenu(uint8_t menu) {
appMenu = menu; appMenu = menu;
}; };
@ -103,6 +130,10 @@ namespace Pinetime {
uint8_t clockFace = 0; uint8_t clockFace = 0;
uint8_t PTSColorTime = 11;
uint8_t PTSColorBar = 11;
uint8_t PTSColorBG = 3;
uint32_t stepsGoal = 10000; uint32_t stepsGoal = 10000;
uint32_t screenTimeOut = 15000; uint32_t screenTimeOut = 15000;

View file

@ -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( SettingPineTimeStyle::SettingPineTimeStyle(
Pinetime::Applications::DisplayApp *app, Pinetime::Controllers::Settings &settingsController) : Pinetime::Applications::DisplayApp *app, Pinetime::Controllers::Settings &settingsController) :
Screen(app), Screen(app),
@ -19,7 +25,7 @@ SettingPineTimeStyle::SettingPineTimeStyle(
{ {
timebar = lv_obj_create(lv_scr_act(), nullptr); 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_style_local_radius(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
lv_obj_set_size(timebar, 200, 240); lv_obj_set_size(timebar, 200, 240);
lv_obj_align(timebar, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 5, 0); 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); 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_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_label_set_text(timeDD1, "12");
lv_obj_align(timeDD1, timebar, LV_ALIGN_IN_TOP_MID, 5, 5); lv_obj_align(timeDD1, timebar, LV_ALIGN_IN_TOP_MID, 5, 5);
timeDD2 = lv_label_create(lv_scr_act(), nullptr); 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_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_label_set_text(timeDD2, "34");
lv_obj_align(timeDD2, timebar, LV_ALIGN_IN_BOTTOM_MID, 5, -5); lv_obj_align(timeDD2, timebar, LV_ALIGN_IN_BOTTOM_MID, 5, -5);
timeAMPM = lv_label_create(lv_scr_act(), nullptr); 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_obj_set_style_local_text_line_space(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, -3);
lv_label_set_text(timeAMPM, "A\nM"); lv_label_set_text(timeAMPM, "A\nM");
lv_obj_align(timeAMPM, timebar, LV_ALIGN_IN_BOTTOM_LEFT, 2, -20); 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 */ /* Create a 40px wide bar down the right side of the screen */
sidebar = lv_obj_create(lv_scr_act(), nullptr); 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_style_local_radius(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
lv_obj_set_size(sidebar, 40, 240); lv_obj_set_size(sidebar, 40, 240);
lv_obj_align(sidebar, lv_scr_act(), LV_ALIGN_IN_TOP_RIGHT, 0, 0); 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_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_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); // lv_style_copy(&style_button, &lv_style_plain_color);
// style_button.body.opa = LV_OPA_50; // style_button.body.opa = LV_OPA_50;
btnNextTime = lv_btn_create(lv_scr_act(), nullptr); 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_style_local_value_str(btnPrevBG, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "<");
lv_obj_set_event_cb(btnPrevBG, event_handler); 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); 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) { void SettingPineTimeStyle::UpdateSelected(lv_obj_t *object, lv_event_t event) {
uint8_t value = 0; uint8_t valueTime = settingsController.GetPTSColorTime();
lv_color_t pts_colors[17] = {LV_COLOR_WHITE, LV_COLOR_SILVER, LV_COLOR_GRAY, LV_COLOR_BLACK, uint8_t valueBar = settingsController.GetPTSColorBar();
LV_COLOR_RED, LV_COLOR_MAROON, LV_COLOR_YELLOW, LV_COLOR_OLIVE, uint8_t valueBG = settingsController.GetPTSColorBG();
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((object == btnNextTime) && (event == LV_EVENT_PRESSED)) {
if ( value < 16 ) { if ( valueTime < 17 ) {
value += 1; valueTime += 1;
lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[value]); settingsController.SetPTSColorTime(valueTime);
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(timeDD1, 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[value]); 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((object == btnPrevTime) && (event == LV_EVENT_PRESSED)) {
if ( value > 0 ) { if ( valueTime > 0 ) {
value -= 1; valueTime -= 1;
lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[value]); settingsController.SetPTSColorTime(valueTime);
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(timeDD1, 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[value]); 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 < 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 == 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((object == btnNextBG) && (event == LV_EVENT_PRESSED)) {
if ( value < 16 ) { if ( valueBG < 17 ) {
value += 1; valueBG += 1;
lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[value]); 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((object == btnPrevBG) && (event == LV_EVENT_PRESSED)) {
if ( value > 0 ) { if ( valueBG > 0 ) {
value -= 1; valueBG -= 1;
lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[value]); settingsController.SetPTSColorBG(valueBG);
lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBG]);
} }
} }