Files
MeshCore-Solo/examples/companion_radio/ui-new/UITask.h
T

102 lines
2.4 KiB
C++
Raw Normal View History

#pragma once
#include <MeshCore.h>
#include <helpers/ui/DisplayDriver.h>
2025-08-08 20:01:31 +10:00
#include <helpers/ui/UIScreen.h>
2025-06-19 17:26:58 +02:00
#include <helpers/SensorManager.h>
#include <helpers/MultiSerialInterface.h>
2025-08-08 20:01:31 +10:00
#include <Arduino.h>
#include <helpers/sensors/LPPDataHelpers.h>
#ifndef LED_STATE_ON
#define LED_STATE_ON 1
#endif
2025-05-20 11:52:55 +10:00
#ifdef PIN_BUZZER
#include <helpers/ui/buzzer.h>
#endif
#ifdef PIN_VIBRATION
2025-09-18 13:19:54 +10:00
#include <helpers/ui/GenericVibration.h>
#endif
2025-05-20 11:52:55 +10:00
2025-08-16 20:04:54 +10:00
#include "../AbstractUITask.h"
#include "../NodePrefs.h"
2025-08-16 20:04:54 +10:00
class UITask : public AbstractUITask {
DisplayDriver* _display;
2025-06-19 17:26:58 +02:00
SensorManager* _sensors;
2025-05-20 11:52:55 +10:00
#ifdef PIN_BUZZER
genericBuzzer buzzer;
#endif
#ifdef PIN_VIBRATION
2025-09-18 13:19:54 +10:00
GenericVibration vibration;
2025-05-20 11:52:55 +10:00
#endif
unsigned long _next_refresh, _auto_off;
NodePrefs* _node_prefs;
2025-06-04 09:51:16 -07:00
char _alert[80];
2025-08-08 20:01:31 +10:00
unsigned long _alert_expiry;
int _msgcount;
2025-08-08 20:01:31 +10:00
unsigned long ui_started_at, next_batt_chck;
2025-09-03 17:22:11 +02:00
int next_backlight_btn_check = 0;
#ifdef PIN_STATUS_LED
int led_state = 0;
int next_led_change = 0;
int last_led_increment = 0;
#endif
2025-10-31 13:04:59 +00:00
#ifdef PIN_USER_BTN_ANA
unsigned long _analogue_pin_read_millis = millis();
#endif
2025-08-08 20:01:31 +10:00
UIScreen* splash;
UIScreen* home;
UIScreen* msg_preview;
UIScreen* curr;
2025-05-27 19:10:56 -07:00
void userLedHandler();
2025-05-27 19:10:56 -07:00
// Button action handlers
2025-08-08 20:01:31 +10:00
char checkDisplayOn(char c);
char handleLongPress(char c);
2025-09-03 08:25:59 +10:00
char handleDoubleClick(char c);
char handleTripleClick(char c);
2025-08-08 20:01:31 +10:00
void setCurrScreen(UIScreen* c);
2025-05-27 19:10:56 -07:00
public:
UITask(mesh::MainBoard* board, MultiSerialInterface* serial) : AbstractUITask(board, serial), _display(NULL), _sensors(NULL) {
2025-08-08 20:01:31 +10:00
next_batt_chck = _next_refresh = 0;
ui_started_at = 0;
curr = NULL;
}
2025-06-19 17:26:58 +02:00
void begin(DisplayDriver* display, SensorManager* sensors, NodePrefs* node_prefs);
2025-08-08 20:01:31 +10:00
void gotoHomeScreen() { setCurrScreen(home); }
void showAlert(const char* text, int duration_millis);
int getMsgCount() const { return _msgcount; }
bool hasDisplay() const { return _display != NULL; }
2025-08-08 20:01:31 +10:00
bool isButtonPressed() const;
2025-08-16 20:04:54 +10:00
2026-02-11 09:51:28 +01:00
bool isBuzzerQuiet() {
#ifdef PIN_BUZZER
return buzzer.isQuiet();
#else
return true;
#endif
}
2025-09-03 08:25:59 +10:00
void toggleBuzzer();
2025-09-23 10:39:43 +02:00
bool getGPSState();
2025-09-03 08:25:59 +10:00
void toggleGPS();
2025-08-16 21:09:35 +10:00
// from AbstractUITask
2025-08-16 20:04:54 +10:00
void msgRead(int msgcount) override;
void newMsg(uint8_t path_len, const char* from_name, const char* text, int msgcount) override;
void notify(UIEventType t = UIEventType::none) override;
2025-08-16 20:04:54 +10:00
void loop() override;
void shutdown(bool restart = false);
};