mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-21 04:22:22 +00:00
Pick up missed function
This commit is contained in:
parent
4dfe1ddab9
commit
ed2953eb4b
@ -196,6 +196,45 @@ void drawGpsCoordinates(OLEDDisplay *display, int16_t x, int16_t y, const meshta
|
||||
}
|
||||
}
|
||||
|
||||
void drawBattery(OLEDDisplay *display, int16_t x, int16_t y, uint8_t *imgBuffer, const meshtastic::PowerStatus *powerStatus)
|
||||
{
|
||||
static const uint8_t powerBar[3] = {0x81, 0xBD, 0xBD};
|
||||
static const uint8_t lightning[8] = {0xA1, 0xA1, 0xA5, 0xAD, 0xB5, 0xA5, 0x85, 0x85};
|
||||
|
||||
// Clear the bar area inside the battery image
|
||||
for (int i = 1; i < 14; i++) {
|
||||
imgBuffer[i] = 0x81;
|
||||
}
|
||||
|
||||
// Fill with lightning or power bars
|
||||
if (powerStatus->getIsCharging()) {
|
||||
memcpy(imgBuffer + 3, lightning, 8);
|
||||
} else {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if (powerStatus->getBatteryChargePercent() >= 25 * i)
|
||||
memcpy(imgBuffer + 1 + (i * 3), powerBar, 3);
|
||||
}
|
||||
}
|
||||
|
||||
// Slightly more conservative scaling based on screen width
|
||||
int scale = 1;
|
||||
|
||||
if (SCREEN_WIDTH >= 200)
|
||||
scale = 2;
|
||||
if (SCREEN_WIDTH >= 300)
|
||||
scale = 2; // Do NOT go higher than 2
|
||||
|
||||
// Draw scaled battery image (16 columns × 8 rows)
|
||||
for (int col = 0; col < 16; col++) {
|
||||
uint8_t colBits = imgBuffer[col];
|
||||
for (int row = 0; row < 8; row++) {
|
||||
if (colBits & (1 << row)) {
|
||||
display->fillRect(x + col * scale, y + row * scale, scale, scale);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Draw nodes status
|
||||
void drawNodes(OLEDDisplay *display, int16_t x, int16_t y, const meshtastic::NodeStatus *nodeStatus, int node_offset,
|
||||
bool show_total, String additional_words)
|
||||
|
@ -31,7 +31,7 @@ class Screen;
|
||||
namespace UIRenderer
|
||||
{
|
||||
// Common UI elements
|
||||
void drawCommonHeader(OLEDDisplay *display, int16_t x, int16_t y);
|
||||
// void drawCommonHeader(OLEDDisplay *display, int16_t x, int16_t y);
|
||||
void drawBattery(OLEDDisplay *display, int16_t x, int16_t y, uint8_t *imgBuffer, const meshtastic::PowerStatus *powerStatus);
|
||||
void drawNodes(OLEDDisplay *display, int16_t x, int16_t y, const meshtastic::NodeStatus *nodeStatus, int node_offset = 0,
|
||||
bool show_total = true, String additional_words = "");
|
||||
|
Loading…
Reference in New Issue
Block a user