Index: apps/bootmenu-ipodclassic/main.c |
— | — | @@ -258,6 +258,22 @@ |
259 | 259 | message(106, "Data partition has", "been reformatted.");
|
260 | 260 | }
|
261 | 261 |
|
| 262 | +bool update_display(struct chooser_data* data)
|
| 263 | +{
|
| 264 | + char buf[6];
|
| 265 | + struct rtc_datetime dt;
|
| 266 | + rtc_read_datetime(&dt);
|
| 267 | + snprintf(buf, sizeof(buf), "%02d:%02d", dt.hour, dt.minute);
|
| 268 | + // clock
|
| 269 | + rendertext(framebuf, 287, 4, 320, 0xffffcccc, 0, buf);
|
| 270 | + unsigned int batt_level = 22 * read_battery_mwh_current(0) / read_battery_mwh_full(0);
|
| 271 | + // remaining battery level
|
| 272 | + ui->blendcolor(batt_level, 6, 0xc0ffcccc, framebuf, 5, 5, 320, framebuf, 5, 5, 320);
|
| 273 | + // background of the rest space
|
| 274 | + ui->blendcolor(22 - batt_level, 6, 0x40000000, framebuf, 5 + batt_level, 5, 320, framebuf, 5 + batt_level, 5, 320);
|
| 275 | + return false;
|
| 276 | +}
|
| 277 | +
|
262 | 278 | struct chooser_renderer_list_params toolchooser_rparams =
|
263 | 279 | {
|
264 | 280 | .version = CHOOSER_RENDERER_LIST_PARAMS_VERSION,
|
— | — | @@ -276,7 +292,7 @@ |
277 | 293 | .blit_dest = LIBUI_POINT(0, 0),
|
278 | 294 | .blit_src = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 320), LIBUI_POINT(0, 0)),
|
279 | 295 | LIBUI_POINT(320, 240)),
|
280 | | - .preblit = NULL,
|
| 296 | + .preblit = update_display,
|
281 | 297 | .postblit = NULL
|
282 | 298 | };
|
283 | 299 |
|
— | — | @@ -348,22 +364,12 @@ |
349 | 365 |
|
350 | 366 | bool mainchooser_preblit(struct chooser_data* data)
|
351 | 367 | {
|
352 | | - char buf[6];
|
353 | | - struct rtc_datetime dt;
|
354 | | - rtc_read_datetime(&dt);
|
355 | | - snprintf(buf, sizeof(buf), "%02d:%02d", dt.hour, dt.minute);
|
356 | | - // clock
|
357 | | - rendertext(framebuf, 287, 4, 320, 0xffffcccc, 0, buf);
|
| 368 | + char buf[4];
|
358 | 369 | struct chooser_action_handler_wheel_data* adata;
|
359 | 370 | adata = (struct chooser_action_handler_wheel_data*)(data->actionhandlerdata);
|
360 | 371 | snprintf(buf, sizeof(buf), "%3d", adata->timeout_remaining / 1000000);
|
361 | | - // remaining time
|
362 | 372 | rendertext(framebuf, 299, 229, 320, 0xffffcccc, 0, buf);
|
363 | | - unsigned int batt_level = 22 * read_battery_mwh_current(0) / read_battery_mwh_full(0);
|
364 | | - // remaining battery level
|
365 | | - ui->blendcolor(batt_level, 6, 0xc0ffcccc, framebuf, 5, 5, 320, framebuf, 5, 5, 320);
|
366 | | - // background of the rest space
|
367 | | - ui->blendcolor(22 - batt_level, 6, 0x40000000, framebuf, 5 + batt_level, 5, 320, framebuf, 5 + batt_level, 5, 320);
|
| 373 | + update_display(data);
|
368 | 374 | return false;
|
369 | 375 | }
|
370 | 376 |
|
Index: apps/bootmenu-ipodnano2g/main.c |
— | — | @@ -318,6 +318,22 @@ |
319 | 319 | }
|
320 | 320 | }
|
321 | 321 |
|
| 322 | +bool update_display(struct chooser_data* data)
|
| 323 | +{
|
| 324 | + char buf[6];
|
| 325 | + struct rtc_datetime dt;
|
| 326 | + rtc_read_datetime(&dt);
|
| 327 | + snprintf(buf, sizeof(buf), "%02d:%02d", dt.hour, dt.minute);
|
| 328 | + // clock
|
| 329 | + rendertext(framebuf, 143, 4, 176, 0xffffcccc, 0, buf);
|
| 330 | + unsigned int batt_level = 22 * read_battery_mwh_current(0) / read_battery_mwh_full(0);
|
| 331 | + // remaining battery level
|
| 332 | + ui->blendcolor(batt_level, 6, 0xc0ffcccc, framebuf, 5, 5, 176, framebuf, 5, 5, 176);
|
| 333 | + // background of the rest space
|
| 334 | + ui->blendcolor(22 - batt_level, 6, 0x40000000, framebuf, 5 + batt_level, 5, 176, framebuf, 5 + batt_level, 5, 176);
|
| 335 | + return false;
|
| 336 | +}
|
| 337 | +
|
322 | 338 | struct chooser_renderer_list_params toolchooser_rparams =
|
323 | 339 | {
|
324 | 340 | .version = CHOOSER_RENDERER_LIST_PARAMS_VERSION,
|
— | — | @@ -336,7 +352,7 @@ |
337 | 353 | .blit_dest = LIBUI_POINT(0, 0),
|
338 | 354 | .blit_src = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 176), LIBUI_POINT(0, 0)),
|
339 | 355 | LIBUI_POINT(176, 132)),
|
340 | | - .preblit = NULL,
|
| 356 | + .preblit = update_display,
|
341 | 357 | .postblit = NULL
|
342 | 358 | };
|
343 | 359 |
|
— | — | @@ -418,22 +434,12 @@ |
419 | 435 |
|
420 | 436 | bool mainchooser_preblit(struct chooser_data* data)
|
421 | 437 | {
|
422 | | - char buf[6];
|
423 | | - struct rtc_datetime dt;
|
424 | | - rtc_read_datetime(&dt);
|
425 | | - snprintf(buf, sizeof(buf), "%02d:%02d", dt.hour, dt.minute);
|
426 | | - // clock
|
427 | | - rendertext(framebuf, 143, 4, 176, 0xffffcccc, 0, buf);
|
| 438 | + char buf[4];
|
428 | 439 | struct chooser_action_handler_wheel_data* adata;
|
429 | 440 | adata = (struct chooser_action_handler_wheel_data*)(data->actionhandlerdata);
|
430 | 441 | snprintf(buf, sizeof(buf), "%3d", adata->timeout_remaining / 1000000);
|
431 | | - // remaining time
|
432 | 442 | rendertext(framebuf, 155, 121, 176, 0xffffcccc, 0, buf);
|
433 | | - unsigned int batt_level = 22 * read_battery_mwh_current(0) / read_battery_mwh_full(0);
|
434 | | - // remaining battery level
|
435 | | - ui->blendcolor(batt_level, 6, 0xc0ffcccc, framebuf, 5, 5, 176, framebuf, 5, 5, 176);
|
436 | | - // background of the rest space
|
437 | | - ui->blendcolor(22 - batt_level, 6, 0x40000000, framebuf, 5 + batt_level, 5, 176, framebuf, 5 + batt_level, 5, 176);
|
| 443 | + update_display(data);
|
438 | 444 | return false;
|
439 | 445 | }
|
440 | 446 |
|