Esempio n. 1
0
void tetris_print_batt()
{
    char pct[5];
    bootmgr_get_file(battery_pct, &pct, 4);
    char *n = strchr(&pct, '\n');
    *n = NULL;
    bootmgr_printf(234, 28, WHITE, "Batt: %s%%", &pct);
}
Esempio n. 2
0
void *bootmgr_time_thread(void *cookie)
{
    time_t tm;

    char pct[5];
    char status[50];
    int8_t hours;
    int8_t mins;

    const uint16_t update_val = settings.show_seconds ? 10 : 600;
    uint16_t timer = update_val;

    while(bootmgr_time_run)
    {
        if(timer == update_val)
        {
            time(&tm);
            bootmgr_get_file(battery_pct, &pct, 4);
            char *n = strchr(&pct, '\n');
            *n = NULL;
            bootmgr_get_file(battery_status, &status, 50);

            // Timezone lame handling
            hours = (tm%86400/60/60) + settings.timezone;
            mins = tm%3600/60 + settings.timezone_mins;

            if     (mins >= 60) { mins -= 60; ++hours; }
            else if(mins < 0)   { mins = 60 - mins; --hours; }

            if     (hours >= 24) hours -= 24;
            else if(hours < 0)   hours = 24 + hours;

            if(settings.show_seconds)
                bootmgr_printf(0, 0, WHITE, "%2u:%02u:%02u    Battery: %s%%, %s", hours, mins, tm%60, &pct, &status);
            else
                bootmgr_printf(0, 0, WHITE, "%2u:%02u         Battery: %s%%, %s", hours, mins, &pct, &status);

            bootmgr_draw();
            timer = 0;
        }
        usleep(100000);
        ++timer;
    }
    return NULL;
}
Esempio n. 3
0
void *bootmgr_time_thread(void *cookie)
{
    time_t tm;

    char status[50];
    int8_t hours;
    int8_t mins;
    int battery;

    const uint16_t update_val = settings.show_seconds ? 10 : 600;
    uint16_t timer = update_val;

    while(bootmgr_time_run)
    {
        if(sleep_mode)
        {
            usleep(500000);
            continue;
        }

        if(timer == update_val || force_update_time)
        {
            time(&tm);

            battery = bootmgr_get_battery_pct();
            bootmgr_get_file(battery_status, status, 50);

            // Timezone lame handling
            hours = (tm%86400/60/60) + settings.timezone;
            mins = tm%3600/60 + settings.timezone_mins;

            if     (mins >= 60) { mins -= 60; ++hours; }
            else if(mins < 0)   { mins = 60 - mins; --hours; }

            if     (hours >= 24) hours -= 24;
            else if(hours < 0)   hours = 24 + hours;

            if(settings.show_seconds)
                bootmgr_printf(0, 0, WHITE, "%2u:%02u:%02u    Battery: %u%%, %s", hours, mins, tm%60, battery, status);
            else
                bootmgr_printf(0, 0, WHITE, "%2u:%02u         Battery: %u%%, %s", hours, mins, battery, status);

            bootmgr_draw();
            timer = 0;
            force_update_time = 0;
        }
        usleep(100000);
        ++timer;
    }
    return NULL;
}
Esempio n. 4
0
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();
}