mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-10 07:02:11 +00:00
Move title into drawCommonHeader; initial screen tested
This commit is contained in:
parent
6746fe2387
commit
e7f153ae48
@ -40,7 +40,7 @@ void drawRoundedHighlight(OLEDDisplay *display, int16_t x, int16_t y, int16_t w,
|
|||||||
// *************************
|
// *************************
|
||||||
// * Common Header Drawing *
|
// * Common Header Drawing *
|
||||||
// *************************
|
// *************************
|
||||||
void drawCommonHeader(OLEDDisplay *display, int16_t x, int16_t y)
|
void drawCommonHeader(OLEDDisplay *display, int16_t x, int16_t y, const char *titleStr)
|
||||||
{
|
{
|
||||||
constexpr int HEADER_OFFSET_Y = 1;
|
constexpr int HEADER_OFFSET_Y = 1;
|
||||||
y += HEADER_OFFSET_Y;
|
y += HEADER_OFFSET_Y;
|
||||||
@ -70,6 +70,14 @@ void drawCommonHeader(OLEDDisplay *display, int16_t x, int16_t y)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// === Screen Title ===
|
||||||
|
display->setTextAlignment(TEXT_ALIGN_CENTER);
|
||||||
|
display->drawString(SCREEN_WIDTH / 2, y, titleStr);
|
||||||
|
if (config.display.heading_bold) {
|
||||||
|
display->drawString((SCREEN_WIDTH / 2) + 1, y, titleStr);
|
||||||
|
}
|
||||||
|
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
||||||
|
|
||||||
// === 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;
|
||||||
@ -156,7 +164,7 @@ void drawCommonHeader(OLEDDisplay *display, int16_t x, int16_t y)
|
|||||||
timeX = screenW - xOffset - timeStrWidth + 4;
|
timeX = screenW - xOffset - timeStrWidth + 4;
|
||||||
|
|
||||||
// === Show Mail or Mute Icon to the Left of Time ===
|
// === Show Mail or Mute Icon to the Left of Time ===
|
||||||
int iconRightEdge = timeX - 2;
|
int iconRightEdge = timeX;
|
||||||
|
|
||||||
bool showMail = false;
|
bool showMail = false;
|
||||||
|
|
||||||
@ -180,30 +188,59 @@ void drawCommonHeader(OLEDDisplay *display, int16_t x, int16_t y)
|
|||||||
int iconX = iconRightEdge - iconW;
|
int iconX = iconRightEdge - iconW;
|
||||||
int iconY = textY + (FONT_HEIGHT_SMALL - iconH) / 2 - 1;
|
int iconY = textY + (FONT_HEIGHT_SMALL - iconH) / 2 - 1;
|
||||||
if (isInverted) {
|
if (isInverted) {
|
||||||
display->setColor(BLACK);
|
|
||||||
display->drawRect(iconX - 1, iconY - 1, iconW + 3, iconH + 2);
|
|
||||||
display->setColor(WHITE);
|
display->setColor(WHITE);
|
||||||
|
display->fillRect(iconX - 1, iconY - 1, iconW + 3, iconH + 2);
|
||||||
|
display->setColor(BLACK);
|
||||||
} else {
|
} else {
|
||||||
display->setColor(WHITE);
|
|
||||||
display->drawRect(iconX - 1, iconY - 1, iconW + 3, iconH + 2);
|
|
||||||
display->setColor(BLACK);
|
display->setColor(BLACK);
|
||||||
|
display->fillRect(iconX - 1, iconY - 1, iconW + 3, iconH + 2);
|
||||||
|
display->setColor(WHITE);
|
||||||
}
|
}
|
||||||
display->drawRect(iconX, iconY, iconW + 1, iconH);
|
display->drawRect(iconX, iconY, iconW + 1, iconH);
|
||||||
display->drawLine(iconX, iconY, iconX + iconW / 2, iconY + iconH - 4);
|
display->drawLine(iconX, iconY, iconX + iconW / 2, iconY + iconH - 4);
|
||||||
display->drawLine(iconX + iconW, iconY, iconX + iconW / 2, iconY + iconH - 4);
|
display->drawLine(iconX + iconW, iconY, iconX + iconW / 2, iconY + iconH - 4);
|
||||||
} else {
|
} else {
|
||||||
int iconX = iconRightEdge - mail_width;
|
int iconX = iconRightEdge - (mail_width - 2);
|
||||||
int iconY = textY + (FONT_HEIGHT_SMALL - mail_height) / 2;
|
int iconY = textY + (FONT_HEIGHT_SMALL - mail_height) / 2;
|
||||||
|
if (isInverted) {
|
||||||
|
display->setColor(WHITE);
|
||||||
|
display->fillRect(iconX - 1, iconY - 1, mail_width + 2, mail_height + 2);
|
||||||
|
display->setColor(BLACK);
|
||||||
|
} else {
|
||||||
|
display->setColor(BLACK);
|
||||||
|
display->fillRect(iconX - 1, iconY - 1, mail_width + 2, mail_height + 2);
|
||||||
|
display->setColor(WHITE);
|
||||||
|
}
|
||||||
display->drawXbm(iconX, iconY, mail_width, mail_height, mail);
|
display->drawXbm(iconX, iconY, mail_width, mail_height, mail);
|
||||||
}
|
}
|
||||||
} else if (isMuted) {
|
} else if (isMuted) {
|
||||||
if (useBigIcons) {
|
if (useBigIcons) {
|
||||||
int iconX = iconRightEdge - mute_symbol_big_width;
|
int iconX = iconRightEdge - mute_symbol_big_width;
|
||||||
int iconY = textY + (FONT_HEIGHT_SMALL - mute_symbol_big_height) / 2;
|
int iconY = textY + (FONT_HEIGHT_SMALL - mute_symbol_big_height) / 2;
|
||||||
|
|
||||||
|
if (isInverted) {
|
||||||
|
display->setColor(WHITE);
|
||||||
|
display->fillRect(iconX - 1, iconY - 1, mute_symbol_big_width + 2, mute_symbol_big_height + 2);
|
||||||
|
display->setColor(BLACK);
|
||||||
|
} else {
|
||||||
|
display->setColor(BLACK);
|
||||||
|
display->fillRect(iconX - 1, iconY - 1, mute_symbol_big_width + 2, mute_symbol_big_height + 2);
|
||||||
|
display->setColor(WHITE);
|
||||||
|
}
|
||||||
display->drawXbm(iconX, iconY, mute_symbol_big_width, mute_symbol_big_height, mute_symbol_big);
|
display->drawXbm(iconX, iconY, mute_symbol_big_width, mute_symbol_big_height, mute_symbol_big);
|
||||||
} else {
|
} else {
|
||||||
int iconX = iconRightEdge - mute_symbol_width;
|
int iconX = iconRightEdge - mute_symbol_width;
|
||||||
int iconY = textY + (FONT_HEIGHT_SMALL - mail_height) / 2;
|
int iconY = textY + (FONT_HEIGHT_SMALL - mail_height) / 2;
|
||||||
|
|
||||||
|
if (isInverted) {
|
||||||
|
display->setColor(WHITE);
|
||||||
|
display->fillRect(iconX - 1, iconY - 1, mute_symbol_width + 2, mute_symbol_height + 2);
|
||||||
|
display->setColor(BLACK);
|
||||||
|
} else {
|
||||||
|
display->setColor(BLACK);
|
||||||
|
display->fillRect(iconX - 1, iconY - 1, mute_symbol_width + 2, mute_symbol_height + 2);
|
||||||
|
display->setColor(WHITE);
|
||||||
|
}
|
||||||
display->drawXbm(iconX, iconY, mute_symbol_width, mute_symbol_height, mute_symbol);
|
display->drawXbm(iconX, iconY, mute_symbol_width, mute_symbol_height, mute_symbol);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,6 @@ extern bool isMuted;
|
|||||||
void drawRoundedHighlight(OLEDDisplay *display, int16_t x, int16_t y, int16_t w, int16_t h, int16_t r);
|
void drawRoundedHighlight(OLEDDisplay *display, int16_t x, int16_t y, int16_t w, int16_t h, int16_t r);
|
||||||
|
|
||||||
// Shared battery/time/mail header
|
// Shared battery/time/mail header
|
||||||
void drawCommonHeader(OLEDDisplay *display, int16_t x, int16_t y);
|
void drawCommonHeader(OLEDDisplay *display, int16_t x, int16_t y, const char *titleStr = "");
|
||||||
|
|
||||||
} // namespace graphics
|
} // namespace graphics
|
||||||
|
@ -431,25 +431,7 @@ void drawNodeListScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t
|
|||||||
display->clear();
|
display->clear();
|
||||||
|
|
||||||
// Draw the battery/time header
|
// Draw the battery/time header
|
||||||
graphics::drawCommonHeader(display, x, y);
|
graphics::drawCommonHeader(display, x, y, title);
|
||||||
|
|
||||||
// Draw the centered title within the header
|
|
||||||
const int highlightHeight = COMMON_HEADER_HEIGHT;
|
|
||||||
const int textY = y + 1 + (highlightHeight - FONT_HEIGHT_SMALL) / 2;
|
|
||||||
const int centerX = x + SCREEN_WIDTH / 2;
|
|
||||||
|
|
||||||
display->setFont(FONT_SMALL);
|
|
||||||
display->setTextAlignment(TEXT_ALIGN_CENTER);
|
|
||||||
|
|
||||||
if (config.display.displaymode != meshtastic_Config_DisplayConfig_DisplayMode_INVERTED)
|
|
||||||
display->setColor(BLACK);
|
|
||||||
|
|
||||||
display->drawString(centerX, textY, title);
|
|
||||||
if (config.display.heading_bold)
|
|
||||||
display->drawString(centerX + 1, textY, title);
|
|
||||||
|
|
||||||
display->setColor(WHITE);
|
|
||||||
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
|
||||||
|
|
||||||
// Space below header
|
// Space below header
|
||||||
y += COMMON_HEADER_HEIGHT;
|
y += COMMON_HEADER_HEIGHT;
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
namespace graphics
|
namespace graphics
|
||||||
{
|
{
|
||||||
extern void drawCommonHeader(OLEDDisplay *display, int16_t x, int16_t y);
|
extern void drawCommonHeader(OLEDDisplay *display, int16_t x, int16_t y, const char *titleStr);
|
||||||
}
|
}
|
||||||
#if __has_include(<Adafruit_AHTX0.h>)
|
#if __has_include(<Adafruit_AHTX0.h>)
|
||||||
#include "Sensor/AHT10.h"
|
#include "Sensor/AHT10.h"
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
namespace graphics
|
namespace graphics
|
||||||
{
|
{
|
||||||
extern void drawCommonHeader(OLEDDisplay *display, int16_t x, int16_t y);
|
extern void drawCommonHeader(OLEDDisplay *display, int16_t x, int16_t y, const char *titleStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t PowerTelemetryModule::runOnce()
|
int32_t PowerTelemetryModule::runOnce()
|
||||||
|
Loading…
Reference in New Issue
Block a user