diff --git a/nyx/nyx_gui/frontend/gui.c b/nyx/nyx_gui/frontend/gui.c index 519d990..90f0628 100644 --- a/nyx/nyx_gui/frontend/gui.c +++ b/nyx/nyx_gui/frontend/gui.c @@ -367,6 +367,39 @@ lv_res_t mbox_action(lv_obj_t *btns, const char *txt) 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) { lv_obj_t *dark_bg = lv_obj_create(lv_scr_act(), NULL); diff --git a/nyx/nyx_gui/frontend/gui.h b/nyx/nyx_gui/frontend/gui.h index 37d238f..4e1ef23 100644 --- a/nyx/nyx_gui/frontend/gui.h +++ b/nyx/nyx_gui/frontend/gui.h @@ -55,6 +55,7 @@ lv_style_t mbox_darken; lv_img_dsc_t *bmp_to_lvimg_obj(const char *path); 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); 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); diff --git a/nyx/nyx_gui/frontend/gui_emmc_tools.c b/nyx/nyx_gui/frontend/gui_emmc_tools.c index 31aee7a..42e62e6 100644 --- a/nyx/nyx_gui/frontend/gui_emmc_tools.c +++ b/nyx/nyx_gui/frontend/gui_emmc_tools.c @@ -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) { + if (!nyx_emmc_check_battery_enough()) + return LV_RES_OK; + char *win_label = lv_label_get_text(lv_obj_get_child(btn, NULL)); if (emmc_btn_ctxt.emmc_boot == btn) diff --git a/nyx/nyx_gui/frontend/gui_emummc_tools.c b/nyx/nyx_gui/frontend/gui_emummc_tools.c index ca15500..448482a 100644 --- a/nyx/nyx_gui/frontend/gui_emummc_tools.c +++ b/nyx/nyx_gui/frontend/gui_emummc_tools.c @@ -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) { + if (!nyx_emmc_check_battery_enough()) + return LV_RES_OK; + 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);