mirror of
https://github.com/meshtastic/firmware.git
synced 2025-08-03 04:15:53 +00:00
Rebuild Horizontal Battery, Resolve overlap concerns
This commit is contained in:
parent
766189212c
commit
5ca5ee2846
@ -84,6 +84,9 @@ void drawCommonHeader(OLEDDisplay *display, int16_t x, int16_t y, const char *ti
|
||||
// === Battery State ===
|
||||
int chargePercent = powerStatus->getBatteryChargePercent();
|
||||
bool isCharging = powerStatus->getIsCharging() == meshtastic::OptionalBool::OptTrue;
|
||||
if (chargePercent == 100) {
|
||||
isCharging = false;
|
||||
}
|
||||
uint32_t now = millis();
|
||||
|
||||
#ifndef USE_EINK
|
||||
@ -99,14 +102,16 @@ void drawCommonHeader(OLEDDisplay *display, int16_t x, int16_t y, const char *ti
|
||||
// === Battery Icons ===
|
||||
if (useHorizontalBattery) {
|
||||
int batteryX = 2;
|
||||
int batteryY = HEADER_OFFSET_Y + 2;
|
||||
display->drawXbm(batteryX, batteryY, 29, 15, batteryBitmap_h);
|
||||
int batteryY = HEADER_OFFSET_Y + 3;
|
||||
display->drawXbm(batteryX, batteryY, 9, 13, batteryBitmap_h_bottom);
|
||||
display->drawXbm(batteryX + 9, batteryY, 9, 13, batteryBitmap_h_top);
|
||||
if (isCharging && isBoltVisibleShared)
|
||||
display->drawXbm(batteryX + 9, batteryY + 1, 9, 13, lightning_bolt_h);
|
||||
display->drawXbm(batteryX + 4, batteryY, 9, 13, lightning_bolt_h);
|
||||
else {
|
||||
display->drawXbm(batteryX + 8, batteryY, 12, 15, batteryBitmap_sidegaps_h);
|
||||
int fillWidth = 24 * chargePercent / 100;
|
||||
display->fillRect(batteryX + 1, batteryY + 1, fillWidth, 13);
|
||||
display->drawLine(batteryX + 5, batteryY, batteryX + 10, batteryY);
|
||||
display->drawLine(batteryX + 5, batteryY + 12, batteryX + 10, batteryY + 12);
|
||||
int fillWidth = 14 * chargePercent / 100;
|
||||
display->fillRect(batteryX + 1, batteryY + 1, fillWidth, 11);
|
||||
}
|
||||
} else {
|
||||
int batteryX = 1;
|
||||
@ -129,12 +134,8 @@ void drawCommonHeader(OLEDDisplay *display, int16_t x, int16_t y, const char *ti
|
||||
char chargeStr[4];
|
||||
snprintf(chargeStr, sizeof(chargeStr), "%d", chargePercent);
|
||||
int chargeNumWidth = display->getStringWidth(chargeStr);
|
||||
const int batteryOffset = useHorizontalBattery ? 28 : 6;
|
||||
#ifdef USE_EINK
|
||||
const int percentX = x + xOffset + batteryOffset - 2;
|
||||
#else
|
||||
const int percentX = x + xOffset + batteryOffset;
|
||||
#endif
|
||||
const int batteryOffset = useHorizontalBattery ? 19 : 9;
|
||||
const int percentX = x + batteryOffset;
|
||||
display->drawString(percentX, textY, chargeStr);
|
||||
display->drawString(percentX + chargeNumWidth - 1, textY, "%");
|
||||
if (isBold) {
|
||||
@ -164,7 +165,7 @@ void drawCommonHeader(OLEDDisplay *display, int16_t x, int16_t y, const char *ti
|
||||
}
|
||||
|
||||
timeStrWidth = display->getStringWidth(timeStr);
|
||||
timeX = screenW - xOffset - timeStrWidth + 4;
|
||||
timeX = screenW - xOffset - timeStrWidth + 3;
|
||||
|
||||
// === Show Mail or Mute Icon to the Left of Time ===
|
||||
int iconRightEdge = timeX - 1;
|
||||
|
@ -80,7 +80,11 @@ const char *getCurrentModeTitle(int screenWidth)
|
||||
case MODE_LAST_HEARD:
|
||||
return "Last Heard";
|
||||
case MODE_HOP_SIGNAL:
|
||||
#ifdef USE_EINK
|
||||
return "Hops/Sig";
|
||||
#else
|
||||
return (screenWidth > 128) ? "Hops/Signal" : "Hops/Sig";
|
||||
#endif
|
||||
case MODE_DISTANCE:
|
||||
return "Distance";
|
||||
default:
|
||||
@ -533,7 +537,12 @@ void drawLastHeardScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int16_
|
||||
|
||||
void drawHopSignalScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
|
||||
{
|
||||
#ifdef USE_EINK
|
||||
const char *title = "Hops/Sig";
|
||||
#else
|
||||
|
||||
const char *title = "Hops/Signal";
|
||||
#endif
|
||||
drawNodeListScreen(display, state, x, y, title, drawEntryHopSignal);
|
||||
}
|
||||
|
||||
|
@ -45,19 +45,15 @@ const uint8_t imgSF[] PROGMEM = {0xd2, 0xb7, 0xad, 0xbb, 0x92, 0x01, 0xfd, 0xfd,
|
||||
|
||||
// === Horizontal battery ===
|
||||
// Basic battery design and all related pieces
|
||||
const unsigned char batteryBitmap_h[] PROGMEM = {
|
||||
0b11111110, 0b00000000, 0b11110000, 0b00000111, 0b00000001, 0b00000000, 0b00000000, 0b00001000, 0b00000001, 0b00000000,
|
||||
0b00000000, 0b00001000, 0b00000001, 0b00000000, 0b00000000, 0b00001000, 0b00000001, 0b00000000, 0b00000000, 0b00001000,
|
||||
0b00000001, 0b00000000, 0b00000000, 0b00011000, 0b00000001, 0b00000000, 0b00000000, 0b00011000, 0b00000001, 0b00000000,
|
||||
0b00000000, 0b00011000, 0b00000001, 0b00000000, 0b00000000, 0b00011000, 0b00000001, 0b00000000, 0b00000000, 0b00011000,
|
||||
0b00000001, 0b00000000, 0b00000000, 0b00001000, 0b00000001, 0b00000000, 0b00000000, 0b00001000, 0b00000001, 0b00000000,
|
||||
0b00000000, 0b00001000, 0b00000001, 0b00000000, 0b00000000, 0b00001000, 0b11111110, 0b00000000, 0b11110000, 0b00000111};
|
||||
const unsigned char batteryBitmap_h_bottom[] PROGMEM = {
|
||||
0b00011110, 0b00000000, 0b00000001, 0b00000000, 0b00000001, 0b00000000, 0b00000001, 0b00000000, 0b00000001,
|
||||
0b00000000, 0b00000001, 0b00000000, 0b00000001, 0b00000000, 0b00000001, 0b00000000, 0b00000001, 0b00000000,
|
||||
0b00000001, 0b00000000, 0b00000001, 0b00000000, 0b00000001, 0b00000000, 0b00011110, 0b00000000};
|
||||
|
||||
// This is the left and right bars for the fill in
|
||||
const unsigned char batteryBitmap_sidegaps_h[] PROGMEM = {
|
||||
0b11111111, 0b00001111, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000,
|
||||
0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000,
|
||||
0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b11111111, 0b00001111};
|
||||
const unsigned char batteryBitmap_h_top[] PROGMEM = {
|
||||
0b00111100, 0b00000000, 0b01000000, 0b00000000, 0b01000000, 0b00000000, 0b01000000, 0b00000000, 0b01000000,
|
||||
0b00000000, 0b11000000, 0b00000000, 0b11000000, 0b00000000, 0b11000000, 0b00000000, 0b01000000, 0b00000000,
|
||||
0b01000000, 0b00000000, 0b01000000, 0b00000000, 0b01000000, 0b00000000, 0b00111100, 0b00000000};
|
||||
|
||||
// Lightning Bolt
|
||||
const unsigned char lightning_bolt_h[] PROGMEM = {
|
||||
|
Loading…
Reference in New Issue
Block a user