Commit Graph

933 Commits

Author SHA1 Message Date
Jakub
bb94a6f81f feat: home screen ordering — reorder all screens from Settings
NodePrefs: add page_order[11] (1-indexed bit-index, 0=end/legacy).
DataStore: persist page_order appended after use_lemon_font.

UITask/HomeScreen:
- bitToPage(): maps stable bit indices 0-10 to HomePage enum values
- buildVisibleOrder(): respects page_order when initialised, else
  falls back to default enum sequence
- navPage() and navigation dots use buildVisibleOrder()

SettingsScreen Home Pages section:
- Add Settings (bit 9) and Messages (bit 10) — show as "always"
- LEFT/RIGHT on any home page item moves it earlier/later in order
- ENTER toggles ON/OFF for pages that can be disabled
- Position number shown before label once custom order is active
- ensurePageOrderInit() seeds default order on first reorder action

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-22 23:33:06 +02:00
Jakub
319428c7c6 chore: remove unused FS_START_Y constant from FullscreenMsgView
startY is computed dynamically from header_h, making the constant redundant.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-22 09:34:24 +02:00
Jakub
ca5eb221e7 fix: persist use_lemon_font setting across reboots
The font preference was not saved to or loaded from flash, so it would
reset to default (Adafruit font) on every boot. Added to the versioned
DataStore read/write chain in the same pattern as other recently added
fields (auto_lock, dm_melody etc.).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-22 09:34:24 +02:00
Jakub
4161951d19 fix: force immediate redraw after font switch in applyFont()
Without _next_refresh = 0 the Settings screen would continue using its
2-second refresh interval after a font change, showing stale rendering
for up to 2 seconds. Mirrors the pattern used by setBrightnessLevel().

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-22 09:33:35 +02:00
Jakub
a115916d8f feat: runtime font switcher — Default vs Lemon in Settings > Display
- Add Lemon font (LemonFont.h, LemonIcons.h) to the standard build
  alongside the Adafruit built-in font; ~101 KB added to flash
- SH1106Display: add _use_lemon flag + setLemonFont(bool) to switch
  at runtime; print() and getTextWidth() use Lemon path when active;
  translateUTF8ToBlocks() passes UTF-8 through unchanged (Lemon supports
  full Unicode U+0020-U+04FF) vs transliterating for the default font
- DisplayDriver: add getCharWidth()/getLineHeight() virtuals (defaults 6/8);
  SH1106Display returns 5/9 for Lemon, 6/8 for default; add setLemonFont()
  no-op virtual; fix orphaned UTF-8 leading byte in drawTextEllipsized
- FullscreenMsgView: replace fixed-char-count word-wrap with pixel-accurate
  wrap using display.getTextWidth(); use getLineHeight() for spacing so
  Lemon (9 px) and default (8 px) both render correctly
- NodePrefs: add use_lemon_font field (0=default, 1=Lemon)
- SettingsScreen: add "Font" item in Display section (Default / Lemon),
  calls UITask::applyFont() on change
- UITask: add applyFont() that calls display->setLemonFont(use_lemon_font);
  called at startup (begin()) and when the setting changes

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-22 09:33:35 +02:00
Jakub
72c07df8b3 fix: code review corrections in DualSerialInterface and NearbyScreen
- DualSerialInterface: guard writeFrame/isWriteBusy/isBLEConnected with
  _ble_enabled to avoid BLE-after-disable race
- NearbyScreen: initialize all fields in constructor; promote D_* layout
  constants to class scope; clamp _dscroll on result count change;
  replace hardcoded 2 with D_VISIBLE in scroll logic; allow re-scan
  from detail view via KEY_CONTEXT_MENU/KEY_ENTER
