add UI frame to display PaxCounter module data

This commit is contained in:
Thomas Herrmann 2024-02-22 23:41:14 +01:00 committed by Thomas Göttgens
parent 02192e1163
commit bbc76f884e
2 changed files with 23 additions and 0 deletions

View File

@ -87,4 +87,25 @@ int32_t PaxcounterModule::runOnce()
}
}
// TODO: Probably we could get this from Screen or other central class
#define FONT_SMALL ArialMT_Plain_10
#define FONT_MEDIUM ArialMT_Plain_16
#define FONT_LARGE ArialMT_Plain_24
void PaxcounterModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
{
char buffer[50];
display->setTextAlignment(TEXT_ALIGN_LEFT);
display->setFont(FONT_SMALL);
display->drawString(x + 0, y + 0, "PAX");
libpax_counter_count(&count_from_libpax);
display->setTextAlignment(TEXT_ALIGN_CENTER);
display->setFont(FONT_SMALL);
display->drawStringf(display->getWidth() / 2 + x, 0 + y + 12,
buffer, "WiFi: %d\nBLE: %d\nuptime: %ds",
count_from_libpax.wifi_count, count_from_libpax.ble_count, millis() / 1000);
}
#endif

View File

@ -23,6 +23,8 @@ class PaxcounterModule : private concurrency::OSThread, public ProtobufModule<me
bool sendInfo(NodeNum dest = NODENUM_BROADCAST);
virtual bool handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshtastic_Paxcount *p) override;
virtual meshtastic_MeshPacket *allocReply() override;
virtual bool wantUIFrame() override { return true; }
virtual void drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) override;
};
extern PaxcounterModule *paxcounterModule;