mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-08 22:22:05 +00:00
Bell Icon added
This commit is contained in:
parent
2a7059c86e
commit
b66d3d7157
@ -315,12 +315,16 @@ void Screen::showOverlayBanner(const String &message, uint32_t durationMs)
|
|||||||
static void drawAlertBannerOverlay(OLEDDisplay *display, OLEDDisplayUiState *state)
|
static void drawAlertBannerOverlay(OLEDDisplay *display, OLEDDisplayUiState *state)
|
||||||
{
|
{
|
||||||
// Exit if no message is active or duration has passed
|
// Exit if no message is active or duration has passed
|
||||||
if (alertBannerMessage.length() == 0 || (alertBannerUntil != 0 && millis() > alertBannerUntil)) return;
|
if (alertBannerMessage.length() == 0 || (alertBannerUntil != 0 && millis() > alertBannerUntil))
|
||||||
|
return;
|
||||||
|
|
||||||
// === Layout Configuration ===
|
// === Layout Configuration ===
|
||||||
constexpr uint16_t padding = 5; // Padding around text inside the box
|
constexpr uint16_t padding = 5; // Padding around text inside the box
|
||||||
constexpr uint8_t lineSpacing = 1; // Extra space between lines
|
constexpr uint8_t lineSpacing = 1; // Extra space between lines
|
||||||
|
|
||||||
|
// Search the mesage to determine if we need the bell added
|
||||||
|
bool needs_bell = (alertBannerMessage.indexOf("Alert Received") != -1);
|
||||||
|
|
||||||
// Setup font and alignment
|
// Setup font and alignment
|
||||||
display->setFont(FONT_SMALL);
|
display->setFont(FONT_SMALL);
|
||||||
display->setTextAlignment(TEXT_ALIGN_LEFT); // We will manually center per line
|
display->setTextAlignment(TEXT_ALIGN_LEFT); // We will manually center per line
|
||||||
@ -340,10 +344,14 @@ static void drawAlertBannerOverlay(OLEDDisplay *display, OLEDDisplayUiState *sta
|
|||||||
for (const auto &line : lines) {
|
for (const auto &line : lines) {
|
||||||
uint16_t w = display->getStringWidth(line.c_str(), line.length(), true);
|
uint16_t w = display->getStringWidth(line.c_str(), line.length(), true);
|
||||||
lineWidths.push_back(w);
|
lineWidths.push_back(w);
|
||||||
if (w > maxWidth) maxWidth = w;
|
if (w > maxWidth)
|
||||||
|
maxWidth = w;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t boxWidth = padding * 2 + maxWidth;
|
uint16_t boxWidth = padding * 2 + maxWidth;
|
||||||
|
if (needs_bell && boxWidth < 78)
|
||||||
|
boxWidth += 20;
|
||||||
|
|
||||||
uint16_t boxHeight = padding * 2 + lines.size() * FONT_HEIGHT_SMALL + (lines.size() - 1) * lineSpacing;
|
uint16_t boxHeight = padding * 2 + lines.size() * FONT_HEIGHT_SMALL + (lines.size() - 1) * lineSpacing;
|
||||||
|
|
||||||
int16_t boxLeft = (display->width() / 2) - (boxWidth / 2);
|
int16_t boxLeft = (display->width() / 2) - (boxWidth / 2);
|
||||||
@ -359,8 +367,16 @@ static void drawAlertBannerOverlay(OLEDDisplay *display, OLEDDisplayUiState *sta
|
|||||||
int16_t lineY = boxTop + padding;
|
int16_t lineY = boxTop + padding;
|
||||||
for (size_t i = 0; i < lines.size(); ++i) {
|
for (size_t i = 0; i < lines.size(); ++i) {
|
||||||
int16_t textX = boxLeft + (boxWidth - lineWidths[i]) / 2;
|
int16_t textX = boxLeft + (boxWidth - lineWidths[i]) / 2;
|
||||||
|
uint16_t line_width = display->getStringWidth(lines[i].c_str(), lines[i].length(), true);
|
||||||
|
|
||||||
|
if (needs_bell && i == 0) {
|
||||||
|
int bellY = lineY + (FONT_HEIGHT_SMALL - 8) / 2;
|
||||||
|
display->drawXbm(textX - 10, bellY, 8, 8, bell_alert);
|
||||||
|
display->drawXbm(textX + line_width + 2, bellY, 8, 8, bell_alert);
|
||||||
|
}
|
||||||
|
|
||||||
display->drawString(textX, lineY, lines[i]);
|
display->drawString(textX, lineY, lines[i]);
|
||||||
|
if (SCREEN_WIDTH > 128)
|
||||||
display->drawString(textX + 1, lineY, lines[i]); // Faux bold
|
display->drawString(textX + 1, lineY, lines[i]); // Faux bold
|
||||||
|
|
||||||
lineY += FONT_HEIGHT_SMALL + lineSpacing;
|
lineY += FONT_HEIGHT_SMALL + lineSpacing;
|
||||||
@ -3707,19 +3723,16 @@ void Screen::dismissCurrentFrame()
|
|||||||
memset(&devicestate.rx_text_message, 0, sizeof(devicestate.rx_text_message));
|
memset(&devicestate.rx_text_message, 0, sizeof(devicestate.rx_text_message));
|
||||||
dismissedFrames.textMessage = true;
|
dismissedFrames.textMessage = true;
|
||||||
dismissed = true;
|
dismissed = true;
|
||||||
}
|
} else if (currentFrame == framesetInfo.positions.waypoint && devicestate.has_rx_waypoint) {
|
||||||
else if (currentFrame == framesetInfo.positions.waypoint && devicestate.has_rx_waypoint) {
|
|
||||||
LOG_DEBUG("Dismiss Waypoint");
|
LOG_DEBUG("Dismiss Waypoint");
|
||||||
devicestate.has_rx_waypoint = false;
|
devicestate.has_rx_waypoint = false;
|
||||||
dismissedFrames.waypoint = true;
|
dismissedFrames.waypoint = true;
|
||||||
dismissed = true;
|
dismissed = true;
|
||||||
}
|
} else if (currentFrame == framesetInfo.positions.wifi) {
|
||||||
else if (currentFrame == framesetInfo.positions.wifi) {
|
|
||||||
LOG_DEBUG("Dismiss WiFi Screen");
|
LOG_DEBUG("Dismiss WiFi Screen");
|
||||||
dismissedFrames.wifi = true;
|
dismissedFrames.wifi = true;
|
||||||
dismissed = true;
|
dismissed = true;
|
||||||
}
|
} else if (currentFrame == framesetInfo.positions.memory) {
|
||||||
else if (currentFrame == framesetInfo.positions.memory) {
|
|
||||||
LOG_INFO("Dismiss Memory");
|
LOG_INFO("Dismiss Memory");
|
||||||
dismissedFrames.memory = true;
|
dismissedFrames.memory = true;
|
||||||
dismissed = true;
|
dismissed = true;
|
||||||
@ -3730,7 +3743,6 @@ void Screen::dismissCurrentFrame()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Screen::handleStartFirmwareUpdateScreen()
|
void Screen::handleStartFirmwareUpdateScreen()
|
||||||
{
|
{
|
||||||
LOG_DEBUG("Show firmware screen");
|
LOG_DEBUG("Show firmware screen");
|
||||||
@ -4239,7 +4251,8 @@ int Screen::handleTextMessage(const meshtastic_MeshPacket *packet)
|
|||||||
String banner;
|
String banner;
|
||||||
|
|
||||||
// Match bell character or exact alert text
|
// Match bell character or exact alert text
|
||||||
if (msg == "\x07" || msg.indexOf("Alert Bell Character") != -1) {
|
// if (msg == "\x07" || msg.indexOf("Alert Bell Character") != -1) {
|
||||||
|
if (msg.indexOf("\x07") != -1) {
|
||||||
banner = "Alert Received";
|
banner = "Alert Received";
|
||||||
} else {
|
} else {
|
||||||
banner = "New Message";
|
banner = "New Message";
|
||||||
@ -4250,14 +4263,13 @@ int Screen::handleTextMessage(const meshtastic_MeshPacket *packet)
|
|||||||
banner += longName;
|
banner += longName;
|
||||||
}
|
}
|
||||||
|
|
||||||
screen->showOverlayBanner(banner, 3000);
|
screen->showOverlayBanner(banner, 30000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Triggered by MeshModules
|
// Triggered by MeshModules
|
||||||
int Screen::handleUIFrameEvent(const UIFrameEvent *event)
|
int Screen::handleUIFrameEvent(const UIFrameEvent *event)
|
||||||
{
|
{
|
||||||
|
@ -389,6 +389,11 @@ const uint8_t icon_module[] PROGMEM = {
|
|||||||
0b00111100, // ░░████░░
|
0b00111100, // ░░████░░
|
||||||
0b00011000 // ░░░██░░░
|
0b00011000 // ░░░██░░░
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Bell icon for Alert Message
|
||||||
|
const unsigned char bell_alert[] PROGMEM = {0b00011000, 0b00100100, 0b00100100, 0b01000010,
|
||||||
|
0b01000010, 0b01000010, 0b11111111, 0b00011000};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "img/icon.xbm"
|
#include "img/icon.xbm"
|
||||||
|
Loading…
Reference in New Issue
Block a user