- variant.cpp: fix inconsistent indentation in initVariant()

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-21 22:08:28 +02:00
Jakub
38cd0fada3 feat: add 12h/24h clock format setting (default 24h)
Toggle in Settings > Display > Format. In 12h mode the clock shows
h:mm AM/PM (or h:mm:ss AM/PM with seconds, no space before AM/PM).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-21 21:04:43 +02:00
Jakub
e0312c2b6b fix: strip @[nick] reply prefix in channel and DM history card previews
Reply prefix was eating ~9 chars of display width, causing the actual
message body to be ellipsized in list cards. Fullscreen view already
showed the recipient correctly via the To: header line.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-21 16:37:25 +02:00
Jakub
6b2f2ecf01 fix: replace base64.hpp include with local encoder to fix ODR link error
base64.hpp is header-only; including it in a .h file pulled into multiple
translation units caused duplicate symbol errors at link time.

Replaced with a self-contained static pubKeyToBase64() method inside
NearbyScreen that implements the same standard base64 encoding without
any external include.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-21 09:14:16 +02:00
Jakub
52d97ed314 feat: show pub_key as base64 in discover detail screen
Replaces "Type: Repeater" line with the node's full public key encoded
as base64 (44 chars). drawTextEllipsized clips it with ... to fit the
128px wide display. Type is already visible in the inverted header.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-21 09:11:32 +02:00
Jakub
3b7915d0b7 feat: discover detail screen + card selection + Rem removed from card body
Card body now shows only "RSSI:-87 SNR:7" (Rem was too long to fit).

List view:
- UP/DOWN selects items; selected card fully inverted, unselected keeps header-only highlight
- Enter opens full-screen detail for selected node
- Long-press Enter (context menu) re-scans

Detail screen:
- Inverted title bar with node name (or [Type])
- Type / RSSI / SNR / Rem / Status lines
- Cancel or context menu returns to discover list

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-21 09:05:15 +02:00
Jakub
2da37b3af5 feat: 2-line boxed discover entries with RSSI, SNR, remote SNR
Each discovered node now renders as a boxed 2-line card (same style as
message history):
  ┌──────────────────────────────┐
  │ NodeName (or [Sensor])  Type │  ← inverted header
  │ RSSI:-87 SNR:7 Rem:5         │  ← signal stats
  └──────────────────────────────┘

Add snr_x4 and remote_snr_x4 to DiscoverResult:
  snr_x4       = _radio->getLastSNR()*4  (how well we heard the response)
  remote_snr_x4 = payload[1]             (how well responder heard our request)

2 items visible at a time; UP/DOWN scroll through results.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-21 08:56:54 +02:00
Jakub
2a9874d05d feat: show RSSI in discover results list
Add rssi field to DiscoverResult, captured from _radio->getLastRSSI()
when the discover response is received.

Display format in the right column:
  known node  → "Rpt-87" / "Snsr-92" (type + dBm)
  new node    → "*-87" (asterisk + dBm; type already visible in "[Rpt]" label)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-21 08:51:43 +02:00
Jakub
6249e63ec0 fix: remove isBLEConnected guard from discover response handling
The !isBLEConnected() check was too restrictive — if BLE happened to be
connected (app in background) the standalone discover would silently drop
all responses. Tag matching already provides correct isolation: responses
matching _pending_node_discover_tag are handled by the standalone UI and
not forwarded to the BLE app; responses with a different tag fall through
to the normal forward path.

Also show short type names (Rpt/Snsr/Room) in the discover results list
instead of generic "known"/"NEW", with a '*' prefix for nodes not yet
in contacts — matching the repeater/sensor distinction the app shows.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-21 08:37:17 +02:00
Jakub
64098bc4dc fix: change [M]=Discover hint to [Enter]=Discover in NearbyScreen
[M] key doesn't exist on the device; context menu is long-press Enter.
Also handle KEY_ENTER directly when the list is empty so the hint
is accurate — pressing Enter with no contacts enters discover mode
without going through the context menu.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-21 08:13:13 +02:00
Jakub
d851043059 feat: add dedicated discover sub-screen to NearbyScreen
Replaces the inline advert scan in the nearby list with a proper
CTL_TYPE_NODE_DISCOVER_RESP-based sub-screen accessible via the context menu.

- DiscoveredEntry → DiscoverResult: adds name[32] and is_known flag so
  both known contacts and unknown nodes are shown with useful labels
