mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-20 22:13:47 +00:00
82 lines
2.2 KiB
C++
82 lines
2.2 KiB
C++
#pragma once
|
|
|
|
#include <MeshCore.h>
|
|
#include <helpers/ui/DisplayDriver.h>
|
|
#include <helpers/ui/UIScreen.h>
|
|
#include <helpers/SensorManager.h>
|
|
#include <helpers/BaseSerialInterface.h>
|
|
#include <Arduino.h>
|
|
|
|
#ifdef PIN_BUZZER
|
|
#include <helpers/ui/buzzer.h>
|
|
#endif
|
|
|
|
#include "NodePrefs.h"
|
|
|
|
enum class UIEventType {
|
|
none,
|
|
contactMessage,
|
|
channelMessage,
|
|
roomMessage,
|
|
newContactMessage,
|
|
ack
|
|
};
|
|
|
|
#define MAX_TOP_LEVEL 8
|
|
|
|
class UITask {
|
|
DisplayDriver* _display;
|
|
mesh::MainBoard* _board;
|
|
BaseSerialInterface* _serial;
|
|
SensorManager* _sensors;
|
|
#ifdef PIN_BUZZER
|
|
genericBuzzer buzzer;
|
|
#endif
|
|
unsigned long _next_refresh, _auto_off;
|
|
bool _connected;
|
|
NodePrefs* _node_prefs;
|
|
char _alert[80];
|
|
unsigned long _alert_expiry;
|
|
int _msgcount;
|
|
unsigned long ui_started_at, next_batt_chck;
|
|
|
|
UIScreen* splash;
|
|
UIScreen* home;
|
|
UIScreen* msg_preview;
|
|
UIScreen* curr;
|
|
|
|
void userLedHandler();
|
|
|
|
// Button action handlers
|
|
char checkDisplayOn(char c);
|
|
char handleLongPress(char c);
|
|
|
|
void setCurrScreen(UIScreen* c);
|
|
|
|
public:
|
|
|
|
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; }
|
|
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);
|
|
void shutdown(bool restart = false);
|
|
void loop();
|
|
};
|