* UI revamp for companion radios

This commit is contained in:
Scott Powell
2025-08-08 20:01:31 +10:00
parent a310a5c4d5
commit 4b95c981bb
26 changed files with 840 additions and 323 deletions

View File

@@ -2,18 +2,18 @@
#include <MeshCore.h>
#include <helpers/ui/DisplayDriver.h>
#include <helpers/ui/UIScreen.h>
#include <helpers/SensorManager.h>
#include <stddef.h>
#include <helpers/BaseSerialInterface.h>
#include <Arduino.h>
#ifdef PIN_BUZZER
#include <helpers/ui/buzzer.h>
#endif
#include "NodePrefs.h"
#include "Button.h"
enum class UIEventType
{
enum class UIEventType {
none,
contactMessage,
channelMessage,
@@ -22,9 +22,12 @@
ack
};
#define MAX_TOP_LEVEL 8
class UITask {
DisplayDriver* _display;
mesh::MainBoard* _board;
BaseSerialInterface* _serial;
SensorManager* _sensors;
#ifdef PIN_BUZZER
genericBuzzer buzzer;
@@ -32,48 +35,45 @@ class UITask {
unsigned long _next_refresh, _auto_off;
bool _connected;
NodePrefs* _node_prefs;
char _version_info[32];
char _origin[62];
char _msg[80];
char _alert[80];
unsigned long _alert_expiry;
int _msgcount;
bool _need_refresh = true;
bool _displayWasOn = false; // Track display state before button press
unsigned long ui_started_at;
unsigned long ui_started_at, next_batt_chck;
// Button handlers
#ifdef PIN_USER_BTN
Button* _userButton = nullptr;
#endif
#ifdef PIN_USER_BTN_ANA
Button* _userButtonAnalog = nullptr;
#endif
UIScreen* splash;
UIScreen* home;
UIScreen* msg_preview;
UIScreen* curr;
void renderCurrScreen();
void userLedHandler();
void renderBatteryIndicator(uint16_t batteryMilliVolts);
// Button action handlers
void handleButtonAnyPress();
void handleButtonShortPress();
void handleButtonDoublePress();
void handleButtonTriplePress();
void handleButtonQuadruplePress();
void handleButtonLongPress();
char checkDisplayOn(char c);
char handleLongPress(char c);
void setCurrScreen(UIScreen* c);
public:
UITask(mesh::MainBoard* board) : _board(board), _display(NULL), _sensors(NULL) {
_next_refresh = 0;
ui_started_at = 0;
_connected = false;
UITask(mesh::MainBoard* board, BaseSerialInterface* serial) : _board(board), _serial(serial), _display(NULL), _sensors(NULL) {
next_batt_chck = _next_refresh = 0;
ui_started_at = 0;
_connected = false;
curr = NULL;
}
void begin(DisplayDriver* display, SensorManager* sensors, NodePrefs* node_prefs);
void gotoHomeScreen() { setCurrScreen(home); }
void showAlert(const char* text, int duration_millis);
void setHasConnection(bool connected) { _connected = connected; }
bool hasConnection() const { return _connected; }
uint16_t getBattMilliVolts() const { return _board->getBattMilliVolts(); }
bool isSerialEnabled() const { return _serial->isEnabled(); }
void enableSerial() { _serial->enable(); }
void disableSerial() { _serial->disable(); }
int getMsgCount() const { return _msgcount; }
bool hasDisplay() const { return _display != NULL; }
void clearMsgPreview();
bool isButtonPressed() const;
void msgRead(int msgcount);
void newMsg(uint8_t path_len, const char* from_name, const char* text, int msgcount);
void soundBuzzer(UIEventType bet = UIEventType::none);