Skip to content

Commit 98ac447

Browse files
committed
Fixed button color changing
1 parent b9c4010 commit 98ac447

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

src/displayapp/screens/settings/SettingShakeThreshold.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
using namespace Pinetime::Applications::Screens;
88

99
namespace {
10-
static void event_handler(lv_obj_t* obj, lv_event_t event) {
10+
void event_handler(lv_obj_t* obj, lv_event_t event) {
1111
SettingShakeThreshold* screen = static_cast<SettingShakeThreshold*>(obj->user_data);
1212
screen->UpdateSelected(obj, event);
1313
}
@@ -41,10 +41,11 @@ SettingShakeThreshold::SettingShakeThreshold(DisplayApp* app,
4141
lv_obj_set_height(animArc, lv_obj_get_height(positionArc));
4242
lv_obj_align_mid(animArc, positionArc, LV_ALIGN_CENTER, 0, 0);
4343
lv_obj_set_style_local_line_opa(animArc, LV_ARC_PART_BG, LV_STATE_DEFAULT, 0);
44-
lv_obj_set_style_local_line_opa(animArc, LV_ARC_PART_INDIC, LV_STATE_DEFAULT, LV_OPA_60);
44+
lv_obj_set_style_local_line_opa(animArc, LV_ARC_PART_INDIC, LV_STATE_DEFAULT, LV_OPA_70);
4545
lv_obj_set_style_local_line_opa(animArc, LV_ARC_PART_KNOB, LV_STATE_DEFAULT, LV_OPA_0);
4646
lv_obj_set_style_local_line_color(animArc, LV_ARC_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_RED);
4747
lv_obj_set_style_local_bg_color(animArc, LV_ARC_PART_BG, LV_STATE_CHECKED, LV_COLOR_TRANSP);
48+
4849
animArc->user_data = this;
4950
lv_obj_set_click(animArc, false);
5051

@@ -80,8 +81,8 @@ void SettingShakeThreshold::Refresh() {
8081
if (xTaskGetTickCount() - vCalTime > pdMS_TO_TICKS(2000)) {
8182
vCalTime = xTaskGetTickCount();
8283
calibrating = 2;
83-
lv_obj_set_style_local_bg_color(calButton, LV_BTN_PART_MAIN, LV_BTN_STATE_CHECKED_RELEASED, LV_COLOR_RED);
84-
lv_obj_set_style_local_bg_color(calButton, LV_BTN_PART_MAIN, LV_BTN_STATE_CHECKED_PRESSED, LV_COLOR_RED);
84+
lv_obj_set_style_local_bg_color(calButton, LV_BTN_PART_MAIN, LV_STATE_CHECKED, LV_COLOR_RED);
85+
lv_obj_set_style_local_bg_color(calButton, LV_BTN_PART_MAIN, LV_STATE_CHECKED, LV_COLOR_RED);
8586
lv_label_set_text(calLabel, "Shake!!");
8687
}
8788
}
@@ -108,17 +109,17 @@ void SettingShakeThreshold::UpdateSelected(lv_obj_t* object, lv_event_t event) {
108109
switch (event) {
109110
case LV_EVENT_VALUE_CHANGED: {
110111
if (object == calButton) {
111-
112112
if (lv_btn_get_state(calButton) == LV_BTN_STATE_CHECKED_RELEASED && calibrating == 0) {
113113
lv_arc_set_value(positionArc, 0);
114114
calibrating = 1;
115115
vCalTime = xTaskGetTickCount();
116116
lv_label_set_text(calLabel, "Ready!");
117-
lv_obj_set_click(calButton,false);
117+
lv_obj_set_click(positionArc, false);
118+
lv_obj_set_style_local_bg_color(calButton, LV_BTN_PART_MAIN, LV_STATE_CHECKED, LV_COLOR_GREEN);
119+
lv_obj_set_style_local_bg_color(calButton, LV_BTN_PART_MAIN, LV_STATE_CHECKED, LV_COLOR_GREEN);
118120
} else if (lv_btn_get_state(calButton) == LV_BTN_STATE_RELEASED) {
119-
120121
calibrating = 0;
121-
lv_obj_set_click(calButton,true);
122+
lv_obj_set_click(positionArc, true);
122123
lv_label_set_text(calLabel, "Calibrate");
123124
}
124125
break;

src/displayapp/screens/settings/SettingShakeThreshold.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ namespace Pinetime {
2727
System::SystemTask& systemTask;
2828
uint8_t calibrating;
2929
uint32_t vDecay,vCalTime;
30-
lv_obj_t* cbOption[2];
3130
lv_obj_t *positionArc, *animArc,*calButton, *calLabel;
3231
lv_task_t* refreshTask;
3332
};

0 commit comments

Comments
 (0)