void bootmgr_start(int charger) { settings.default_boot_sd = (char*)malloc(256); bootmgr_load_settings(); bootmgr_init_display(); bootmgr_set_brightness(settings.brightness); int key = 0; int8_t last_selected = -1; int8_t last_phase = -1; uint8_t key_pressed = (settings.timeout_seconds == -1); int16_t timer = settings.timeout_seconds*10; uint16_t x, y; uint8_t touch; selected = -1; pthread_t t_input; pthread_create(&t_input, NULL, bootmgr_input_thread, NULL); bootmgr_set_time_thread(1); bootmgr_selected = settings.default_boot; if(charger && (settings.charger_settings & CHARGER_AUTO_START)) { char status[50]; bootmgr_get_file(battery_status, status, 50); if(strstr(status, "Charging") == status) { key_pressed = 1; bootmgr_charger_init(); } } disable_lg_charger = (settings.charger_settings & CHARGER_DISABLE_LG); while(bootmgr_run) { if(last_selected != bootmgr_selected) { bootmgr_draw(); last_selected = bootmgr_selected; } if(last_phase != bootmgr_phase) { bootmgr_setup_touch(); bootmgr_draw(); last_phase = bootmgr_phase; } key = bootmgr_get_last_key(); touch = bootmgr_get_last_touch(&x, &y); if(key != -1 || touch) { if(!key_pressed) { bootmgr_erase_text(25); bootmgr_draw(); key_pressed = 1; } if(bootmgr_handle_key(key)) break; if(touch && !sleep_mode) { key = bootmgr_check_touch(x, y); if(key & TCALL_EXIT_MGR) break; } } usleep(100000); if(!key_pressed) { if(timer%10 == 0) { bootmgr_printf(-1, 25, WHITE, "Boot from %s in %us", bootmgr_selected == 0 ? "internal mem" : "SD card", timer/10); bootmgr_draw(); } if(--timer <= 0) { bootmgr_erase_text(25); if(bootmgr_selected == 0) { bootmgr_boot_internal(); break; } else { if(bootmgr_boot_sd_auto()) break; } key_pressed = 1; } } } bootmgr_exit(); }
void bootmgr_start() { bootmgr_load_settings(); bootmgr_init_display(); bootmgr_set_brightness(settings.brightness); int key = 0; int8_t last_selected = -1; int8_t last_phase = -1; uint8_t key_pressed = (settings.timeout_seconds == -1); int16_t timer = settings.timeout_seconds*10; uint16_t x, y; uint8_t touch; selected = -1; pthread_t t_input; pthread_create(&t_input, NULL, bootmgr_input_thread, NULL); bootmgr_set_time_thread(1); while(bootmgr_run) { if(last_selected != bootmgr_selected) { bootmgr_draw(); last_selected = bootmgr_selected; } if(last_phase != bootmgr_phase) { bootmgr_setup_touch(); bootmgr_draw(); last_phase = bootmgr_phase; } key = bootmgr_get_last_key(); touch = bootmgr_get_last_touch(&x, &y); if(key != -1 || touch) { if(!key_pressed) { bootmgr_erase_text(25); bootmgr_draw(); key_pressed = 1; } if(bootmgr_handle_key(key)) break; if(touch) { key = bootmgr_check_touch(x, y); if(key & TCALL_EXIT_MGR) break; } } usleep(100000); if(!key_pressed) { if(timer%10 == 0) { bootmgr_printf(-1, 25, WHITE, "Boot from internal mem in %us", timer/10); bootmgr_draw(); } if(--timer <= 0) { bootmgr_boot_internal(); break; } } } bootmgr_exit(); }