- getDiscoveredNodes → getDiscoverResults, capacity 8 → 16
- onControlDataRecv populates name from contacts for known nodes and
  records all respondents (not just unknowns)
- NearbyScreen gains _discover_mode sub-screen: 8-second scan window,
  live result polling each render cycle, UP/DOWN scroll, CANCEL to
  return, ENTER/M to re-scan; known nodes show actual name + "known",
  unknown nodes show "[Type]" + "NEW"
- List view is clean: no discovered nodes mixed in, no scanning banner

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-21 07:57:21 +02:00
Jakub
9cabcd5ac7 feat: replace advert scan with active node discovery in NearbyScreen
NearbyScreen now sends CTL_TYPE_NODE_DISCOVER_REQ (same protocol as the
companion app) instead of a plain self-advert. Nearby repeaters, sensors
and room servers respond with their pub_key and type. Known contacts get
their lastmod refreshed; unknown nodes appear as temporary entries (e.g.
"Repeater") in the list until their advert is received.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-21 00:16:53 +02:00
Jakub
9427fa1999 fix: correct dual serial interface — routing, UI state, debug logging
- isConnected() returns true always (USB always available, mesh can send)
- isBLEConnected() added to BaseSerialInterface for BLE-specific UI/buzzer state
- MyMesh uses isBLEConnected() to update UITask connection indicator
- Disable BLE_DEBUG_LOGGING in dual build (would corrupt USB stream)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-20 18:24:55 +02:00
Jakub
1787752e82 feat: add dual BLE+USB serial interface for Wio Tracker L1
BLE takes priority when connected; USB is always ready as fallback.
Both state machines run continuously — no BLE disconnect on USB connect.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-20 18:20:10 +02:00
Jakub
6399df1f4a fix: improve buzzer volume control on nRF52
- Use inverted PWM polarity (0x8000) with PCT {2,5,12,25,50} giving
  ~6-8 dB perceptual steps (-24/-16/-9/-3/0 dB) vs the original
  uneven steps where levels 4 and 5 were only 1 dB apart
- Guard against cmp=0 truncation in both _nrfStartPwm and applyVolume:
  at level 1 with high notes (freq > ~2.5 kHz) integer math gives
  cmp=0 which with inverted polarity means 100% HIGH → complete silence
- Change volume preview note from C5 (523 Hz) to C6 (1047 Hz) to better
  match the piezo resonant frequency range and actual notification sounds

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-20 09:06:00 +02:00
Jakub
fa194016d7 feat: show message age (3m, 2h, >1d) in channel and DM history list
Stores RTC timestamp on each history entry and renders it right-aligned
on the sender row using a compact format (Xs/Xm/Xh/>1d).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-19 20:21:32 +02:00
Jakub
eee496b60b fix: add missing space after Type: and Seen: labels in NearbyScreen detail view
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-19 17:44:49 +02:00
Jakub
0f5740f6b6 fix: remove redundant slen clamp and update stale comment
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-18 18:20:42 +02:00
Jakub
34cfd27b8a fix: use @[nick] format for replies and fix fullscreen message display
- Reply prefix changed to "@[nick] " format — bracket delimiter handles
  nicks with spaces unambiguously
- FullscreenMsgView: parse "@[nick] body" to show "To: nick" header;
  fall back gracefully if format not matched
- Reduce FS_CHARS 21→20 to prevent scroll arrows overlapping last char
- Transliterate nick before displaying in "To:" header and "RE:" title
  so non-ASCII characters render correctly on the OLED font

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-18 18:18:45 +02:00
Jakub
b21bcb5ca4 fix: render reply popup in CHANNEL_HIST and DM_HIST phases
_ctx_menu.render() was only called in CONTACT_PICK and CHANNEL_PICK,
so the reply popup was active but invisible in history views. Added
render calls for list view and fullscreen view in both DM_HIST and
CHANNEL_HIST phases.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-18 16:11:25 +02:00
Jakub
6f7de3ed20 feat: add reply action to channel and DM message history
Long-press Enter (KEY_CONTEXT_MENU) on a selected message shows an
'Options / Reply' popup in both list and fullscreen views. Confirming
opens MSG_PICK with 'RE: nick' title — the reply can be sent via
keyboard or quick message templates, both automatically prefixed with
'@nick '.

- Channel: reply prefix extracted from 'sender: message' format
- DM: reply available only on incoming messages, uses contact name
- FullscreenMsgView: REPLY added to Result enum, KEY_CONTEXT_MENU handled
- MSG_PICK: _reply_mode flag routes prefix through keyboard and templates
- Guard: prevent sending empty reply (prefix-only keyboard input ignored)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-18 15:12:11 +02:00
Jakub
8f566732ed feat: show @recipient as 'To: nick' bar in fullscreen message view
When a message starts with @nick, the fullscreen view expands the header
to show a second row 'To: nick' below the sender name, and displays the
message body without the @nick prefix.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-18 15:00:01 +02:00
Jakub
9b61bc3028 fix: increase quick-message expansion buffer from 80 to 140 bytes
custom_msgs templates are up to 140 chars; the 80-byte msg[] buffer
silently truncated any message longer than 79 characters before sending.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-18 09:53:36 +02:00
Jakub
584ef33b3e fix: channel bot respects bot_enabled flag
tryBotReplyChannel checked bot_channel_enabled but not bot_enabled,
so disabling the bot via the main Enable toggle had no effect on
channel replies. Added bot_enabled to the guard condition.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-18 09:41:56 +02:00
Jakub
4df97ae5ed fix: persist auto_lock setting across reboots
auto_lock was defined in NodePrefs but missing from both loadPrefsInt
and savePrefs in DataStore.cpp. Added at the end of the serialization
chain (inside if(file.available())) for backwards compatibility with
existing saved files — old files default to auto_lock=0 (disabled).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-18 09:39:10 +02:00
Jakub
44122565f6 perf: query sensors once for both lock screen dashboard fields
Previously each LPP sensor field called querySensors() separately.
Now a single querySensors() call fills a shared buffer used by both fields.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-17 18:52:40 +02:00
Jakub
360d5d10f7 feat: add 30s minimum interval option to auto-advert screen
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-17 14:33:58 +02:00
Jakub
a2856b7a48 fix: lock screen wake window no longer extends on repeated key presses
Previously every key press while locked reset _lock_wake_until to now+5s,
so multiple presses (or spurious button events) kept extending the window.
Now the 5s timer is set only when the display first wakes from dark.
The unlock sequence still extends the window on each Back+Enter step.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-17 14:30:53 +02:00
Jakub
3fb0a55aef fix: auto-reset _lock_seq_used after 5s in case Back release event is missed
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-17 12:17:02 +02:00
Jakub
20e88443b4 fix: polish lock screen sequence — hints update instantly, screen stays on, triple-Back blocked
- Turn display on at first Back+Enter press so hints are visible even when screen was dark
- Extend _lock_wake_until on every sequence step to prevent screen blanking mid-press
- Set _next_refresh=0 on every Enter press (not just on completion) for immediate hint redraw
- Add _lock_seq_used flag to suppress the Back CLICK that fires on release after unlock
- Block triple-Back (buzzer toggle) when screen is locked

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-17 11:17:59 +02:00
Jakub
43f3621fdc fix: replace long-press lock trigger with back_btn.isPressed() check
Long press detection on back_btn was unreliable — the release generated
a spurious CLICK that cancelled the sequence. Now the Enter click handler
checks back_btn.isPressed() directly: holding Back and clicking Enter 3×
within 3 seconds locks/unlocks the screen.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-17 10:09:54 +02:00
Jakub
ef0241b5f3 feat: show two dashboard sensor values on lock screen
Reuses dashboard_fields[0] and [1] from NodePrefs — left-aligned and
right-aligned in one row under the clock, no labels to save space.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-17 10:04:28 +02:00
Jakub
9ff42a9296 feat: screen lock — hold Back + 3×Enter to lock/unlock
- Long press Back starts lock sequence; 3 Enter presses within 3s toggle lock
- Locked screen wakes for 5 seconds on any key, showing clock and unlock hint
- Incoming messages do not wake the display while locked
- Auto Lock setting in Display section: locks automatically when screen turns off
- Lock state persisted in UITask; NodePrefs gains auto_lock flag

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-17 09:55:51 +02:00
Jakub
b068318bc5 refactor: extract SettingsScreen and QuickMsgScreen to separate header files
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-17 00:12:40 +02:00
Jakub
a60ec376d7 perf: increase render interval on static screens from 300ms to 2000ms
Static screens (SettingsScreen, BotScreen, FullscreenMsgView, message
list, contact picker) were re-rendering every 300ms with no visible
benefit. New messages still trigger immediate refresh via newMsg() →
_next_refresh=100, so responsiveness is unchanged. Reduces unnecessary
SPI transfers and CPU wakeups ~6x on idle static screens.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 23:42:52 +02:00
Jakub
c4b152fd6a fix: clear arrow background in FullscreenMsgView to prevent text overlap
Text lines fill the full display width, causing the last chars to bleed
into the scroll arrow area. Draw a DARK fillRect behind each arrow before
rendering it, so the arrow appears on a clean black background without
truncating the text width.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 23:28:18 +02:00
Jakub
5d41812784 fix: separate DM and channel bot reply cooldown timers
Single shared _bot_last_reply_ms caused a DM reply to block the
channel bot for 10s and vice versa. Split into _bot_last_dm_reply_ms
and _bot_last_ch_reply_ms so each cooldown is independent.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 23:26:31 +02:00
Jakub
44b2519df4 fix: with_sender buffer too small and FS_LINE_H mismatch
- with_sender[160] could hold only ~160 chars but node_name(32) +
  expanded(200) needs up to 234; snprintf would silently truncate
  the UI display entry. Increased to 240.
