| 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, 143, 4, 176, 0xffffcccc, 0, buf);
|
64 |
rendertext(framebuf, 143, 4, 176, 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, 176, framebuf, 4, 4, 176);
|
67 |
ui->blendcolor(24, 1, 0xffffcccc, framebuf, 4, 4, 176, framebuf, 4, 4, 176);
|
| Line 62... |
Line 71... |
| 62 |
ui->blendcolor(1, 6, 0xffffcccc, framebuf, 4, 5, 176, framebuf, 4, 5, 176);
|
71 |
ui->blendcolor(1, 6, 0xffffcccc, framebuf, 4, 5, 176, framebuf, 4, 5, 176);
|
| 63 |
// right line
|
72 |
// right line
|
| 64 |
ui->blendcolor(1, 6, 0xffffcccc, framebuf, 27, 5, 176, framebuf, 27, 5, 176);
|
73 |
ui->blendcolor(1, 6, 0xffffcccc, framebuf, 27, 5, 176, framebuf, 27, 5, 176);
|
| 65 |
// tip - right
|
74 |
// tip - right
|
| 66 |
ui->blendcolor(1, 4, 0xffffcccc, framebuf, 28, 6, 176, framebuf, 28, 6, 176);
|
75 |
ui->blendcolor(1, 4, 0xffffcccc, framebuf, 28, 6, 176, framebuf, 28, 6, 176);
|
| 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, 176, framebuf, 5, 5, 176);
|
77 |
ui->blendcolor(batt_level, 6, 0xc0ffcccc, framebuf, 5, 5, 176, framebuf, 5, 5, 176);
|
| 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, 176, framebuf, 5 + batt_level, 5, 176);
|
80 |
5, 176, framebuf, 5 + batt_level, 5, 176);
|