diff options
author | Marcin Bukat <marcin.bukat@gmail.com> | 2010-07-17 11:29:06 +0000 |
---|---|---|
committer | Marcin Bukat <marcin.bukat@gmail.com> | 2010-07-17 11:29:06 +0000 |
commit | 47d7be5f8b99435683596c0f96d58541584be430 (patch) | |
tree | 987facd318691cbcda9f9d2062682f07022e9b34 | |
parent | cdb0c16023459bf24f7480be6ecf39a3df607bf2 (diff) | |
download | rockbox-47d7be5f8b99435683596c0f96d58541584be430.tar.gz rockbox-47d7be5f8b99435683596c0f96d58541584be430.zip |
Beautify view_battery() graph in debug menu. FS#11324 by me
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27467 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/debug_menu.c | 72 |
1 files changed, 57 insertions, 15 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c index a574896d63..ec30477698 100644 --- a/apps/debug_menu.c +++ b/apps/debug_menu.c | |||
@@ -1504,10 +1504,11 @@ static bool tsc2100_debug(void) | |||
1504 | #define BAT_LAST_VAL MIN(LCD_WIDTH, POWER_HISTORY_LEN) | 1504 | #define BAT_LAST_VAL MIN(LCD_WIDTH, POWER_HISTORY_LEN) |
1505 | #define BAT_YSPACE (LCD_HEIGHT - 20) | 1505 | #define BAT_YSPACE (LCD_HEIGHT - 20) |
1506 | 1506 | ||
1507 | |||
1507 | static bool view_battery(void) | 1508 | static bool view_battery(void) |
1508 | { | 1509 | { |
1509 | int view = 0; | 1510 | int view = 0; |
1510 | int i, x, y; | 1511 | int i, x, y, y1, y2, grid, graph; |
1511 | unsigned short maxv, minv; | 1512 | unsigned short maxv, minv; |
1512 | 1513 | ||
1513 | lcd_setfont(FONT_SYSFIXED); | 1514 | lcd_setfont(FONT_SYSFIXED); |
@@ -1526,23 +1527,64 @@ static bool view_battery(void) | |||
1526 | if (power_history[i] < minv) | 1527 | if (power_history[i] < minv) |
1527 | minv = power_history[i]; | 1528 | minv = power_history[i]; |
1528 | } | 1529 | } |
1529 | 1530 | ||
1530 | lcd_putsf(0, 0, "Battery %d.%03d", power_history[0] / 1000, | 1531 | /* adjust grid scale */ |
1532 | if ((maxv - minv) > 50) | ||
1533 | grid = 50; | ||
1534 | else | ||
1535 | grid = 5; | ||
1536 | |||
1537 | /* print header */ | ||
1538 | lcd_putsf(0, 0, "battery %d.%03dV", power_history[0] / 1000, | ||
1531 | power_history[0] % 1000); | 1539 | power_history[0] % 1000); |
1532 | lcd_putsf(0, 1, "scale %d.%03d-%d.%03dV", | 1540 | lcd_putsf(0, 1, "%d.%03d-%d.%03dV (%2dmV)", |
1533 | minv / 1000, minv % 1000, maxv / 1000, maxv % 1000); | 1541 | minv / 1000, minv % 1000, maxv / 1000, maxv % 1000, |
1534 | 1542 | grid); | |
1543 | |||
1544 | i = 1; | ||
1545 | while ((y = (minv - (minv % grid)+i*grid)) < maxv) | ||
1546 | { | ||
1547 | graph = ((y-minv)*BAT_YSPACE)/(maxv-minv); | ||
1548 | graph = LCD_HEIGHT-1 - graph; | ||
1549 | |||
1550 | /* draw dotted horizontal grid line */ | ||
1551 | for (x=0; x<LCD_WIDTH;x=x+2) | ||
1552 | lcd_drawpixel(x,graph); | ||
1553 | |||
1554 | i++; | ||
1555 | } | ||
1556 | |||
1535 | x = 0; | 1557 | x = 0; |
1536 | for (i = BAT_LAST_VAL - 1; i >= 0; i--) { | 1558 | /* draw plot of power history |
1537 | y = (power_history[i] - minv) * BAT_YSPACE / (maxv - minv); | 1559 | * skip empty entries |
1538 | lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); | 1560 | */ |
1539 | lcd_vline(x, LCD_HEIGHT-1, 20); | 1561 | for (i = BAT_LAST_VAL - 1; i > 0; i--) |
1540 | lcd_set_drawmode(DRMODE_SOLID); | 1562 | { |
1541 | lcd_vline(x, LCD_HEIGHT-1, | 1563 | if (power_history[i] && power_history[i-1]) |
1542 | MIN(MAX(LCD_HEIGHT-1 - y, 20), LCD_HEIGHT-1)); | 1564 | { |
1543 | x++; | 1565 | y1 = (power_history[i] - minv) * BAT_YSPACE / |
1566 | (maxv - minv); | ||
1567 | y1 = MIN(MAX(LCD_HEIGHT-1 - y1, 20), | ||
1568 | LCD_HEIGHT-1); | ||
1569 | y2 = (power_history[i-1] - minv) * BAT_YSPACE / | ||
1570 | (maxv - minv); | ||
1571 | y2 = MIN(MAX(LCD_HEIGHT-1 - y2, 20), | ||
1572 | LCD_HEIGHT-1); | ||
1573 | |||
1574 | lcd_set_drawmode(DRMODE_SOLID); | ||
1575 | |||
1576 | /* make line thicker */ | ||
1577 | lcd_drawline(((x*LCD_WIDTH)/(BAT_LAST_VAL)), | ||
1578 | y1, | ||
1579 | (((x+1)*LCD_WIDTH)/(BAT_LAST_VAL)), | ||
1580 | y2); | ||
1581 | lcd_drawline(((x*LCD_WIDTH)/(BAT_LAST_VAL))+1, | ||
1582 | y1+1, | ||
1583 | (((x+1)*LCD_WIDTH)/(BAT_LAST_VAL))+1, | ||
1584 | y2+1); | ||
1585 | x++; | ||
1586 | } | ||
1544 | } | 1587 | } |
1545 | |||
1546 | break; | 1588 | break; |
1547 | 1589 | ||
1548 | case 1: /* status: */ | 1590 | case 1: /* status: */ |