Skip to content

Commit

Permalink
info app: Show time 3V3 regulator has been off.
Browse files Browse the repository at this point in the history
  • Loading branch information
jakkra committed Aug 13, 2023
1 parent b1f37bd commit d522030
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
2 changes: 2 additions & 0 deletions app/src/applications/info/info_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ static void info_app_start(lv_obj_t *root, lv_group_t *group)
info_ui_set_uptime_sec(k_uptime_get() / 1000);
info_ui_set_total_uptime_sec(retained.uptime_sum / 1000);
info_ui_set_wakeup_time_sec(retained.wakeup_time / 1000, (retained.wakeup_time / (double)retained.uptime_sum) * 100);
info_ui_set_ref_off_time_sec(retained.display_off_time / 1000, (retained.display_off_time / (double)retained.uptime_sum) * 100);
info_ui_set_time_to_inactive_sec(zsw_power_manager_get_ms_to_inactive() / 1000);
info_ui_set_resets(retained.boots);

Expand All @@ -62,6 +63,7 @@ static void timer_callback(lv_timer_t *timer)
info_ui_set_uptime_sec(k_uptime_get() / 1000);
info_ui_set_total_uptime_sec(retained.uptime_sum / 1000);
info_ui_set_wakeup_time_sec(retained.wakeup_time / 1000, (retained.wakeup_time / (double)retained.uptime_sum) * 100);
info_ui_set_ref_off_time_sec(retained.display_off_time / 1000, (retained.display_off_time / (double)retained.uptime_sum) * 100);
info_ui_set_time_to_inactive_sec(zsw_power_manager_get_ms_to_inactive() / 1000);
}

Expand Down
27 changes: 23 additions & 4 deletions app/src/applications/info/info_ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ static lv_obj_t *uptime_label;
static lv_obj_t *resets_label;
static lv_obj_t *runtime_label;
static lv_obj_t *wake_time_label;
static lv_obj_t *disp_pwr_off_label;
static lv_obj_t *mac_addr_label;
static lv_obj_t *inactive_time_label;

Expand Down Expand Up @@ -52,18 +53,25 @@ static void create_ui(lv_obj_t *parent)
lv_obj_set_y(wake_time_label, 15);
lv_obj_set_align(wake_time_label, LV_ALIGN_LEFT_MID);

disp_pwr_off_label = lv_label_create(parent);
lv_obj_set_width(disp_pwr_off_label, LV_SIZE_CONTENT);
lv_obj_set_height(disp_pwr_off_label, LV_SIZE_CONTENT);
lv_obj_set_x(disp_pwr_off_label, 10);
lv_obj_set_y(disp_pwr_off_label, 35);
lv_obj_set_align(disp_pwr_off_label, LV_ALIGN_LEFT_MID);

mac_addr_label = lv_label_create(parent);
lv_obj_set_width(mac_addr_label, LV_SIZE_CONTENT);
lv_obj_set_height(mac_addr_label, LV_SIZE_CONTENT);
lv_obj_set_x(mac_addr_label, 10);
lv_obj_set_y(mac_addr_label, 35);
lv_obj_set_x(mac_addr_label, 20);
lv_obj_set_y(mac_addr_label, 50);
lv_obj_set_align(mac_addr_label, LV_ALIGN_LEFT_MID);

inactive_time_label = lv_label_create(parent);
lv_obj_set_width(inactive_time_label, LV_SIZE_CONTENT);
lv_obj_set_height(inactive_time_label, LV_SIZE_CONTENT);
lv_obj_set_x(inactive_time_label, 20);
lv_obj_set_y(inactive_time_label, 50);
lv_obj_set_x(inactive_time_label, 30);
lv_obj_set_y(inactive_time_label, 65);
lv_obj_set_align(inactive_time_label, LV_ALIGN_LEFT_MID);
}

Expand Down Expand Up @@ -133,6 +141,17 @@ void info_ui_set_wakeup_time_sec(uint64_t total_wake_time, uint32_t percent_used
lv_label_set_text(wake_time_label, buf);
}

void info_ui_set_ref_off_time_sec(uint64_t total_off_time, uint32_t percent_off)
{
int days;
int hours;
int minutes;
int seconds;

seconds_to_time_chunks(total_off_time, &days, &hours, &minutes, &seconds);
lv_label_set_text_fmt(disp_pwr_off_label, "3V3 off: %02d:%02d:%02d:%02d (%d%%)", days, hours, minutes, seconds, percent_off);
}

void info_ui_set_time_to_inactive_sec(uint32_t time_left_seconds)
{
char buf[100] = {};
Expand Down
2 changes: 2 additions & 0 deletions app/src/applications/info/info_ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ void info_ui_set_total_uptime_sec(uint32_t uptime_seconds);

void info_ui_set_wakeup_time_sec(uint64_t total_wake_time, uint32_t percent_used);

void info_ui_set_ref_off_time_sec(uint64_t total_off_time, uint32_t percent_off);

void info_ui_set_time_to_inactive_sec(uint32_t time_left_seconds);

void info_ui_set_mac_addr(char *mac_str);

0 comments on commit d522030

Please sign in to comment.