This commit is contained in:
HarukiToreda 2025-04-08 11:19:13 -04:00
parent 383ae7a82f
commit ebea34520d
2 changed files with 71 additions and 98 deletions

View File

@ -1022,18 +1022,8 @@ void drawCommonHeader(OLEDDisplay *display, int16_t x, int16_t y)
display->setColor(BLACK);
}
// === Text baseline ===
const int textY = y + (highlightHeight - FONT_HEIGHT_SMALL) / 2;
// === Battery Vertical and Horizontal ===
const int nubSize = 2;
const int batteryShort = highlightHeight - nubSize - 2;
int batteryX = x + xOffset;
int batteryY = y + (highlightHeight - batteryShort) / 2 + nubSize;
int chargePercent = powerStatus->getBatteryChargePercent();
bool isCharging = powerStatus->getIsCharging() == OptionalBool::OptTrue;
uint32_t now = millis();
if (isCharging && now - lastBlink > blinkInterval) {
@ -1046,90 +1036,43 @@ void drawCommonHeader(OLEDDisplay *display, int16_t x, int16_t y)
if (useHorizontalBattery) {
// === Horizontal battery ===
batteryX = 2;
batteryY = 4;
// Basic battery design and all related pieces
const unsigned char batteryBitmap[] 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};
int batteryX = 2;
int batteryY = 4;
// This is the left and right bars for the fill in
const unsigned char batteryBitmap_sidegaps[] 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};
// Lightning Bolt
const unsigned char lightning_bolt[] PROGMEM = {
0b11110000, 0b00000000, 0b11110000, 0b00000000, 0b01110000, 0b00000000, 0b00111000, 0b00000000, 0b00111100,
0b00000000, 0b11111100, 0b00000000, 0b01111110, 0b00000000, 0b00111000, 0b00000000, 0b00110000, 0b00000000,
0b00010000, 0b00000000, 0b00010000, 0b00000000, 0b00001000, 0b00000000, 0b00001000, 0b00000000};
display->drawXbm(batteryX, batteryY, 29, 15, batteryBitmap);
display->drawXbm(batteryX, batteryY, 29, 15, batteryBitmap_h);
if (isCharging && isBoltVisible) {
display->drawXbm(batteryX + 9, batteryY + 1, 9, 13, lightning_bolt);
display->drawXbm(batteryX + 9, batteryY + 1, 9, 13, lightning_bolt_h);
} else if (isCharging && !isBoltVisible) {
display->drawXbm(batteryX + 8, batteryY, 12, 15, batteryBitmap_sidegaps);
} else if (!isCharging) {
display->drawXbm(batteryX + 8, batteryY, 12, 15, batteryBitmap_sidegaps);
display->drawXbm(batteryX + 8, batteryY, 12, 15, batteryBitmap_sidegaps_h);
} else {
display->drawXbm(batteryX + 8, batteryY, 12, 15, batteryBitmap_sidegaps_h);
int fillWidth = 24 * chargePercent / 100;
int fillX = batteryX + fillWidth;
display->fillRect(batteryX + 1, batteryY + 1, fillX, 13);
}
} else {
// === Vertical battery ===
batteryX = 1;
batteryY = 3;
// Basic battery design and all related pieces
const unsigned char batteryBitmap[] PROGMEM = {
0b00011100, // ..###..
0b00111110, // .#####.
0b01000001, // #.....#
0b01000001, // #.....#
0b00000000, // .......
0b00000000, // .......
0b00000000, // .......
0b01000001, // #.....#
0b01000001, // #.....#
0b01000001, // #.....#
0b00111110 // .#####.
};
// This is the left and right bars for the fill in
const unsigned char batteryBitmap_sidegaps[] PROGMEM = {
0b10000010, // #.....#
0b10000010, // #.....#
0b10000010, // #.....#
};
// Lightning Bolt
const unsigned char lightning_bolt[] PROGMEM = {
0b00000100, // Column 0
0b00000110, // Column 1
0b00011111, // Column 2
0b00001100, // Column 3
0b00000100 // Column 4
};
int batteryX = 1;
int batteryY = 3;
display->drawXbm(batteryX, batteryY, 7, 11, batteryBitmap);
display->drawXbm(batteryX, batteryY, 7, 11, batteryBitmap_v);
if (isCharging && isBoltVisible) {
display->drawXbm(batteryX + 1, batteryY + 3, 5, 5, lightning_bolt);
display->drawXbm(batteryX + 1, batteryY + 3, 5, 5, lightning_bolt_v);
} else if (isCharging && !isBoltVisible) {
display->drawXbm(batteryX - 1, batteryY + 4, 8, 3, batteryBitmap_sidegaps);
} else if (!isCharging) {
display->drawXbm(batteryX - 1, batteryY + 4, 8, 3, batteryBitmap_sidegaps);
display->drawXbm(batteryX - 1, batteryY + 4, 8, 3, batteryBitmap_sidegaps_v);
} else {
display->drawXbm(batteryX - 1, batteryY + 4, 8, 3, batteryBitmap_sidegaps_v);
int fillHeight = 8 * chargePercent / 100;
int fillY = batteryY - fillHeight;
display->fillRect(batteryX + 1, fillY + 10, 5, fillHeight);
}
}
// === Text baseline ===
const int textY = y + (highlightHeight - FONT_HEIGHT_SMALL) / 2;
// === Battery % Text ===
char chargeStr[4];
snprintf(chargeStr, sizeof(chargeStr), "%d", chargePercent);
@ -4091,7 +4034,6 @@ int Screen::handleStatusUpdate(const meshtastic::Status *arg)
return 0;
}
// Handles when message is received would jump to text message frame.
int Screen::handleTextMessage(const meshtastic_MeshPacket *packet)
{

View File

@ -37,6 +37,37 @@ const uint8_t imgQuestion[] PROGMEM = {0xbf, 0x41, 0xc0, 0x8b, 0xdb, 0x70, 0xa1,
const uint8_t imgSF[] PROGMEM = {0xd2, 0xb7, 0xad, 0xbb, 0x92, 0x01, 0xfd, 0xfd, 0x15, 0x85, 0xf5};
#endif
// === 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};
// 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};
// Lightning Bolt
const unsigned char lightning_bolt_h[] PROGMEM = {
0b11110000, 0b00000000, 0b11110000, 0b00000000, 0b01110000, 0b00000000, 0b00111000, 0b00000000, 0b00111100,
0b00000000, 0b11111100, 0b00000000, 0b01111110, 0b00000000, 0b00111000, 0b00000000, 0b00110000, 0b00000000,
0b00010000, 0b00000000, 0b00010000, 0b00000000, 0b00001000, 0b00000000, 0b00001000, 0b00000000};
// === Vertical battery ===
// Basic battery design and all related pieces
const unsigned char batteryBitmap_v[] PROGMEM = {0b00011100, 0b00111110, 0b01000001, 0b01000001, 0b00000000, 0b00000000,
0b00000000, 0b01000001, 0b01000001, 0b01000001, 0b00111110};
// This is the left and right bars for the fill in
const unsigned char batteryBitmap_sidegaps_v[] PROGMEM = {0b10000010, 0b10000010, 0b10000010};
// Lightning Bolt
const unsigned char lightning_bolt_v[] PROGMEM = {0b00000100, 0b00000110, 0b00011111, 0b00001100, 0b00000100};
#ifndef EXCLUDE_EMOJI
#define thumbs_height 25
#define thumbs_width 25