Skip to content

Fix UART caps LED leak, framed Fn+1 ESC, and modifier state leak on mode switch#1

Merged
hlym123 merged 4 commits into
m5stack:mainfrom
GOB52:pr/uart-mode-fixes
May 27, 2026
Merged

Fix UART caps LED leak, framed Fn+1 ESC, and modifier state leak on mode switch#1
hlym123 merged 4 commits into
m5stack:mainfrom
GOB52:pr/uart-mode-fixes

Conversation

@GOB52

@GOB52 GOB52 commented May 19, 2026

Copy link
Copy Markdown
Contributor

Summary

Three bug fixes for UART mode, all observed and reproduced on hardware.
Also includes a FIRMWARE_VERSION 0x01 → 0x02 bump so host-side libraries can detect the fixed build.

  1. Caps one-shot indicator LED stays lit in UART/ESP-NOW modes
  2. Fn + 1 (ESC) is sent as a raw byte instead of a framed event in UART mode
  3. Modifier state and LED leak into the new mode after Fn + Sym + N

1. Caps one-shot LED stays lit in UART/ESP-NOW modes

After Aa is tapped (one-shot uppercase armed → green LED on), the next alphabetic key is correctly returned as uppercase and the host sees lowercase from then on, but the green LED never clears. app_clear_caps_one_time() is only called from the I2C / BLE HID ASCII output branch, so caps_one_time stays set in UART/ESP-NOW. Fix: add a mode-independent caps consumer that fires when a Latin letter is pressed.

2. Fn + 1 (ESC) sent as raw byte in UART mode

This was previously flagged and acknowledged in earlier correspondence (developer's answer: "Right, I overlooked that. It should send an ESC event, just like in I2C mode.") but the fix isn't yet in the current 444b5bd snapshot. The ESC branch for UART sends a bare `0x1B` via `bsp_uart_send()`, which hosts parsing the 5-byte `{0xAA, 0x03, key_id, state, checksum}` frame format drop. Fix: use `app_send_uart_frame(KEY_ESC, true)` so the ESC press is delivered as a regular framed key event.

3. Modifier state / LED leak across mode switch

Steps to reproduce: tap `Sym` (blue LED), then `Aa` x2 (caps lock → cyan LED), then `Fn + Sym + 1`. After the white blink the LED stays cyan and the new mode boots with `sym_mode` and `caps_locked` still engaged. `app_mode_apply()` re-initialises peripherals but leaves modifier flags untouched, and `app_led_blink_white()` restores the pre-switch `current_r/g/b`. Fix: clear `sym_mode`, `sym_pressed`, `fn_pressed`, `caps_one_time`, `caps_locked`, `caps_hold` and refresh the LED at the end of `app_mode_apply()`.

Reproduction

# Operation Before After
1 UART: `Aa` tap → `q` → `q` `Q`, `q` (correct), LED green stays on LED clears after second `q`
2 UART: `Fn + 1` Host receives nothing Framed ESC press event received
3 Any mode: Sym + Caps active, then `Fn + Sym + 1` New mode boots with cyan LED, sym/caps still engaged New mode boots black, modifier flags cleared

If a fix for any of these is already prepared in an internal branch, or if this isn't the right repository, apologies for the noise — feel free to close.

GOB52 added 4 commits May 19, 2026 17:15
The caps one-shot indicator (green LED) never cleared after the next
alphabetic key press in UART or ESP-NOW modes, because
app_clear_caps_one_time() was only called from the I2C/BLE HID ASCII
output branch. Add a mode-independent caps consumer that fires when a
Latin letter is pressed (excluding modifier keys and Fn-combined
presses).
The Fn+1 ESC branch for UART sent a bare 0x1B via bsp_uart_send,
which hosts parsing the 5-byte {0xAA, 0x03, key_id, state, checksum}
frame format drop. Replace with app_send_uart_frame(KEY_ESC, true) so
ESC presses are delivered as regular framed key events, matching the
host UART protocol used by the rest of the keys.
app_mode_apply() re-initialised the comms peripherals but left the
modifier flags untouched. Combined with app_led_blink_white() then
restoring the previous current_r/g/b, the new mode would boot with
Sym/Caps/Fn flags still engaged and the LED in the pre-switch colour
(e.g. cyan when both Sym and Caps were active). Clear the modifier
flags and refresh the LED at the end of app_mode_apply() so each new
mode starts clean.
Mark this build as containing the fixes applied in the preceding three
commits so host-side libraries can distinguish the patched firmware
from the original (0x01) via the I2C version register and the
AT+VERSION? production-test command.
@hlym123 hlym123 merged commit cdbf0c9 into m5stack:main May 27, 2026
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants