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