mirror of
https://github.com/meshtastic/firmware.git
synced 2025-09-23 01:41:10 +00:00

* chore: todo.txt * chore: comments * fix: no fast refresh on VME290 Reverts a line of code which was accidentally committed * refactor: god class Divide the behavior from the old WindowManager class into several subclasses which each have a clear role. * refactor: cppcheck medium warnings Enough to pass github CI for now * refactor: updateType selection * refactor: don't use a setter for the shared AppletFonts * fix: update prioritization forceUpdate calls weren't being prioritized * refactor: remove unhelpful logging getTimeString is used for parsing our own time, but also the timestamps of messages. The "one time only" log printing will likely fire in unhelpful situations. * fix: " " * refactor: get rid of types.h file for enums * Keep that sneaky todo file out of commits
52 lines
1.7 KiB
C++
52 lines
1.7 KiB
C++
#ifdef MESHTASTIC_INCLUDE_INKHUD
|
|
|
|
#include "./NewMsgExampleApplet.h"
|
|
|
|
using namespace NicheGraphics;
|
|
|
|
// We configured MeshModule API to call this method when we receive a new text message
|
|
ProcessMessage InkHUD::NewMsgExampleApplet::handleReceived(const meshtastic_MeshPacket &mp)
|
|
{
|
|
|
|
// Abort if applet fully deactivated
|
|
if (!isActive())
|
|
return ProcessMessage::CONTINUE;
|
|
|
|
// Check that this is an incoming message
|
|
// Outgoing messages (sent by us) will also call handleReceived
|
|
|
|
if (!isFromUs(&mp)) {
|
|
// Store the sender's nodenum
|
|
// We need to keep this information, so we can re-use it anytime render() is called
|
|
haveMessage = true;
|
|
fromWho = mp.from;
|
|
|
|
// Tell InkHUD that we have something new to show on the screen
|
|
requestUpdate();
|
|
}
|
|
|
|
// Tell MeshModule API to continue informing other firmware components about this message
|
|
// We're not the only component which is interested in new text messages
|
|
return ProcessMessage::CONTINUE;
|
|
}
|
|
|
|
// All drawing happens here
|
|
// We can trigger a render by calling requestUpdate()
|
|
// Render might be called by some external source
|
|
// We should always be ready to draw
|
|
void InkHUD::NewMsgExampleApplet::onRender()
|
|
{
|
|
printAt(0, 0, "Example: NewMsg", LEFT, TOP); // Print top-left corner of text at (0,0)
|
|
|
|
int16_t centerX = X(0.5); // Same as width() / 2
|
|
int16_t centerY = Y(0.5); // Same as height() / 2
|
|
|
|
if (haveMessage) {
|
|
printAt(centerX, centerY, "New Message", CENTER, BOTTOM);
|
|
printAt(centerX, centerY, "From: " + hexifyNodeNum(fromWho), CENTER, TOP);
|
|
} else {
|
|
printAt(centerX, centerY, "No Message", CENTER, MIDDLE); // Place center of string at (centerX, centerY)
|
|
}
|
|
}
|
|
|
|
#endif |