2025-03-04 23:09:43 +11:00
|
|
|
#pragma once
|
|
|
|
|
|
2025-03-10 17:11:55 +01:00
|
|
|
#include <MeshCore.h>
|
2025-03-04 23:09:43 +11:00
|
|
|
#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>
|
2025-08-08 20:01:31 +10:00
|
|
|
#include <helpers/BaseSerialInterface.h>
|
|
|
|
|
#include <Arduino.h>
|
2025-09-09 16:32:41 +02:00
|
|
|
#include <helpers/sensors/LPPDataHelpers.h>
|
2025-03-04 23:09:43 +11:00
|
|
|
|
2025-11-30 10:52:33 +01:00
|
|
|
#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
|
2025-09-07 15:16:15 +08:00
|
|
|
#ifdef PIN_VIBRATION
|
2025-09-18 13:19:54 +10:00
|
|
|
#include <helpers/ui/GenericVibration.h>
|
2025-09-07 15:16:15 +08:00
|
|
|
#endif
|
2025-05-20 11:52:55 +10:00
|
|
|
|
2025-08-16 20:04:54 +10:00
|
|
|
#include "../AbstractUITask.h"
|
|
|
|
|
#include "../NodePrefs.h"
|
2025-04-20 17:40:58 -07:00
|
|
|
|
2025-08-16 20:04:54 +10:00
|
|
|
class UITask : public AbstractUITask {
|
2025-03-04 23:09:43 +11:00
|
|
|
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;
|
2025-09-07 15:16:15 +08:00
|
|
|
#endif
|
|
|
|
|
#ifdef PIN_VIBRATION
|
2025-09-18 13:19:54 +10:00
|
|
|
GenericVibration vibration;
|
2025-05-20 11:52:55 +10:00
|
|
|
#endif
|
2025-03-10 17:11:55 +01:00
|
|
|
unsigned long _next_refresh, _auto_off;
|
2025-04-20 17:40:58 -07:00
|
|
|
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;
|
2025-03-10 17:11:55 +01:00
|
|
|
int _msgcount;
|
2026-05-11 19:27:16 +02:00
|
|
|
int _room_unread;
|
2026-05-11 18:56:26 +02:00
|
|
|
int _last_notif_ch_idx;
|
2025-08-08 20:01:31 +10:00
|
|
|
unsigned long ui_started_at, next_batt_chck;
|
2026-05-10 15:18:35 +02:00
|
|
|
uint16_t _batt_mv; // EMA-filtered battery voltage
|
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-03-04 23:09:43 +11:00
|
|
|
|
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;
|
2026-05-10 15:18:35 +02:00
|
|
|
UIScreen* settings;
|
2026-05-10 18:45:35 +02:00
|
|
|
UIScreen* quick_msg;
|
Add ringtone editor, buzzer volume, unread fixes and buzzer notification fixes
- RingtoneEditorScreen: 32-note step sequencer accessible via new Tools page on home screen. U/D=pitch, ENTER=octave cycle, L/R=cursor, MENU=options (play, duration, BPM, insert/delete, save). Notes stored packed in NodePrefs and persisted via DataStore.
- ToolsScreen: new "Tools" home page entry launching the editor
- Buzzer volume: 0-4 bar control in Settings > Sound, persisted to prefs
- Buzzer notifications: fixed notify() firing inside wrong serial-guard branch and before addChannelMsg set the channel index
- Unread counter: fixed newest-first index direction; watermark formula now correct
- OLED brightness: wider range via pre-charge register 0xD9 combined with contrast
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-12 09:40:37 +02:00
|
|
|
UIScreen* tools_screen;
|
|
|
|
|
UIScreen* ringtone_edit;
|
2026-05-12 11:47:33 +02:00
|
|
|
UIScreen* bot_screen;
|
2025-08-08 20:01:31 +10:00
|
|
|
UIScreen* curr;
|
2025-05-27 19:10:56 -07:00
|
|
|
|
2025-03-10 17:11:55 +01:00
|
|
|
void userLedHandler();
|
2025-11-30 10:52:33 +01:00
|
|
|
|
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
|
|
|
|
2025-03-04 23:09:43 +11:00
|
|
|
public:
|
2025-03-10 17:11:55 +01:00
|
|
|
|
2026-05-10 20:26:05 +02:00
|
|
|
UITask(mesh::MainBoard* board, BaseSerialInterface* serial) : AbstractUITask(board, serial), _display(NULL), _sensors(NULL), _node_prefs(NULL) {
|
2025-08-08 20:01:31 +10:00
|
|
|
next_batt_chck = _next_refresh = 0;
|
|
|
|
|
ui_started_at = 0;
|
2026-05-10 15:18:35 +02:00
|
|
|
_batt_mv = 0;
|
2026-05-11 19:27:16 +02:00
|
|
|
_msgcount = _room_unread = 0;
|
2026-05-11 18:56:26 +02:00
|
|
|
_last_notif_ch_idx = -1;
|
2025-08-08 20:01:31 +10:00
|
|
|
curr = NULL;
|
2025-03-10 17:11:55 +01:00
|
|
|
}
|
2025-06-19 17:26:58 +02:00
|
|
|
void begin(DisplayDriver* display, SensorManager* sensors, NodePrefs* node_prefs);
|
2025-03-04 23:09:43 +11:00
|
|
|
|
2026-05-10 15:18:35 +02:00
|
|
|
NodePrefs* getNodePrefs() const { return _node_prefs; }
|
|
|
|
|
uint16_t getBattMilliVolts() const { return _batt_mv > 0 ? _batt_mv : AbstractUITask::getBattMilliVolts(); }
|
2025-08-08 20:01:31 +10:00
|
|
|
void gotoHomeScreen() { setCurrScreen(home); }
|
2026-05-10 22:12:29 +02:00
|
|
|
void gotoSettingsScreen();
|
2026-05-10 18:45:35 +02:00
|
|
|
void gotoQuickMsgScreen();
|
Add ringtone editor, buzzer volume, unread fixes and buzzer notification fixes
- RingtoneEditorScreen: 32-note step sequencer accessible via new Tools page on home screen. U/D=pitch, ENTER=octave cycle, L/R=cursor, MENU=options (play, duration, BPM, insert/delete, save). Notes stored packed in NodePrefs and persisted via DataStore.
- ToolsScreen: new "Tools" home page entry launching the editor
- Buzzer volume: 0-4 bar control in Settings > Sound, persisted to prefs
- Buzzer notifications: fixed notify() firing inside wrong serial-guard branch and before addChannelMsg set the channel index
- Unread counter: fixed newest-first index direction; watermark formula now correct
- OLED brightness: wider range via pre-charge register 0xD9 combined with contrast
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-12 09:40:37 +02:00
|
|
|
void gotoToolsScreen();
|
|
|
|
|
void gotoRingtoneEditor();
|
2026-05-12 11:47:33 +02:00
|
|
|
void gotoBotScreen();
|
Add ringtone editor, buzzer volume, unread fixes and buzzer notification fixes
- RingtoneEditorScreen: 32-note step sequencer accessible via new Tools page on home screen. U/D=pitch, ENTER=octave cycle, L/R=cursor, MENU=options (play, duration, BPM, insert/delete, save). Notes stored packed in NodePrefs and persisted via DataStore.
- ToolsScreen: new "Tools" home page entry launching the editor
- Buzzer volume: 0-4 bar control in Settings > Sound, persisted to prefs
- Buzzer notifications: fixed notify() firing inside wrong serial-guard branch and before addChannelMsg set the channel index
- Unread counter: fixed newest-first index direction; watermark formula now correct
- OLED brightness: wider range via pre-charge register 0xD9 combined with contrast
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-12 09:40:37 +02:00
|
|
|
void playMelody(const char* melody);
|
|
|
|
|
void stopMelody();
|
|
|
|
|
bool isMelodyPlaying();
|
2025-08-08 20:01:31 +10:00
|
|
|
void showAlert(const char* text, int duration_millis);
|
WioTrackerL1: redesign companion UI (channels, keyboard, msg preview)
- QuickMsg → Message screen: channel history, on-screen keyboard, custom message first
- Channel history: RAM ring buffer (32 entries, 80 chars), fullscreen view with word-wrap scroll
- After channel send: stay in history, own message shown as "Me: ..."
- MsgPreview: one message per screen with up/down nav, ENTER opens fullscreen scroll
- Monochromatic display: all color usage corrected to DARK/LIGHT only
- Top bar: battery icon, BT muted indicator, splash "Plus for Wio"
- KB_MAX_LEN: 64 → 100 chars; channel text buffer: 52 → 80 chars
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-11 15:56:30 +02:00
|
|
|
void addChannelMsg(uint8_t channel_idx, const char* text) override;
|
2025-08-08 20:01:31 +10:00
|
|
|
int getMsgCount() const { return _msgcount; }
|
2026-05-11 19:11:19 +02:00
|
|
|
int getChannelUnreadCount() const;
|
2026-05-11 19:27:16 +02:00
|
|
|
int getRoomUnreadCount() const { return _room_unread; }
|
|
|
|
|
void clearRoomUnread() { _room_unread = 0; }
|
2025-03-16 13:42:36 +11:00
|
|
|
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();
|
2026-05-12 20:12:54 +02:00
|
|
|
void cycleBuzzerMode(); // ON → OFF → Auto → ON
|
|
|
|
|
int getBuzzerMode(); // 0=ON, 1=OFF, 2=Auto
|
2025-09-23 10:39:43 +02:00
|
|
|
bool getGPSState();
|
2025-09-03 08:25:59 +10:00
|
|
|
void toggleGPS();
|
2026-05-10 15:18:35 +02:00
|
|
|
void applyBrightness();
|
|
|
|
|
void setBrightnessLevel(uint8_t level);
|
|
|
|
|
uint8_t getBrightnessLevel() const { return _node_prefs ? _node_prefs->display_brightness : 2; }
|
2026-05-12 09:17:37 +02:00
|
|
|
void setBuzzerVolumeLevel(uint8_t level);
|
|
|
|
|
uint8_t getBuzzerVolume() const { return _node_prefs ? _node_prefs->buzzer_volume : 4; }
|
2026-05-10 15:18:35 +02:00
|
|
|
void applyTxPower();
|
|
|
|
|
void applyGPSInterval();
|
|
|
|
|
uint32_t autoOffMillis() const {
|
|
|
|
|
if (!_node_prefs || _node_prefs->auto_off_secs == 0) return 0;
|
|
|
|
|
return (uint32_t)_node_prefs->auto_off_secs * 1000UL;
|
|
|
|
|
}
|
2025-09-03 08:25:59 +10:00
|
|
|
|
|
|
|
|
|
2025-08-16 21:09:35 +10:00
|
|
|
// from AbstractUITask
|
2025-08-16 20:04:54 +10:00
|
|
|
void msgRead(int msgcount) override;
|
2026-05-11 19:27:16 +02:00
|
|
|
void newMsg(uint8_t path_len, const char* from_name, const char* text, int msgcount, uint8_t contact_type = 0) override;
|
2025-09-17 08:53:50 +08:00
|
|
|
void notify(UIEventType t = UIEventType::none) override;
|
2025-08-16 20:04:54 +10:00
|
|
|
void loop() override;
|
|
|
|
|
|
2025-05-27 11:07:51 +12:00
|
|
|
void shutdown(bool restart = false);
|
2025-03-10 17:11:55 +01:00
|
|
|
};
|