- FS_LINE_H was 9 but Adafruit 5x7 font line height is 8, wasting
  1px per line and showing 5 lines instead of 6.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 23:23:20 +02:00
Jakub
1b9dc42250 fix: bot trigger matched against message body only, not sender name
Channel messages have the format "sender_name: body". The trigger was
being searched across the whole string, so a nick containing the trigger
word would fire a reply even with an unrelated message. Now the match
skips past the ": " separator and only checks the message body.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 23:19:12 +02:00
Jakub
5bc250888f fix: apply saved display brightness before UI task starts
Loading... screen was always shown at full brightness because prefs
are not yet loaded at that point. Apply setBrightness() in the first
common code path after the_mesh.begin() loads prefs, so at least the
tail of the loading screen and the entire splash screen respect the
saved brightness level.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 23:15:29 +02:00
Jakub
b91afa05b9 fix: reduce low battery shutdown text size to fit 128px OLED
Size 2 rendered text wider than display width. Switched to size 1
and adjusted y-positions to keep both lines visible.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 17:47:22 +02:00
Jakub
6a7f8b7ca7 fix: transliterate message text in FullscreenMsgView before wrapping
Raw UTF-8 message body was passed directly to display.print(), rendering
Polish and other accented chars as garbage on the Adafruit font.
Transliterating before wrapLines also fixes byte-count wrapping for
multi-byte UTF-8 characters.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 15:24:36 +02:00
Jakub
fbe636a05a feat: show plus version number on splash screen
Splash screen bar changes from "Plus for Wio" to "Plus 1.4 for Wio"
by extracting the suffix after "plus." from FIRMWARE_VERSION.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 00:33:13 +02:00
Jakub
9c40a253e2 update README and fix quick message / melody naming collision
- Expand README: ringtone editor now documents two melody slots, full
  note spec, and melody assignment to DM/channel notifications; settings
  section lists DM Melody and Channel Melody options; context menu
  description updated with melody override detail
- Rename quick reply template labels from M1-M10 to Q1-Q10 to avoid
  ambiguity with melody slot identifiers M1/M2
- Increase DM message history buffer from 32 to 64 entries

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 00:09:57 +02:00
Jakub
1d04930c1e quick fix 2026-05-15 16:33:19 +02:00