Subversion Repositories freemyipod

Rev

Rev 843 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 843 Rev 879
Line 24... Line 24...
24
#include "emcoreapp.h"
24
#include "emcoreapp.h"
25
#include "util.h"
25
#include "util.h"
26
#include "main.h"
26
#include "main.h"
27
 
27
 
28
 
28
 
-
 
29
static struct rtc_datetime datetime;
-
 
30
static unsigned int batt_level;
-
 
31
static long next_refresh = 0;
-
 
32
 
-
 
33
 
29
struct emcorelib_header* loadlib(uint32_t identifier, uint32_t version, char* filename)
34
struct emcorelib_header* loadlib(uint32_t identifier, uint32_t version, char* filename)
30
{
35
{
31
    struct emcorelib_header* lib = get_library(identifier, version, LIBSOURCE_BOOTFLASH, filename);
36
    struct emcorelib_header* lib = get_library(identifier, version, LIBSOURCE_BOOTFLASH, filename);
32
    if (!lib) panicf(PANIC_KILLTHREAD, "Could not load %s", filename);
37
    if (!lib) panicf(PANIC_KILLTHREAD, "Could not load %s", filename);
33
    return lib;
38
    return lib;
Line 46... Line 51...
46
}
51
}
47
 
52
 
48
bool update_display(struct chooser_data* data)
53
bool update_display(struct chooser_data* data)
49
{
54
{
50
    char buf[6];
55
    char buf[6];
-
 
56
    if (!next_refresh || TIMEOUT_EXPIRED(next_refresh, 10000000))
-
 
57
    {
51
    struct rtc_datetime dt;
58
        rtc_read_datetime(&datetime);
-
 
59
        batt_level = 22 * read_battery_mwh_current(0) / read_battery_mwh_full(0);
52
    rtc_read_datetime(&dt);
60
        next_refresh = USEC_TIMER;
-
 
61
    }
53
    snprintf(buf, sizeof(buf), "%02d:%02d", dt.hour, dt.minute);
62
    snprintf(buf, sizeof(buf), "%02d:%02d", datetime.hour, datetime.minute);
54
    // clock
63
    // clock
55
    rendertext(framebuf, 287, 4, 320, 0xffffcccc, 0, buf);
64
    rendertext(framebuf, 287, 4, 320, 0xffffcccc, 0, buf);
56
    // draw the battery meter box
65
    // draw the battery meter box
57
    // top line
66
    // top line
58
    ui->blendcolor(24, 1, 0xffffcccc, framebuf, 4, 4, 320, framebuf, 4, 4, 320);
67
    ui->blendcolor(24, 1, 0xffffcccc, framebuf, 4, 4, 320, framebuf, 4, 4, 320);
Line 62... Line 71...
62
    ui->blendcolor(1, 6, 0xffffcccc, framebuf, 4, 5, 320, framebuf, 4, 5, 320);
71
    ui->blendcolor(1, 6, 0xffffcccc, framebuf, 4, 5, 320, framebuf, 4, 5, 320);
63
    // right line
72
    // right line
64
    ui->blendcolor(1, 6, 0xffffcccc, framebuf, 27, 5, 320, framebuf, 27, 5, 320);
73
    ui->blendcolor(1, 6, 0xffffcccc, framebuf, 27, 5, 320, framebuf, 27, 5, 320);
65
    // top - right
74
    // top - right
66
    ui->blendcolor(1, 4, 0xffffcccc, framebuf, 28, 6, 320, framebuf, 28, 6, 320);
75
    ui->blendcolor(1, 4, 0xffffcccc, framebuf, 28, 6, 320, framebuf, 28, 6, 320);
67
    unsigned int batt_level = 22 * read_battery_mwh_current(0) / read_battery_mwh_full(0);
-
 
68
    // remaining battery level
76
    // remaining battery level
69
    ui->blendcolor(batt_level, 6, 0xc0ffcccc, framebuf, 5, 5, 320, framebuf, 5, 5, 320);
77
    ui->blendcolor(batt_level, 6, 0xc0ffcccc, framebuf, 5, 5, 320, framebuf, 5, 5, 320);
70
    // background of the rest space
78
    // background of the rest space
71
    ui->blendcolor(22 - batt_level, 6, 0x40000000, framebuf, 5 + batt_level,
79
    ui->blendcolor(22 - batt_level, 6, 0x40000000, framebuf, 5 + batt_level,
72
                   5, 320, framebuf, 5 + batt_level, 5, 320);
80
                   5, 320, framebuf, 5 + batt_level, 5, 320);