mirror of
https://github.com/ttrftech/NanoVNA.git
synced 2026-04-05 06:25:36 +00:00
show battery indicator (requires implementing D2 on board)
This commit is contained in:
parent
ec8c53bde3
commit
a9457dbd0a
4 changed files with 127 additions and 1 deletions
70
plot.c
70
plot.c
|
|
@ -1484,6 +1484,76 @@ draw_cal_status(void)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
draw_battery_status(void)
|
||||
{
|
||||
int w = 10, h = 14;
|
||||
int x = 0, y = 0;
|
||||
int i, c;
|
||||
uint16_t *buf = spi_buffer;
|
||||
uint8_t vbati = vbat2bati(vbat);
|
||||
uint16_t col = vbati == 0 ? RGB565(0, 255, 0) : RGB565(0, 0, 240);
|
||||
memset(spi_buffer, 0, w * h * 2);
|
||||
|
||||
// battery head
|
||||
x = 3;
|
||||
buf[y * w + x++] = col;
|
||||
buf[y * w + x++] = col;
|
||||
buf[y * w + x++] = col;
|
||||
buf[y * w + x++] = col;
|
||||
|
||||
y++;
|
||||
x = 3;
|
||||
buf[y * w + x++] = col;
|
||||
x++; x++;
|
||||
buf[y * w + x++] = col;
|
||||
|
||||
y++;
|
||||
x = 1;
|
||||
for (i = 0; i < 8; i++)
|
||||
buf[y * w + x++] = col;
|
||||
|
||||
for (c = 0; c < 3; c++) {
|
||||
y++;
|
||||
x = 1;
|
||||
buf[y * w + x++] = col;
|
||||
x++; x++; x++; x++; x++; x++;
|
||||
buf[y * w + x++] = col;
|
||||
|
||||
y++;
|
||||
x = 1;
|
||||
buf[y * w + x++] = col;
|
||||
x++;
|
||||
for (i = 0; i < 4; i++)
|
||||
buf[y * w + x++] = ( ((c+1) * 25) >= (100 - vbati)) ? col : 0;
|
||||
x++;
|
||||
buf[y * w + x++] = col;
|
||||
|
||||
y++;
|
||||
x = 1;
|
||||
buf[y * w + x++] = col;
|
||||
x++;
|
||||
for (i = 0; i < 4; i++)
|
||||
buf[y * w + x++] = ( ((c+1) * 25) >= (100 - vbati)) ? col : 0;
|
||||
x++;
|
||||
buf[y * w + x++] = col;
|
||||
}
|
||||
|
||||
// battery foot
|
||||
y++;
|
||||
x = 1;
|
||||
buf[y * w + x++] = col;
|
||||
x++; x++; x++; x++; x++; x++;
|
||||
buf[y * w + x++] = col;
|
||||
|
||||
y++;
|
||||
x = 1;
|
||||
for (i = 0; i < 8; i++)
|
||||
buf[y * w + x++] = col;
|
||||
|
||||
ili9341_bulk(0, 1, w, h);
|
||||
}
|
||||
|
||||
void
|
||||
request_to_redraw_grid(void)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue