Skip to content

Commit

Permalink
add UI frame to display PaxCounter module data
Browse files Browse the repository at this point in the history
  • Loading branch information
thoherr authored and caveman99 committed Feb 25, 2024
1 parent d47f552 commit ca98fd0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/modules/esp32/PaxcounterModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions src/modules/esp32/PaxcounterModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit ca98fd0

Please sign in to comment.