nyx: Disallow eMMC ops with low battery

This commit is contained in:
CTCaer 2020-04-30 03:59:16 +03:00
parent e89b7f12dd
commit f540c8250b
4 changed files with 40 additions and 0 deletions

View file

@ -367,6 +367,39 @@ lv_res_t mbox_action(lv_obj_t *btns, const char *txt)
return LV_RES_INV; return LV_RES_INV;
} }
bool nyx_emmc_check_battery_enough()
{
int batt_volt = 4000;
max17050_get_property(MAX17050_VCELL, &batt_volt);
if (batt_volt < 3650)
{
lv_obj_t *dark_bg = lv_obj_create(lv_scr_act(), NULL);
lv_obj_set_style(dark_bg, &mbox_darken);
lv_obj_set_size(dark_bg, LV_HOR_RES, LV_VER_RES);
static const char * mbox_btn_map[] = { "\211", "\222OK", "\211", "" };
lv_obj_t * mbox = lv_mbox_create(dark_bg, NULL);
lv_mbox_set_recolor_text(mbox, true);
lv_mbox_set_text(mbox,
"#FF8000 Battery Check#\n\n"
"#FFDD00 Battery is not enough to carry on#\n"
"#FFDD00 with selected operation!#\n\n"
"Charge to at least #C7EA46 3650 mV#, and try again!");
lv_mbox_add_btns(mbox, mbox_btn_map, mbox_action);
lv_obj_set_width(mbox, LV_HOR_RES / 9 * 5);
lv_obj_align(mbox, NULL, LV_ALIGN_CENTER, 0, 0);
lv_obj_set_top(mbox, true);
return false;
}
return true;
}
static void nyx_sd_card_issues(void *param) static void nyx_sd_card_issues(void *param)
{ {
lv_obj_t *dark_bg = lv_obj_create(lv_scr_act(), NULL); lv_obj_t *dark_bg = lv_obj_create(lv_scr_act(), NULL);

View file

@ -55,6 +55,7 @@ lv_style_t mbox_darken;
lv_img_dsc_t *bmp_to_lvimg_obj(const char *path); lv_img_dsc_t *bmp_to_lvimg_obj(const char *path);
lv_res_t mbox_action(lv_obj_t * btns, const char * txt); lv_res_t mbox_action(lv_obj_t * btns, const char * txt);
bool nyx_emmc_check_battery_enough();
void nyx_window_toggle_buttons(lv_obj_t *win, bool disable); void nyx_window_toggle_buttons(lv_obj_t *win, bool disable);
lv_obj_t *nyx_create_standard_window(const char *win_title); lv_obj_t *nyx_create_standard_window(const char *win_title);
void nyx_create_onoff_button(lv_theme_t *th, lv_obj_t *parent, lv_obj_t *btn, const char *btn_name, lv_action_t action, bool transparent); void nyx_create_onoff_button(lv_theme_t *th, lv_obj_t *parent, lv_obj_t *btn, const char *btn_name, lv_action_t action, bool transparent);

View file

@ -177,6 +177,9 @@ static void _create_window_backup_restore(emmcPartType_t type, const char* win_l
static lv_res_t _emmc_backup_buttons_decider(lv_obj_t *btn) static lv_res_t _emmc_backup_buttons_decider(lv_obj_t *btn)
{ {
if (!nyx_emmc_check_battery_enough())
return LV_RES_OK;
char *win_label = lv_label_get_text(lv_obj_get_child(btn, NULL)); char *win_label = lv_label_get_text(lv_obj_get_child(btn, NULL));
if (emmc_btn_ctxt.emmc_boot == btn) if (emmc_btn_ctxt.emmc_boot == btn)

View file

@ -308,6 +308,9 @@ static lv_res_t _create_emummc_action(lv_obj_t * btns, const char * txt)
static lv_res_t _create_mbox_emummc_create(lv_obj_t *btn) static lv_res_t _create_mbox_emummc_create(lv_obj_t *btn)
{ {
if (!nyx_emmc_check_battery_enough())
return LV_RES_OK;
lv_obj_t *dark_bg = lv_obj_create(lv_scr_act(), NULL); lv_obj_t *dark_bg = lv_obj_create(lv_scr_act(), NULL);
lv_obj_set_style(dark_bg, &mbox_darken); lv_obj_set_style(dark_bg, &mbox_darken);
lv_obj_set_size(dark_bg, LV_HOR_RES, LV_VER_RES); lv_obj_set_size(dark_bg, LV_HOR_RES, LV_VER_RES);