| Index: apps/bootmenu-ipodclassic-wintertheme/util.c | 
| — | — | @@ -26,6 +26,11 @@ | 
| 27 | 27 | #include "main.h" | 
| 28 | 28 |  | 
| 29 | 29 |  | 
|  | 30 | +static struct rtc_datetime datetime; | 
|  | 31 | +static unsigned int batt_level; | 
|  | 32 | +static long next_refresh = 0; | 
|  | 33 | + | 
|  | 34 | + | 
| 30 | 35 | struct emcorelib_header* loadlib(uint32_t identifier, uint32_t version, char* filename) | 
| 31 | 36 | { | 
| 32 | 37 | struct emcorelib_header* lib = get_library(identifier, version, LIBSOURCE_BOOTFLASH, filename); | 
| — | — | @@ -48,9 +53,13 @@ | 
| 49 | 54 | bool update_display(struct chooser_data* data) | 
| 50 | 55 | { | 
| 51 | 56 | char buf[6]; | 
| 52 |  | -    struct rtc_datetime dt;
 | 
| 53 |  | -    rtc_read_datetime(&dt);
 | 
| 54 |  | -    snprintf(buf, sizeof(buf), "%02d:%02d", dt.hour, dt.minute);
 | 
|  | 57 | +    if (!next_refresh || TIMEOUT_EXPIRED(next_refresh, 10000000)) | 
|  | 58 | +    { | 
|  | 59 | +        rtc_read_datetime(&datetime); | 
|  | 60 | +        batt_level = 22 * read_battery_mwh_current(0) / read_battery_mwh_full(0); | 
|  | 61 | +        next_refresh = USEC_TIMER; | 
|  | 62 | +    } | 
|  | 63 | +    snprintf(buf, sizeof(buf), "%02d:%02d", datetime.hour, datetime.minute); | 
| 55 | 64 | // clock | 
| 56 | 65 | rendertext(framebuf, 287, 4, 320, 0xff3f0000, 0x3fffffff, buf); | 
| 57 | 66 | // draw the battery meter box | 
| — | — | @@ -64,7 +73,6 @@ | 
| 65 | 74 | ui->blendcolor(1, 6, 0xcf7f0000, framebuf, 27, 5, 320, framebuf, 27, 5, 320); | 
| 66 | 75 | // top - right | 
| 67 | 76 | ui->blendcolor(1, 4, 0xcf7f0000, framebuf, 28, 6, 320, framebuf, 28, 6, 320); | 
| 68 |  | -    unsigned int batt_level = 22 * read_battery_mwh_current(0) / read_battery_mwh_full(0);
 | 
| 69 | 77 | // remaining battery level | 
| 70 | 78 | ui->blendcolor(batt_level, 6, 0x7fff7f7f, framebuf, 5, 5, 320, framebuf, 5, 5, 320); | 
| 71 | 79 | // background of the rest space | 
| Index: apps/bootmenu-ipodnano2g-wintertheme/util.c | 
| — | — | @@ -26,6 +26,11 @@ | 
| 27 | 27 | #include "main.h" | 
| 28 | 28 |  | 
| 29 | 29 |  | 
|  | 30 | +static struct rtc_datetime datetime; | 
|  | 31 | +static unsigned int batt_level; | 
|  | 32 | +static long next_refresh = 0; | 
|  | 33 | + | 
|  | 34 | + | 
| 30 | 35 | struct emcorelib_header* loadlib(uint32_t identifier, uint32_t version, char* filename) | 
| 31 | 36 | { | 
| 32 | 37 | struct emcorelib_header* lib = get_library(identifier, version, LIBSOURCE_BOOTFLASH, filename); | 
| — | — | @@ -48,9 +53,13 @@ | 
| 49 | 54 | bool update_display(struct chooser_data* data) | 
| 50 | 55 | { | 
| 51 | 56 | char buf[6]; | 
| 52 |  | -    struct rtc_datetime dt;
 | 
| 53 |  | -    rtc_read_datetime(&dt);
 | 
| 54 |  | -    snprintf(buf, sizeof(buf), "%02d:%02d", dt.hour, dt.minute);
 | 
|  | 57 | +    if (!next_refresh || TIMEOUT_EXPIRED(next_refresh, 10000000)) | 
|  | 58 | +    { | 
|  | 59 | +        rtc_read_datetime(&datetime); | 
|  | 60 | +        batt_level = 22 * read_battery_mwh_current(0) / read_battery_mwh_full(0); | 
|  | 61 | +        next_refresh = USEC_TIMER; | 
|  | 62 | +    } | 
|  | 63 | +    snprintf(buf, sizeof(buf), "%02d:%02d", datetime.hour, datetime.minute); | 
| 55 | 64 | // clock | 
| 56 | 65 | rendertext(framebuf, 143, 4, 176, 0xff3f0000, 0x3fffffff, buf); | 
| 57 | 66 | // draw the battery meter box | 
| — | — | @@ -64,7 +73,6 @@ | 
| 65 | 74 | ui->blendcolor(1, 6, 0xcf7f0000, framebuf, 27, 5, 176, framebuf, 27, 5, 176); | 
| 66 | 75 | // top - right | 
| 67 | 76 | ui->blendcolor(1, 4, 0xcf7f0000, framebuf, 28, 6, 176, framebuf, 28, 6, 176); | 
| 68 |  | -    unsigned int batt_level = 22 * read_battery_mwh_current(0) / read_battery_mwh_full(0);
 | 
| 69 | 77 | // remaining battery level | 
| 70 | 78 | ui->blendcolor(batt_level, 6, 0x7fff7f7f, framebuf, 5, 5, 176, framebuf, 5, 5, 176); | 
| 71 | 79 | // background of the rest space | 
| Index: apps/bootmenu-ipodclassic/util.c | 
| — | — | @@ -26,6 +26,11 @@ | 
| 27 | 27 | #include "main.h" | 
| 28 | 28 |  | 
| 29 | 29 |  | 
|  | 30 | +static struct rtc_datetime datetime; | 
|  | 31 | +static unsigned int batt_level; | 
|  | 32 | +static long next_refresh = 0; | 
|  | 33 | + | 
|  | 34 | + | 
| 30 | 35 | struct emcorelib_header* loadlib(uint32_t identifier, uint32_t version, char* filename) | 
| 31 | 36 | { | 
| 32 | 37 | struct emcorelib_header* lib = get_library(identifier, version, LIBSOURCE_BOOTFLASH, filename); | 
| — | — | @@ -48,9 +53,13 @@ | 
| 49 | 54 | bool update_display(struct chooser_data* data) | 
| 50 | 55 | { | 
| 51 | 56 | char buf[6]; | 
| 52 |  | -    struct rtc_datetime dt;
 | 
| 53 |  | -    rtc_read_datetime(&dt);
 | 
| 54 |  | -    snprintf(buf, sizeof(buf), "%02d:%02d", dt.hour, dt.minute);
 | 
|  | 57 | +    if (!next_refresh || TIMEOUT_EXPIRED(next_refresh, 10000000)) | 
|  | 58 | +    { | 
|  | 59 | +        rtc_read_datetime(&datetime); | 
|  | 60 | +        batt_level = 22 * read_battery_mwh_current(0) / read_battery_mwh_full(0); | 
|  | 61 | +        next_refresh = USEC_TIMER; | 
|  | 62 | +    } | 
|  | 63 | +    snprintf(buf, sizeof(buf), "%02d:%02d", datetime.hour, datetime.minute); | 
| 55 | 64 | // clock | 
| 56 | 65 | rendertext(framebuf, 287, 4, 320, 0xffffcccc, 0, buf); | 
| 57 | 66 | // draw the battery meter box | 
| — | — | @@ -64,7 +73,6 @@ | 
| 65 | 74 | ui->blendcolor(1, 6, 0xffffcccc, framebuf, 27, 5, 320, framebuf, 27, 5, 320); | 
| 66 | 75 | // top - right | 
| 67 | 76 | ui->blendcolor(1, 4, 0xffffcccc, framebuf, 28, 6, 320, framebuf, 28, 6, 320); | 
| 68 |  | -    unsigned int batt_level = 22 * read_battery_mwh_current(0) / read_battery_mwh_full(0);
 | 
| 69 | 77 | // remaining battery level | 
| 70 | 78 | ui->blendcolor(batt_level, 6, 0xc0ffcccc, framebuf, 5, 5, 320, framebuf, 5, 5, 320); | 
| 71 | 79 | // background of the rest space | 
| Index: apps/bootmenu-ipodnano2g/util.c | 
| — | — | @@ -26,6 +26,11 @@ | 
| 27 | 27 | #include "main.h" | 
| 28 | 28 |  | 
| 29 | 29 |  | 
|  | 30 | +static struct rtc_datetime datetime; | 
|  | 31 | +static unsigned int batt_level; | 
|  | 32 | +static long next_refresh = 0; | 
|  | 33 | + | 
|  | 34 | + | 
| 30 | 35 | struct emcorelib_header* loadlib(uint32_t identifier, uint32_t version, char* filename) | 
| 31 | 36 | { | 
| 32 | 37 | struct emcorelib_header* lib = get_library(identifier, version, LIBSOURCE_BOOTFLASH, filename); | 
| — | — | @@ -48,9 +53,13 @@ | 
| 49 | 54 | bool update_display(struct chooser_data* data) | 
| 50 | 55 | { | 
| 51 | 56 | char buf[6]; | 
| 52 |  | -    struct rtc_datetime dt;
 | 
| 53 |  | -    rtc_read_datetime(&dt);
 | 
| 54 |  | -    snprintf(buf, sizeof(buf), "%02d:%02d", dt.hour, dt.minute);
 | 
|  | 57 | +    if (!next_refresh || TIMEOUT_EXPIRED(next_refresh, 10000000)) | 
|  | 58 | +    { | 
|  | 59 | +        rtc_read_datetime(&datetime); | 
|  | 60 | +        batt_level = 22 * read_battery_mwh_current(0) / read_battery_mwh_full(0); | 
|  | 61 | +        next_refresh = USEC_TIMER; | 
|  | 62 | +    } | 
|  | 63 | +    snprintf(buf, sizeof(buf), "%02d:%02d", datetime.hour, datetime.minute); | 
| 55 | 64 | // clock | 
| 56 | 65 | rendertext(framebuf, 143, 4, 176, 0xffffcccc, 0, buf); | 
| 57 | 66 | // draw the battery meter box | 
| — | — | @@ -64,7 +73,6 @@ | 
| 65 | 74 | ui->blendcolor(1, 6, 0xffffcccc, framebuf, 27, 5, 176, framebuf, 27, 5, 176); | 
| 66 | 75 | // tip - right | 
| 67 | 76 | ui->blendcolor(1, 4, 0xffffcccc, framebuf, 28, 6, 176, framebuf, 28, 6, 176); | 
| 68 |  | -    unsigned int batt_level = 22 * read_battery_mwh_current(0) / read_battery_mwh_full(0);
 | 
| 69 | 77 | // remaining battery level | 
| 70 | 78 | ui->blendcolor(batt_level, 6, 0xc0ffcccc, framebuf, 5, 5, 176, framebuf, 5, 5, 176); | 
| 71 | 79 | // background of the rest space |