store/load run status on edit

This commit is contained in:
leo 2023-09-21 17:26:53 +02:00
parent e017cb8a9d
commit 11446b5de7
Signed by: leo
GPG Key ID: 0DD993BFB2B307DB

View File

@ -23,6 +23,8 @@ static lv_obj_t* ws_label;
static lv_timer_t* volume_readout_update_timer = NULL;
static uint8_t run_status = 0;
static void delete_timer(lv_timer_t** timer){
if(*timer == NULL) return;
lv_timer_del(*timer);
@ -51,6 +53,7 @@ static void run_handler(lv_event_t * e){
lv_label_set_text(label, LV_SYMBOL_PAUSE);
pse_sp_set_dir_all(units, units_num, 1);
pse_sp_start_all(units, units_num);
run_status = 1;
volume_readout_update_timer = lv_timer_create(volume_readout_update, 100, NULL);
}
@ -58,6 +61,7 @@ static void run_handler(lv_event_t * e){
lv_label_set_text(label, LV_SYMBOL_PLAY);
pse_sp_stop_all(units, units_num);
delete_timer(&volume_readout_update_timer);
run_status = 0;
}
}
}
@ -192,7 +196,7 @@ static lv_obj_t* PSE_unit_widget(lv_obj_t* parent, pse_unit* pse_unit){
lv_obj_t* enabled = lv_btn_create(cont);
lv_obj_t* enabled_label = lv_label_create(enabled);
lv_obj_set_width(enabled, lv_pct(100));
lv_obj_add_flag(enabled, LV_OBJ_FLAG_CHECKABLE);
lv_obj_add_flag(enabled, LV_OBJ_FLAG_CHECKABLE);
lv_obj_add_event_cb(enabled, unit_widget_enabled_handler, LV_EVENT_ALL, pse_unit);
lv_obj_set_flex_grow(enabled, 1);
lv_obj_center(enabled_label);
@ -232,6 +236,11 @@ void Home_Screen_Gen(pse_unit* pse_units, uint8_t pse_unit_num, uint8_t delete){
lv_obj_t* run_label = lv_label_create(run_button);
lv_label_set_text(run_label, LV_SYMBOL_PLAY);
lv_obj_center(run_label);
if(run_status){
lv_obj_add_state(run_button, LV_STATE_CHECKED);
lv_label_set_text(run_label, LV_SYMBOL_PAUSE);
volume_readout_update_timer = lv_timer_create(volume_readout_update, 100, NULL);
}
// add workspace switcher
lv_obj_t* ws_left = lv_btn_create(top_menu);