Skip to content

Commit

Permalink
treewide: define display timeout in seconds
Browse files Browse the repository at this point in the history
Define the display timeout in seconds rather than in microseconds, in
preparation of making the timeout dynamically configurable.
  • Loading branch information
stintel authored and kristiankielhofner committed Oct 9, 2023
1 parent 517d153 commit 349a8e4
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 17 deletions.
8 changes: 4 additions & 4 deletions main/audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ static esp_err_t cb_ar_event(audio_rec_evt_t *are, void *data)
lvgl_port_unlock();
}

reset_timer(hdl_display_timer, DISPLAY_TIMEOUT_US, false);
reset_timer(hdl_display_timer, DISPLAY_TIMEOUT, false);
break;
case AUDIO_REC_WAKEUP_END:
ESP_LOGI(TAG, "AUDIO_REC_WAKEUP_END");
Expand All @@ -292,7 +292,7 @@ static esp_err_t cb_ar_event(audio_rec_evt_t *are, void *data)
recorder_sr_wakeup_result_t *wake_data = are->event_data;
ESP_LOGI(TAG, "wake volume: %f", wake_data->data_volume);
send_wake_start(wake_data->data_volume);
reset_timer(hdl_display_timer, DISPLAY_TIMEOUT_US, true);
reset_timer(hdl_display_timer, DISPLAY_TIMEOUT, true);

speech_rec_mode = config_get_char("speech_rec_mode", DEFAULT_SPEECH_REC_MODE);

Expand Down Expand Up @@ -356,7 +356,7 @@ static esp_err_t cb_ar_event(audio_rec_evt_t *are, void *data)
lv_label_set_text(lbl_ln2, lookup_cmd_multinet(command_id));
lvgl_port_unlock();
}
reset_timer(hdl_display_timer, DISPLAY_TIMEOUT_US, false);
reset_timer(hdl_display_timer, DISPLAY_TIMEOUT, false);
#else
ESP_LOGE(TAG, "multinet not supported but enabled in config");
#endif
Expand Down Expand Up @@ -785,7 +785,7 @@ static void at_read(void *data)
lv_obj_add_flag(btn_cancel, LV_OBJ_FLAG_HIDDEN);
lvgl_port_unlock();
}
reset_timer(hdl_display_timer, DISPLAY_TIMEOUT_US, false);
reset_timer(hdl_display_timer, DISPLAY_TIMEOUT, false);
break;
default:
printf("at_read(): invalid msg '%d'\n", msg);
Expand Down
2 changes: 1 addition & 1 deletion main/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ void config_write(const char *data)
lv_obj_clear_flag(lbl_ln3, LV_OBJ_FLAG_HIDDEN);
lvgl_port_unlock();
}
reset_timer(hdl_display_timer, DISPLAY_TIMEOUT_US, true);
reset_timer(hdl_display_timer, DISPLAY_TIMEOUT, true);
display_set_backlight(true);
restart_delayed();
}
4 changes: 2 additions & 2 deletions main/endpoint/hass.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ no_speech:;
free(hir.speech);
}

reset_timer(hdl_display_timer, DISPLAY_TIMEOUT_US, false);
reset_timer(hdl_display_timer, DISPLAY_TIMEOUT, false);

cleanup:
cJSON_Delete(cjson);
Expand Down Expand Up @@ -367,7 +367,7 @@ static void hass_post(const char *data)
lvgl_port_unlock();
}

reset_timer(hdl_display_timer, DISPLAY_TIMEOUT_US, false);
reset_timer(hdl_display_timer, DISPLAY_TIMEOUT, false);
free(body);

free(url);
Expand Down
2 changes: 1 addition & 1 deletion main/endpoint/openhab.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ void openhab_send(const char *data)
lvgl_port_unlock();
}

reset_timer(hdl_display_timer, DISPLAY_TIMEOUT_US, false);
reset_timer(hdl_display_timer, DISPLAY_TIMEOUT, false);

