Skip to content

Commit a980238

Browse files
committed
Redraw the battery indicator in iOS style, #11
1 parent 880bf42 commit a980238

File tree

2 files changed

+28
-20
lines changed

2 files changed

+28
-20
lines changed

ats-mini/ats-mini.ino

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
#define vol_offset_y 150 // Volume vertical offset
7878
#define rds_offset_x 165 // RDS horizontal offset
7979
#define rds_offset_y 94 // RDS vertical offset
80-
#define batt_offset_x 286 // Battery meter x offset
80+
#define batt_offset_x 288 // Battery meter x offset
8181
#define batt_offset_y 0 // Battery meter y offset
8282
#define clock_datum 90 // Clock x offset
8383

@@ -2327,52 +2327,59 @@ void batteryMonitor() {
23272327
uint16_t batteryLevelColor;
23282328

23292329
if (batt_soc_state == 0 ) {
2330-
chargeLevel=7;
2330+
chargeLevel=6;
23312331
batteryLevelColor=theme[themeIdx].batt_low;
23322332
}
23332333
if (batt_soc_state == 1 ) {
2334-
chargeLevel=14;
2334+
chargeLevel=12;
23352335
batteryLevelColor=theme[themeIdx].batt_full;
23362336
}
23372337
if (batt_soc_state == 2 ) {
2338-
chargeLevel=21;
2338+
chargeLevel=18;
23392339
batteryLevelColor=theme[themeIdx].batt_full;
23402340
}
23412341
if (batt_soc_state == 3 ) {
2342-
chargeLevel=28;
2342+
chargeLevel=24;
23432343
batteryLevelColor=theme[themeIdx].batt_full;
23442344
}
23452345

23462346
// Set display information
2347-
spr.fillRect(batt_offset_x, batt_offset_y + 1, 30, 14, theme[themeIdx].batt_border);
2348-
spr.fillRect(batt_offset_x + 30, batt_offset_y + 3, 3, 10, theme[themeIdx].batt_border);
2347+
spr.drawRoundRect(batt_offset_x, batt_offset_y + 1, 28, 14, 3, theme[themeIdx].batt_border);
2348+
spr.drawLine(batt_offset_x + 29, batt_offset_y + 5, batt_offset_x + 29, batt_offset_y + 10, theme[themeIdx].batt_border);
2349+
spr.drawLine(batt_offset_x + 30, batt_offset_y + 6, batt_offset_x + 30, batt_offset_y + 9, theme[themeIdx].batt_border);
23492350

23502351
spr.setTextDatum(TR_DATUM);
23512352
spr.setTextColor(theme[themeIdx].batt_voltage, theme[themeIdx].bg);
23522353

23532354
#if THEME_EDITOR
2354-
spr.fillRect(batt_offset_x - 32, batt_offset_y + 1, 30, 14, theme[themeIdx].batt_border);
2355-
spr.fillRect(batt_offset_x - 32 + 30, batt_offset_y + 3, 3, 10, theme[themeIdx].batt_border);
2355+
spr.drawRoundRect(batt_offset_x - 31, batt_offset_y + 1, 28, 14, 3, theme[themeIdx].batt_border);
2356+
spr.drawLine(batt_offset_x - 31 + 29, batt_offset_y + 5, batt_offset_x - 31 + 29, batt_offset_y + 10, theme[themeIdx].batt_border);
2357+
spr.drawLine(batt_offset_x - 31 + 30, batt_offset_y + 6, batt_offset_x - 31 + 30, batt_offset_y + 9, theme[themeIdx].batt_border);
23562358

2357-
spr.fillRect(batt_offset_x -32 + 1, batt_offset_y + 2, 28, 12, theme[themeIdx].bg);
2358-
spr.fillRect(batt_offset_x -32 + 1, batt_offset_y + 2, 21, 12, theme[themeIdx].batt_full);
2359-
spr.fillRect(batt_offset_x -32 + 1, batt_offset_y + 2, 14, 12, theme[themeIdx].batt_low);
2360-
spr.drawString("4.0V", batt_offset_x -32 - 3, batt_offset_y, 2);
2359+
spr.fillRoundRect(batt_offset_x - 31 + 2, batt_offset_y + 3, 18, 10, 2, theme[themeIdx].batt_full);
2360+
spr.fillRoundRect(batt_offset_x - 31 + 2, batt_offset_y + 3, 12, 10, 2, theme[themeIdx].batt_low);
2361+
spr.drawString("4.0V", batt_offset_x - 31 - 3, batt_offset_y, 2);
23612362

23622363
adc_volt_avr = 4.5;
23632364
#endif
23642365
// The hardware has a load sharing circuit to allow simultaneous charge and power
23652366
// With USB(5V) connected the voltage reading will be approx. VBUS - Diode Drop = 4.65V
23662367
// If the average voltage is greater than 4.3V, show ligtning on the display
23672368
if (adc_volt_avr > 4.3) {
2368-
spr.fillRect(batt_offset_x + 1, batt_offset_y + 2, 28, 12, theme[themeIdx].batt_charge);
2369-
spr.fillTriangle(batt_offset_x + 6, batt_offset_y + 7, batt_offset_x + 16, batt_offset_y + 7, batt_offset_x + 16, batt_offset_y + 4, theme[themeIdx].batt_icon);
2370-
spr.fillTriangle(batt_offset_x + 23, batt_offset_y + 8, batt_offset_x + 13, batt_offset_y + 8, batt_offset_x + 13, batt_offset_y + 11, theme[themeIdx].batt_icon);
2371-
}
2372-
else {
2369+
spr.fillRoundRect(batt_offset_x + 2, batt_offset_y + 3, 24, 10, 2, theme[themeIdx].batt_charge);
2370+
spr.drawLine(batt_offset_x + 9 + 8, batt_offset_y + 1, batt_offset_x + 9 + 6, batt_offset_y + 1 + 5, theme[themeIdx].bg);
2371+
spr.drawLine(batt_offset_x + 9 + 6, batt_offset_y + 1 + 5, batt_offset_x + 9 + 10, batt_offset_y + 1 + 5, theme[themeIdx].bg);
2372+
spr.drawLine(batt_offset_x + 9 + 11, batt_offset_y + 1 + 6, batt_offset_x + 9 + 4, batt_offset_y + 1 + 13, theme[themeIdx].bg);
2373+
spr.drawLine(batt_offset_x + 9 + 2, batt_offset_y + 1 + 13, batt_offset_x + 9 + 4, batt_offset_y + 1 + 8, theme[themeIdx].bg);
2374+
spr.drawLine(batt_offset_x + 9 + 4, batt_offset_y + 1 + 8, batt_offset_x + 9 + 0, batt_offset_y + 1 + 8, theme[themeIdx].bg);
2375+
spr.drawLine(batt_offset_x + 9 - 1, batt_offset_y + 1 + 7, batt_offset_x + 9 + 6, batt_offset_y + 1 + 0, theme[themeIdx].bg);
2376+
spr.fillTriangle(batt_offset_x + 9 + 7, batt_offset_y + 1, batt_offset_x + 9 + 4, batt_offset_y + 1 + 6, batt_offset_x + 9, batt_offset_y + 1 + 7, theme[themeIdx].batt_icon);
2377+
spr.fillTriangle(batt_offset_x + 9 + 5, batt_offset_y + 1 + 6, batt_offset_x + 9 + 10, batt_offset_y + 1 + 6, batt_offset_x + 9 + 3, batt_offset_y + 1 + 13, theme[themeIdx].batt_icon);
2378+
spr.fillRect(batt_offset_x + 9 + 1, batt_offset_y + 1 + 6, 9, 2, theme[themeIdx].batt_icon);
2379+
spr.drawPixel(batt_offset_x + 9 + 3, batt_offset_y + 1 + 12, theme[themeIdx].batt_icon);
2380+
} else {
23732381
char voltage[8];
2374-
spr.fillRect(batt_offset_x + 1, batt_offset_y + 2, 28, 12, theme[themeIdx].bg);
2375-
spr.fillRect(batt_offset_x + 1, batt_offset_y + 2, chargeLevel, 12, batteryLevelColor);
2382+
spr.fillRoundRect(batt_offset_x + 2, batt_offset_y + 3, chargeLevel, 10, 2, batteryLevelColor);
23762383
sprintf(voltage, "%.02fV", adc_volt_avr);
23772384
spr.drawString(voltage, batt_offset_x - 3, batt_offset_y, 2);
23782385
}

changelog/11.changed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Redraw the battery indicator in iOS style

0 commit comments

Comments
 (0)