mirror of
https://github.com/alexhopeoconnor/firmware.git
synced 2026-10-21 18:52:36 +10:00
I thought git would be smart enough to understand all the whitespace changes but even with all the flags I know to make it ignore theses it still blows up if there are identical changes on both sides.
I have a solution but it require creating a new commit at the merge base for each conflicting PR and merging it into develop.
I don't think blowing up all PRs is worth for now, maybe if we can coordinate this for V3 let's say.
This reverts commit 0d11331d18.
This commit is contained in:
@@ -4,127 +4,136 @@
|
||||
|
||||
using namespace NicheGraphics;
|
||||
|
||||
void InkHUD::AllMessageApplet::onActivate() { textMessageObserver.observe(textMessageModule); }
|
||||
void InkHUD::AllMessageApplet::onActivate()
|
||||
{
|
||||
textMessageObserver.observe(textMessageModule);
|
||||
}
|
||||
|
||||
void InkHUD::AllMessageApplet::onDeactivate() { textMessageObserver.unobserve(textMessageModule); }
|
||||
void InkHUD::AllMessageApplet::onDeactivate()
|
||||
{
|
||||
textMessageObserver.unobserve(textMessageModule);
|
||||
}
|
||||
|
||||
// We're not consuming the data passed to this method;
|
||||
// we're just just using it to trigger a render
|
||||
int InkHUD::AllMessageApplet::onReceiveTextMessage(const meshtastic_MeshPacket *p) {
|
||||
// Abort if applet fully deactivated
|
||||
// Already handled by onActivate and onDeactivate, but good practice for all applets
|
||||
if (!isActive())
|
||||
int InkHUD::AllMessageApplet::onReceiveTextMessage(const meshtastic_MeshPacket *p)
|
||||
{
|
||||
// Abort if applet fully deactivated
|
||||
// Already handled by onActivate and onDeactivate, but good practice for all applets
|
||||
if (!isActive())
|
||||
return 0;
|
||||
|
||||
// Abort if this is an outgoing message
|
||||
if (getFrom(p) == nodeDB->getNodeNum())
|
||||
return 0;
|
||||
|
||||
requestAutoshow(); // Want to become foreground, if permitted
|
||||
requestUpdate(); // Want to update display, if applet is foreground
|
||||
|
||||
// Return zero: no issues here, carry on notifying other observers!
|
||||
return 0;
|
||||
|
||||
// Abort if this is an outgoing message
|
||||
if (getFrom(p) == nodeDB->getNodeNum())
|
||||
return 0;
|
||||
|
||||
requestAutoshow(); // Want to become foreground, if permitted
|
||||
requestUpdate(); // Want to update display, if applet is foreground
|
||||
|
||||
// Return zero: no issues here, carry on notifying other observers!
|
||||
return 0;
|
||||
}
|
||||
|
||||
void InkHUD::AllMessageApplet::onRender() {
|
||||
// Find newest message, regardless of whether DM or broadcast
|
||||
MessageStore::Message *message;
|
||||
if (latestMessage->wasBroadcast)
|
||||
message = &latestMessage->broadcast;
|
||||
else
|
||||
message = &latestMessage->dm;
|
||||
void InkHUD::AllMessageApplet::onRender()
|
||||
{
|
||||
// Find newest message, regardless of whether DM or broadcast
|
||||
MessageStore::Message *message;
|
||||
if (latestMessage->wasBroadcast)
|
||||
message = &latestMessage->broadcast;
|
||||
else
|
||||
message = &latestMessage->dm;
|
||||
|
||||
// Short circuit: no text message
|
||||
if (!message->sender) {
|
||||
printAt(X(0.5), Y(0.5), "No Message", CENTER, MIDDLE);
|
||||
return;
|
||||
}
|
||||
// Short circuit: no text message
|
||||
if (!message->sender) {
|
||||
printAt(X(0.5), Y(0.5), "No Message", CENTER, MIDDLE);
|
||||
return;
|
||||
}
|
||||
|
||||
// ===========================
|
||||
// Header (sender, timestamp)
|
||||
// ===========================
|
||||
// ===========================
|
||||
// Header (sender, timestamp)
|
||||
// ===========================
|
||||
|
||||
// Y position for divider
|
||||
// - between header text and messages
|
||||
// Y position for divider
|
||||
// - between header text and messages
|
||||
|
||||
std::string header;
|
||||
std::string header;
|
||||
|
||||
// RX Time
|
||||
// - if valid
|
||||
std::string timeString = getTimeString(message->timestamp);
|
||||
if (timeString.length() > 0) {
|
||||
header += timeString;
|
||||
header += ": ";
|
||||
}
|
||||
// RX Time
|
||||
// - if valid
|
||||
std::string timeString = getTimeString(message->timestamp);
|
||||
if (timeString.length() > 0) {
|
||||
header += timeString;
|
||||
header += ": ";
|
||||
}
|
||||
|
||||
// Sender's id
|
||||
// - short name and long name, if available, or
|
||||
// - node id
|
||||
meshtastic_NodeInfoLite *sender = nodeDB->getMeshNode(message->sender);
|
||||
if (sender && sender->has_user) {
|
||||
header += parseShortName(sender); // May be last-four of node if unprintable (emoji, etc)
|
||||
header += " (";
|
||||
header += parse(sender->user.long_name);
|
||||
header += ")";
|
||||
} else
|
||||
header += hexifyNodeNum(message->sender);
|
||||
// Sender's id
|
||||
// - short name and long name, if available, or
|
||||
// - node id
|
||||
meshtastic_NodeInfoLite *sender = nodeDB->getMeshNode(message->sender);
|
||||
if (sender && sender->has_user) {
|
||||
header += parseShortName(sender); // May be last-four of node if unprintable (emoji, etc)
|
||||
header += " (";
|
||||
header += parse(sender->user.long_name);
|
||||
header += ")";
|
||||
} else
|
||||
header += hexifyNodeNum(message->sender);
|
||||
|
||||
// Draw a "standard" applet header
|
||||
drawHeader(header);
|
||||
// Draw a "standard" applet header
|
||||
drawHeader(header);
|
||||
|
||||
// Fade the right edge of the header, if text spills over edge
|
||||
uint8_t wF = getFont().lineHeight() / 2; // Width of fade effect
|
||||
uint8_t hF = getHeaderHeight(); // Height of fade effect
|
||||
if (getCursorX() > width())
|
||||
hatchRegion(width() - wF - 1, 1, wF, hF, 2, WHITE);
|
||||
// Fade the right edge of the header, if text spills over edge
|
||||
uint8_t wF = getFont().lineHeight() / 2; // Width of fade effect
|
||||
uint8_t hF = getHeaderHeight(); // Height of fade effect
|
||||
if (getCursorX() > width())
|
||||
hatchRegion(width() - wF - 1, 1, wF, hF, 2, WHITE);
|
||||
|
||||
// Dimensions of the header
|
||||
constexpr int16_t padDivH = 2;
|
||||
const int16_t headerDivY = Applet::getHeaderHeight() - 1;
|
||||
// Dimensions of the header
|
||||
constexpr int16_t padDivH = 2;
|
||||
const int16_t headerDivY = Applet::getHeaderHeight() - 1;
|
||||
|
||||
// ===================
|
||||
// Print message text
|
||||
// ===================
|
||||
// ===================
|
||||
// Print message text
|
||||
// ===================
|
||||
|
||||
// Parse any non-ascii chars in the message
|
||||
std::string text = parse(message->text);
|
||||
// Parse any non-ascii chars in the message
|
||||
std::string text = parse(message->text);
|
||||
|
||||
// Extra gap below the header
|
||||
int16_t textTop = headerDivY + padDivH;
|
||||
// Extra gap below the header
|
||||
int16_t textTop = headerDivY + padDivH;
|
||||
|
||||
// Attempt to print with fontLarge
|
||||
uint32_t textHeight;
|
||||
setFont(fontLarge);
|
||||
textHeight = getWrappedTextHeight(0, width(), text);
|
||||
if (textHeight <= (uint32_t)height()) {
|
||||
// Attempt to print with fontLarge
|
||||
uint32_t textHeight;
|
||||
setFont(fontLarge);
|
||||
textHeight = getWrappedTextHeight(0, width(), text);
|
||||
if (textHeight <= (uint32_t)height()) {
|
||||
printWrapped(0, textTop, width(), text);
|
||||
return;
|
||||
}
|
||||
|
||||
// Fallback (too large): attempt to print with fontMedium
|
||||
setFont(fontMedium);
|
||||
textHeight = getWrappedTextHeight(0, width(), text);
|
||||
if (textHeight <= (uint32_t)height()) {
|
||||
printWrapped(0, textTop, width(), text);
|
||||
return;
|
||||
}
|
||||
|
||||
// Fallback (too large): print with fontSmall
|
||||
setFont(fontSmall);
|
||||
printWrapped(0, textTop, width(), text);
|
||||
return;
|
||||
}
|
||||
|
||||
// Fallback (too large): attempt to print with fontMedium
|
||||
setFont(fontMedium);
|
||||
textHeight = getWrappedTextHeight(0, width(), text);
|
||||
if (textHeight <= (uint32_t)height()) {
|
||||
printWrapped(0, textTop, width(), text);
|
||||
return;
|
||||
}
|
||||
|
||||
// Fallback (too large): print with fontSmall
|
||||
setFont(fontSmall);
|
||||
printWrapped(0, textTop, width(), text);
|
||||
}
|
||||
|
||||
// Don't show notifications for text messages when our applet is displayed
|
||||
bool InkHUD::AllMessageApplet::approveNotification(Notification &n) {
|
||||
if (n.type == Notification::Type::NOTIFICATION_MESSAGE_BROADCAST)
|
||||
return false;
|
||||
bool InkHUD::AllMessageApplet::approveNotification(Notification &n)
|
||||
{
|
||||
if (n.type == Notification::Type::NOTIFICATION_MESSAGE_BROADCAST)
|
||||
return false;
|
||||
|
||||
else if (n.type == Notification::Type::NOTIFICATION_MESSAGE_DIRECT)
|
||||
return false;
|
||||
else if (n.type == Notification::Type::NOTIFICATION_MESSAGE_DIRECT)
|
||||
return false;
|
||||
|
||||
else
|
||||
return true;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user