free(body);
}
2 changes: 1 addition & 1 deletion main/endpoint/rest.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ void rest_send(const char *data)
lvgl_port_unlock();
}

reset_timer(hdl_display_timer, DISPLAY_TIMEOUT_US, false);
reset_timer(hdl_display_timer, DISPLAY_TIMEOUT, false);

free(body);
}
2 changes: 1 addition & 1 deletion main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ void app_main(void)
// we can also still crash in the while loop below - this should be improved
ESP_ERROR_CHECK_WITHOUT_ABORT(esp_ota_mark_app_valid_cancel_rollback());

ESP_ERROR_CHECK_WITHOUT_ABORT(reset_timer(hdl_display_timer, DISPLAY_TIMEOUT_US, false));
ESP_ERROR_CHECK_WITHOUT_ABORT(reset_timer(hdl_display_timer, DISPLAY_TIMEOUT, false));

#ifdef CONFIG_WILLOW_DEBUG_RUNTIME_STATS
xTaskCreate(&task_debug_runtime_stats, "dbg_runtime_stats", 4 * 1024, NULL, 0, NULL);
Expand Down
2 changes: 1 addition & 1 deletion main/ota.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ void ota_task(void *data)

void ota_start(char *url)
{
reset_timer(hdl_display_timer, DISPLAY_TIMEOUT_US, true);
reset_timer(hdl_display_timer, DISPLAY_TIMEOUT, true);
if (lvgl_port_lock(lvgl_lock_timeout)) {
lv_obj_add_flag(lbl_ln1, LV_OBJ_FLAG_HIDDEN);
lv_obj_add_flag(lbl_ln2, LV_OBJ_FLAG_HIDDEN);
Expand Down
4 changes: 2 additions & 2 deletions main/slvgl.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ void cb_scr(lv_event_t *ev)
// printf("cb_scr\n");
switch (lv_event_get_code(ev)) {
case LV_EVENT_RELEASED:
reset_timer(hdl_display_timer, DISPLAY_TIMEOUT_US, false);
reset_timer(hdl_display_timer, DISPLAY_TIMEOUT, false);
break;

case LV_EVENT_PRESSED:
reset_timer(hdl_display_timer, DISPLAY_TIMEOUT_US, true);
reset_timer(hdl_display_timer, DISPLAY_TIMEOUT, true);
display_set_backlight(true);
break;

Expand Down
2 changes: 1 addition & 1 deletion main/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,5 @@ esp_err_t reset_timer(esp_timer_handle_t hdl, int timeout, bool pause)
if (pause) {
return ESP_OK;
}
return esp_timer_start_once(hdl, timeout);
return esp_timer_start_once(hdl, timeout * 1000 * 1000);
}
4 changes: 2 additions & 2 deletions main/timer.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#define DISPLAY_TIMEOUT_US 10 * 1000 * 1000
#define DISPLAY_TIMEOUT 10

extern esp_timer_handle_t hdl_display_timer, hdl_sess_timer;

esp_err_t init_display_timer(void);
esp_err_t init_session_timer(void);
esp_err_t reset_timer(esp_timer_handle_t hdl, int timeout, bool pause);
esp_err_t reset_timer(esp_timer_handle_t hdl, int timeout, bool pause);
2 changes: 1 addition & 1 deletion main/was.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ static void IRAM_ATTR cb_ws_event(const void *arg_evh, const esp_event_base_t *b
lv_obj_clear_flag(lbl_ln3, LV_OBJ_FLAG_HIDDEN);
lvgl_port_unlock();
}
reset_timer(hdl_display_timer, DISPLAY_TIMEOUT_US, true);
reset_timer(hdl_display_timer, DISPLAY_TIMEOUT, true);
display_set_backlight(true);
deinit_was();
restart_delayed();
Expand Down

0 comments on commit 349a8e4

Please sign in to comment.