2025-06-01 09:25:17 -07:00
|
|
|
|
#pragma once
|
refactor(ui): apply code review fixes — bugs, risk, optimisations, cleanup
Fixes 7 bugs (timing UB on unsigned long, abs() no-op, XBM CRC PROGMEM
scan, CayenneLPP heap thrash ×2, UTF-8 reply prefix, lock-seq reset on
wake), 3 risk items (notif melody stop guard, bot trigger pre-lowercase,
lock-seq cleared on display wake), plus optimisations (fmtMsgAge/
getTextWidth caching, RTTTL builder consolidated to NodePrefs, HP_*
constants and homePageLabel table moved to NodePrefs, DataStore flat
lambda schema, translateUTF8Static factored out) and minor cleanup.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-23 20:03:45 +02:00
|
|
|
|
#include <cstdint>
|
|
|
|
|
|
#include <stdio.h>
|
2025-04-20 17:40:58 -07:00
|
|
|
|
|
2025-06-01 20:41:04 -07:00
|
|
|
|
#define TELEM_MODE_DENY 0
|
|
|
|
|
|
#define TELEM_MODE_ALLOW_FLAGS 1 // use contact.flags
|
|
|
|
|
|
#define TELEM_MODE_ALLOW_ALL 2
|
2025-05-05 11:21:55 +10:00
|
|
|
|
|
2025-06-22 16:21:04 +10:00
|
|
|
|
#define ADVERT_LOC_NONE 0
|
|
|
|
|
|
#define ADVERT_LOC_SHARE 1
|
|
|
|
|
|
|
2026-06-07 10:53:17 +02:00
|
|
|
|
#define ADVERT_SOUND_SCOPE_ALL 0
|
|
|
|
|
|
#define ADVERT_SOUND_SCOPE_ZERO_HOP 1
|
|
|
|
|
|
|
2025-06-01 20:41:04 -07:00
|
|
|
|
struct NodePrefs { // persisted to file
|
2025-04-20 17:40:58 -07:00
|
|
|
|
float airtime_factor;
|
|
|
|
|
|
char node_name[32];
|
|
|
|
|
|
float freq;
|
|
|
|
|
|
uint8_t sf;
|
|
|
|
|
|
uint8_t cr;
|
2025-07-16 19:25:28 +10:00
|
|
|
|
uint8_t multi_acks;
|
2025-04-20 17:40:58 -07:00
|
|
|
|
uint8_t manual_add_contacts;
|
|
|
|
|
|
float bw;
|
2026-01-03 20:35:14 +01:00
|
|
|
|
int8_t tx_power_dbm;
|
2025-05-05 11:21:55 +10:00
|
|
|
|
uint8_t telemetry_mode_base;
|
|
|
|
|
|
uint8_t telemetry_mode_loc;
|
2025-05-22 15:26:30 +10:00
|
|
|
|
uint8_t telemetry_mode_env;
|
2025-04-20 17:40:58 -07:00
|
|
|
|
float rx_delay_base;
|
|
|
|
|
|
uint32_t ble_pin;
|
2025-06-22 16:21:04 +10:00
|
|
|
|
uint8_t advert_loc_policy;
|
2025-11-20 18:55:39 -08:00
|
|
|
|
uint8_t buzzer_quiet;
|
2026-05-12 09:17:37 +02:00
|
|
|
|
uint8_t buzzer_volume; // 0=min..4=max, default 4
|
2025-11-29 16:37:10 +08:00
|
|
|
|
uint8_t gps_enabled; // GPS enabled flag (0=disabled, 1=enabled)
|
|
|
|
|
|
uint32_t gps_interval; // GPS read interval in seconds
|
2026-01-13 00:38:20 +11:00
|
|
|
|
uint8_t autoadd_config; // bitmask for auto-add contacts config
|
2026-03-05 18:14:47 +00:00
|
|
|
|
uint8_t rx_boosted_gain; // SX126x RX boosted gain mode (0=power saving, 1=boosted)
|
2026-02-14 15:50:06 +11:00
|
|
|
|
uint8_t client_repeat;
|
2026-02-23 18:26:56 +11:00
|
|
|
|
uint8_t path_hash_mode; // which path mode to use when sending
|
2026-03-03 09:05:53 +01:00
|
|
|
|
uint8_t autoadd_max_hops; // 0 = no limit, 1 = direct (0 hops), N = up to N-1 hops (max 64)
|
2026-04-13 23:11:21 +10:00
|
|
|
|
char default_scope_name[31];
|
|
|
|
|
|
uint8_t default_scope_key[16];
|
2026-05-10 15:18:35 +02:00
|
|
|
|
uint8_t display_brightness; // 0=min..4=max, default 2 (medium)
|
|
|
|
|
|
uint16_t auto_off_secs; // display auto-off: 0=never, else seconds (default 15)
|
2026-05-17 09:55:51 +02:00
|
|
|
|
uint8_t auto_lock; // 0=disabled, 1=lock screen when display turns off
|
2026-05-10 15:18:35 +02:00
|
|
|
|
int8_t tz_offset_hours; // timezone offset from UTC, -12..+14 (default 0)
|
|
|
|
|
|
uint16_t low_batt_mv; // auto-shutdown threshold: 0=disabled, 3000-3500 mV
|
|
|
|
|
|
uint8_t batt_display_mode; // 0=icon, 1=percent, 2=voltage
|
2026-05-11 16:52:24 +02:00
|
|
|
|
char custom_msgs[10][140]; // user-defined quick messages (supports {loc}, {time})
|
2026-05-11 18:56:26 +02:00
|
|
|
|
uint64_t ch_notif_override; // bitmask: bit i = channel i has explicit notification setting
|
|
|
|
|
|
uint64_t ch_notif_muted; // bitmask: bit i = channel i muted (only if override bit set)
|
2026-05-11 19:19:44 +02:00
|
|
|
|
uint8_t dm_show_all; // 0=favourites only (default), 1=all chat contacts
|
|
|
|
|
|
uint8_t room_fav_only; // 0=all room servers (default), 1=favourites only
|
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
|
|
|
|
uint8_t ringtone_bpm_idx; // index into {60,90,120,150,180}
|
|
|
|
|
|
uint8_t ringtone_len; // number of notes in custom ringtone (0 = use default)
|
|
|
|
|
|
uint8_t ringtone_notes[32]; // packed: bits0-2=pitch, bits3-4=octave-4, bits5-6=dur_idx
|
2026-05-12 09:51:30 +02:00
|
|
|
|
uint16_t home_pages_mask; // bitmask of visible home pages (bit0=Clock..bit8=Shutdown); 0=all visible
|
2026-05-12 20:12:54 +02:00
|
|
|
|
uint8_t bot_enabled; // 0=disabled, 1=DM bot active (responds to all DMs)
|
|
|
|
|
|
uint8_t bot_channel_enabled; // 0=disabled, 1=channel bot active for bot_channel_idx
|
|
|
|
|
|
uint8_t bot_channel_idx; // channel index for channel bot
|
|
|
|
|
|
char bot_trigger[64]; // trigger phrase (case-insensitive contains match)
|
|
|
|
|
|
char bot_reply_dm[140]; // auto-reply text for DM
|
|
|
|
|
|
char bot_reply_ch[140]; // auto-reply text for channel
|
|
|
|
|
|
uint8_t clock_hide_seconds; // 0=show HH:MM:SS/refresh 1s (default), 1=hide/refresh 60s
|
2026-05-21 21:04:43 +02:00
|
|
|
|
uint8_t clock_12h; // 0=24h (default), 1=12h with AM/PM
|
2026-05-12 20:12:54 +02:00
|
|
|
|
uint8_t buzzer_auto; // 0=manual (default), 1=auto-mute when BT connected
|
2026-05-13 10:48:42 +02:00
|
|
|
|
struct DmNotifEntry { uint8_t prefix[4]; uint8_t state; }; // state: 0=default,1=muted,2=force-on
|
|
|
|
|
|
static const int DM_NOTIF_TABLE_MAX = 16;
|
|
|
|
|
|
DmNotifEntry dm_notif[DM_NOTIF_TABLE_MAX]; // 16*5 = 80 bytes
|
2026-05-27 22:55:50 +02:00
|
|
|
|
uint8_t dashboard_fields[3]; // 0=None,1=Batt V,2=Temp,3=Hum,4=Pres,5=GPS,6=Alt,7=Lux,8=CO2,9=Nodes,10=Msgs,11=Batt %
|
2026-05-14 16:08:33 +02:00
|
|
|
|
uint32_t advert_auto_interval_sec; // periodic 0-hop advert with GPS: 0=off, else seconds
|
2026-05-15 11:43:38 +02:00
|
|
|
|
// Second melody slot (same packing as ringtone_*)
|
|
|
|
|
|
uint8_t ringtone2_bpm_idx;
|
|
|
|
|
|
uint8_t ringtone2_len;
|
|
|
|
|
|
uint8_t ringtone2_notes[32];
|
2026-06-07 09:13:02 +02:00
|
|
|
|
// Global melodies for notifications: 0=built-in, 1=melody1, 2=melody2, 3=none
|
2026-05-15 11:43:38 +02:00
|
|
|
|
uint8_t notif_melody_dm;
|
|
|
|
|
|
uint8_t notif_melody_ch;
|
2026-06-04 08:46:15 +02:00
|
|
|
|
uint8_t notif_melody_ad;
|
2026-06-07 10:53:17 +02:00
|
|
|
|
// Advert sound filter: 0=all adverts, 1=zero-hop only
|
|
|
|
|
|
uint8_t advert_sound_scope;
|
2026-05-15 11:43:38 +02:00
|
|
|
|
// Per-channel melody override (2 bitmasks, 1 bit per channel)
|
|
|
|
|
|
uint64_t ch_notif_melody_set; // bit i = channel i has explicit melody
|
|
|
|
|
|
uint64_t ch_notif_melody_2; // bit i = use melody 2 (else melody 1, when set bit is set)
|
|
|
|
|
|
// Per-DM melody table
|
|
|
|
|
|
struct DmMelodyEntry { uint8_t prefix[4]; uint8_t slot; }; // slot: 0=global,1=melody1,2=melody2
|
|
|
|
|
|
static const int DM_MELODY_TABLE_MAX = 16;
|
|
|
|
|
|
DmMelodyEntry dm_melody[DM_MELODY_TABLE_MAX];
|
2026-05-20 21:53:40 +02:00
|
|
|
|
uint8_t use_lemon_font; // 0=default Adafruit font, 1=Lemon font (Unicode, pixel-accurate wrap)
|
|
|
|
|
|
uint8_t display_rotation; // 0-3; only used on e-ink displays
|
2026-05-24 22:26:56 +02:00
|
|
|
|
// Home screen page order: each byte = HomePageBit + 1. 0 terminates the list.
|
|
|
|
|
|
// Validity gated by page_order_set magic (see below) — not by entry value range,
|
|
|
|
|
|
// so a junk byte in 1..HPB_COUNT cannot trigger custom-order mode.
|
|
|
|
|
|
// (Array length = HPB_COUNT, declared as literal so the field offset is stable
|
|
|
|
|
|
// across builds that add new HomePageBit entries.)
|
2026-05-22 23:33:06 +02:00
|
|
|
|
uint8_t page_order[11];
|
2026-05-23 15:20:40 +02:00
|
|
|
|
uint8_t joystick_rotation; // 0-3 steps CW; independent of display_rotation
|
2026-05-24 10:22:03 +02:00
|
|
|
|
uint8_t eink_full_refresh_every; // index into {0,5,10,20,30}: full refresh every N partials (0=off)
|
2026-05-24 19:53:05 +02:00
|
|
|
|
uint8_t page_order_set; // 0xA5 = page_order is user-configured; anything else = use default
|
|
|
|
|
|
static const uint8_t PAGE_ORDER_MAGIC = 0xA5;
|
refactor(ui): apply code review fixes — bugs, risk, optimisations, cleanup
Fixes 7 bugs (timing UB on unsigned long, abs() no-op, XBM CRC PROGMEM
scan, CayenneLPP heap thrash ×2, UTF-8 reply prefix, lock-seq reset on
wake), 3 risk items (notif melody stop guard, bot trigger pre-lowercase,
lock-seq cleared on display wake), plus optimisations (fmtMsgAge/
getTextWidth caching, RTTTL builder consolidated to NodePrefs, HP_*
constants and homePageLabel table moved to NodePrefs, DataStore flat
lambda schema, translateUTF8Static factored out) and minor cleanup.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-23 20:03:45 +02:00
|
|
|
|
|
2026-05-24 23:00:27 +02:00
|
|
|
|
// Favourites dial: 6 pinned contacts, stored as first 6 bytes of pub_key per slot.
|
|
|
|
|
|
// All-zero = empty slot (probability a real pub_key starts with 6 zero bytes is 2^-48).
|
|
|
|
|
|
// Layout transposes between landscape (3×2) and portrait (2×3).
|
|
|
|
|
|
static const uint8_t FAVOURITES_COUNT = 6;
|
|
|
|
|
|
static const uint8_t FAVOURITE_PREFIX_LEN = 6;
|
|
|
|
|
|
uint8_t favourite_contacts[FAVOURITES_COUNT][FAVOURITE_PREFIX_LEN];
|
|
|
|
|
|
|
2026-05-25 10:48:03 +02:00
|
|
|
|
// GPS trail cadence. Logging on/off is a runtime state (Tools › Trail),
|
|
|
|
|
|
// not a persisted preference.
|
|
|
|
|
|
uint8_t trail_interval_idx; // reserved — sampling cadence is now fixed at TrailStore::SAMPLING_SECS
|
2026-06-04 00:50:42 +02:00
|
|
|
|
uint8_t trail_min_delta_idx; // min-distance gate level (0=finest..3); metres or feet per units_imperial
|
2026-06-04 00:44:56 +02:00
|
|
|
|
uint8_t trail_units_idx; // legacy: old combined speed/pace+unit index (km/h, mph, min/km, min/mi)
|
feat(ui): GPS breadcrumb phase 1 — storage, sampling, Summary view
Adds Tools › Breadcrumb. Enter on the screen toggles tracking; while
active, UITask::loop samples GPS at the cadence chosen in settings
(default 1 min) and drops the point into a 256-entry RAM ring guarded
by a min-distance gate (default 25 m). A "G" indicator joins "A" in
the status bar with the same blink convention.
New storage:
- examples/companion_radio/Breadcrumb.h — BreadcrumbStore class
- 256 × 12 B = 3 KB RAM (survives auto-off, lost on reboot — explicit
flash-slot save comes in phase 4)
- Haversine min-delta gate, total distance, elapsed seconds, current
km/h, bounding-box helper
New screen:
- examples/companion_radio/ui-new/BreadcrumbScreen.h — Summary view
with Status, Points, Dist (m or km), Time (h:mm), Speed; Enter
toggles tracking, Esc returns to Tools
Schema bump 0xC0DE0002 → 0xC0DE0003 for two new NodePrefs bytes:
breadcrumb_interval_idx (1min default) and breadcrumb_min_delta_idx
(25m default). Older saves leave both at zero, which matches the new
defaults. DataStore::loadPrefsInt/savePrefs read/write the pair.
Logging on/off is a runtime flag inside BreadcrumbStore — not a
preference — so reboot returns to the off state cleanly; the user
will be able to persist a snapshot to a slot in phase 4.
Phase 2 (map view), 3 (point list), 4 (slot save/load, GPX export over
USB), and 5 (settings UI) follow incrementally.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-25 08:22:12 +02:00
|
|
|
|
|
2026-05-27 17:33:52 +02:00
|
|
|
|
uint64_t ch_fav_bitmask; // bit i = channel i is marked as favourite
|
|
|
|
|
|
uint8_t ch_fav_only; // 0=show all channels (default), 1=show favourites only
|
|
|
|
|
|
|
2026-06-04 00:44:56 +02:00
|
|
|
|
// Global measurement system for every distance/speed shown in the UI
|
|
|
|
|
|
// (Nearby, Trail, navigate-to-point). 0=metric (default), 1=imperial.
|
|
|
|
|
|
uint8_t units_imperial;
|
|
|
|
|
|
// Trail Summary readout: 0=speed (km/h or mph), 1=pace (min/km or min/mi).
|
|
|
|
|
|
// The km-vs-mi choice now comes from units_imperial, so this is just the mode.
|
|
|
|
|
|
uint8_t trail_show_pace;
|
|
|
|
|
|
|
2026-05-24 20:18:50 +02:00
|
|
|
|
// Tail sentinel written at the end of /new_prefs. Bump the low byte when
|
|
|
|
|
|
// adding/removing/reordering fields in DataStore::savePrefs/loadPrefsInt so
|
|
|
|
|
|
// older saves are detected on load and skipped (zero-init defaults kept).
|
|
|
|
|
|
// High 24 bits identify the file format; low byte is the schema revision.
|
2026-06-07 10:53:17 +02:00
|
|
|
|
static const uint32_t SCHEMA_SENTINEL = 0xC0DE0008;
|
2026-05-24 20:18:50 +02:00
|
|
|
|
|
2026-05-24 22:26:56 +02:00
|
|
|
|
// Bit-index for each home page. Used by page_order (entries store bit+1) and
|
|
|
|
|
|
// by home_pages_mask. Single source of truth — both HomeScreen::pageBit/bitToPage
|
|
|
|
|
|
// and SettingsScreen::homePageBitIndex route their per-enum lookups through these.
|
|
|
|
|
|
enum HomePageBit : uint8_t {
|
2026-05-24 23:00:27 +02:00
|
|
|
|
HPB_CLOCK = 0,
|
|
|
|
|
|
HPB_RECENT = 1,
|
|
|
|
|
|
HPB_RADIO = 2,
|
|
|
|
|
|
HPB_BLUETOOTH = 3,
|
|
|
|
|
|
HPB_ADVERT = 4,
|
|
|
|
|
|
HPB_GPS = 5,
|
|
|
|
|
|
HPB_SENSORS = 6,
|
|
|
|
|
|
HPB_TOOLS = 7,
|
|
|
|
|
|
HPB_SHUTDOWN = 8,
|
|
|
|
|
|
HPB_SETTINGS = 9,
|
|
|
|
|
|
HPB_QUICK_MSG = 10,
|
|
|
|
|
|
HPB_FAVOURITES = 11,
|
|
|
|
|
|
HPB_COUNT = 12,
|
2026-05-24 22:26:56 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
2026-05-24 23:00:27 +02:00
|
|
|
|
// Length of the persisted page_order[] array. Stable across firmware versions
|
|
|
|
|
|
// (don't grow without a schema migration). When HPB_COUNT exceeds this, extra
|
|
|
|
|
|
// visible pages are appended at navigation time via buildVisibleOrder fallback.
|
|
|
|
|
|
static const uint8_t PAGE_ORDER_LEN = 11;
|
|
|
|
|
|
|
refactor(ui): apply code review fixes — bugs, risk, optimisations, cleanup
Fixes 7 bugs (timing UB on unsigned long, abs() no-op, XBM CRC PROGMEM
scan, CayenneLPP heap thrash ×2, UTF-8 reply prefix, lock-seq reset on
wake), 3 risk items (notif melody stop guard, bot trigger pre-lowercase,
lock-seq cleared on display wake), plus optimisations (fmtMsgAge/
getTextWidth caching, RTTTL builder consolidated to NodePrefs, HP_*
constants and homePageLabel table moved to NodePrefs, DataStore flat
lambda schema, translateUTF8Static factored out) and minor cleanup.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-23 20:03:45 +02:00
|
|
|
|
// Bitmasks for home_pages_mask (bit=1 → page visible; 0 field = all visible).
|
2026-05-24 22:26:56 +02:00
|
|
|
|
// SETTINGS and QUICK_MSG have no mask bit — they're always visible.
|
2026-05-24 23:00:27 +02:00
|
|
|
|
static const uint16_t HP_CLOCK = 1 << HPB_CLOCK;
|
|
|
|
|
|
static const uint16_t HP_RECENT = 1 << HPB_RECENT;
|
|
|
|
|
|
static const uint16_t HP_RADIO = 1 << HPB_RADIO;
|
|
|
|
|
|
static const uint16_t HP_BLUETOOTH = 1 << HPB_BLUETOOTH;
|
|
|
|
|
|
static const uint16_t HP_ADVERT = 1 << HPB_ADVERT;
|
|
|
|
|
|
static const uint16_t HP_GPS = 1 << HPB_GPS;
|
|
|
|
|
|
static const uint16_t HP_SENSORS = 1 << HPB_SENSORS;
|
|
|
|
|
|
static const uint16_t HP_TOOLS = 1 << HPB_TOOLS;
|
|
|
|
|
|
static const uint16_t HP_SHUTDOWN = 1 << HPB_SHUTDOWN;
|
|
|
|
|
|
static const uint16_t HP_FAVOURITES = 1 << HPB_FAVOURITES;
|
|
|
|
|
|
static const uint16_t HP_ALL = 0x01FF | HP_FAVOURITES;
|
refactor(ui): apply code review fixes — bugs, risk, optimisations, cleanup
Fixes 7 bugs (timing UB on unsigned long, abs() no-op, XBM CRC PROGMEM
scan, CayenneLPP heap thrash ×2, UTF-8 reply prefix, lock-seq reset on
wake), 3 risk items (notif melody stop guard, bot trigger pre-lowercase,
lock-seq cleared on display wake), plus optimisations (fmtMsgAge/
getTextWidth caching, RTTTL builder consolidated to NodePrefs, HP_*
constants and homePageLabel table moved to NodePrefs, DataStore flat
lambda schema, translateUTF8Static factored out) and minor cleanup.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-23 20:03:45 +02:00
|
|
|
|
|
2026-05-24 22:26:56 +02:00
|
|
|
|
// Label for home page by bit-index; returns "" for out-of-range.
|
|
|
|
|
|
// Array indices match HomePageBit values.
|
refactor(ui): apply code review fixes — bugs, risk, optimisations, cleanup
Fixes 7 bugs (timing UB on unsigned long, abs() no-op, XBM CRC PROGMEM
scan, CayenneLPP heap thrash ×2, UTF-8 reply prefix, lock-seq reset on
wake), 3 risk items (notif melody stop guard, bot trigger pre-lowercase,
lock-seq cleared on display wake), plus optimisations (fmtMsgAge/
getTextWidth caching, RTTTL builder consolidated to NodePrefs, HP_*
constants and homePageLabel table moved to NodePrefs, DataStore flat
lambda schema, translateUTF8Static factored out) and minor cleanup.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-23 20:03:45 +02:00
|
|
|
|
static const char* homePageLabel(uint8_t bit) {
|
2026-05-24 22:26:56 +02:00
|
|
|
|
static const char* labels[HPB_COUNT] = {
|
refactor(ui): apply code review fixes — bugs, risk, optimisations, cleanup
Fixes 7 bugs (timing UB on unsigned long, abs() no-op, XBM CRC PROGMEM
scan, CayenneLPP heap thrash ×2, UTF-8 reply prefix, lock-seq reset on
wake), 3 risk items (notif melody stop guard, bot trigger pre-lowercase,
lock-seq cleared on display wake), plus optimisations (fmtMsgAge/
getTextWidth caching, RTTTL builder consolidated to NodePrefs, HP_*
constants and homePageLabel table moved to NodePrefs, DataStore flat
lambda schema, translateUTF8Static factored out) and minor cleanup.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-23 20:03:45 +02:00
|
|
|
|
"Clock", "Recent", "Radio", "Bluetooth", "Advert",
|
2026-05-24 23:00:27 +02:00
|
|
|
|
"GPS", "Sensors", "Tools", "Shutdown", "Settings", "Messages", "Favourites"
|
refactor(ui): apply code review fixes — bugs, risk, optimisations, cleanup
Fixes 7 bugs (timing UB on unsigned long, abs() no-op, XBM CRC PROGMEM
scan, CayenneLPP heap thrash ×2, UTF-8 reply prefix, lock-seq reset on
wake), 3 risk items (notif melody stop guard, bot trigger pre-lowercase,
lock-seq cleared on display wake), plus optimisations (fmtMsgAge/
getTextWidth caching, RTTTL builder consolidated to NodePrefs, HP_*
constants and homePageLabel table moved to NodePrefs, DataStore flat
lambda schema, translateUTF8Static factored out) and minor cleanup.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-23 20:03:45 +02:00
|
|
|
|
};
|
2026-05-24 22:26:56 +02:00
|
|
|
|
return (bit < HPB_COUNT) ? labels[bit] : "";
|
refactor(ui): apply code review fixes — bugs, risk, optimisations, cleanup
Fixes 7 bugs (timing UB on unsigned long, abs() no-op, XBM CRC PROGMEM
scan, CayenneLPP heap thrash ×2, UTF-8 reply prefix, lock-seq reset on
wake), 3 risk items (notif melody stop guard, bot trigger pre-lowercase,
lock-seq cleared on display wake), plus optimisations (fmtMsgAge/
getTextWidth caching, RTTTL builder consolidated to NodePrefs, HP_*
constants and homePageLabel table moved to NodePrefs, DataStore flat
lambda schema, translateUTF8Static factored out) and minor cleanup.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-23 20:03:45 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void buildRTTTLString(const uint8_t* notes, uint8_t len, uint8_t bpm_idx,
|
|
|
|
|
|
char* buf, int size) {
|
|
|
|
|
|
static const uint16_t BPM_OPTS[] = { 60, 90, 120, 150, 180 };
|
|
|
|
|
|
static const uint8_t DUR_VALS[] = { 4, 8, 16, 32 };
|
|
|
|
|
|
static const char PITCHES[] = { 'p', 'c', 'd', 'e', 'f', 'g', 'a', 'b' };
|
|
|
|
|
|
if (len == 0) { buf[0] = '\0'; return; }
|
|
|
|
|
|
uint16_t bpm = BPM_OPTS[bpm_idx < 5 ? bpm_idx : 2];
|
|
|
|
|
|
int pos = snprintf(buf, size, "Ring:d=8,o=5,b=%u:", bpm);
|
|
|
|
|
|
for (int i = 0; i < len && pos < size - 8; i++) {
|
|
|
|
|
|
if (i > 0 && pos < size - 1) buf[pos++] = ',';
|
|
|
|
|
|
uint8_t pitch = notes[i] & 0x07;
|
|
|
|
|
|
uint8_t octave = ((notes[i] >> 3) & 0x03) + 4;
|
|
|
|
|
|
uint8_t dur_val = DUR_VALS[(notes[i] >> 5) & 0x03];
|
|
|
|
|
|
if (pitch == 0) pos += snprintf(buf + pos, size - pos, "%dp", dur_val);
|
|
|
|
|
|
else pos += snprintf(buf + pos, size - pos, "%d%c%d", dur_val, PITCHES[pitch], octave);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (pos < size) buf[pos] = '\0';
|
|
|
|
|
|
}
|
2026-06-04 08:46:15 +02:00
|
|
|
|
};
|