Commit 0b63b6e
Ravi Singh
feat: robust pairing flow + motion v3 (Kalman) + debounced UI saves
Pairing flow (PR-A):
- mesh.c broadcasts MSG_PAIR every 1s while pairing window open
- Asymmetric pairing: receiving MSG_PAIR auto-opens own window — clicking
Pair on either device pulls the other in (no need to tap both)
- mesh_identify(mac) unicasts MSG_IDENTIFY; recipient blinks status LED
at 10 Hz for 5 s so users can physically locate which board is which
- Coordinator election now has 5 s hysteresis — prevents brief flap when
a single heartbeat is dropped
- mesh_event_cb_t: peer-joined / pairing-opened/closed / identify-requested
events surface to main.c which drives the status LED reactions
- POST /api/mesh/identify {mac} endpoint
- GET /api/mesh now returns pairing/pairing_ms_left/my_mac for live UI
countdown and self-vs-peer card highlighting
Status LED:
- New STATUS_LED_PAIRING (5 Hz) and STATUS_LED_IDENTIFY (10 Hz) patterns
- status_led_oneshot(pattern, ms) — temporary pattern with auto-revert
to last stable pattern; identify becomes one line in main.c
Button (new component):
- Polling-based long-press detector (50 Hz, 40 ms debounce)
- 3 s long-press → mesh_open_pairing(); 10 s reserved for v6.1 factory reset
Motion v3 (PR-B):
- New motion_kalman.{c,h}: 1-D Kalman over [position, velocity], energy-
aware observation noise (R *= 4 when energy < 30), ±200 cm/s velocity
clamp, 3-sample direction hysteresis
- motion.c integrates: motion.mode NVS string ("kalman" default | "pi"),
motion.resp 0..100 (Calm⇄Snappy), motion.la_ms 0..500, motion.outl 0/1/2
(Off / median-3 / median-7); legacy ps/vs/pf/pg/ig kept as advanced
- motion_reload() called by /api/settings POST so changes apply live
Frontend:
- ScreenMesh: SVG circular pairing countdown, per-peer Identify button
with "Blinking…" 5 s cooldown, self-card highlight
- ScreenMotion: Algorithm picker (Kalman/Legacy PI), Response slider with
context-aware hint text, Look-ahead-ms slider, Outlier segmented control,
collapsible Advanced (5 PI knobs)
- New atoms icons: link, plus, search
Debounced saves (fixes ERR_CONNECTION_RESET):
- useDebouncedSave hook: 300 ms tail; coalesces multiple slider changes
into one POST /api/settings batch. Fixes the C3-single-core httpd
saturation when sliders fired ~30 POST/s during drag (verified with
50× rapid POST stress test — all 200 OK)
Verified: idf.py build green; ambisense.bin 1.17 MB / 1.4 MB partition
(18% free); both C3s flashed; /api/mesh, /api/settings round-trip works.1 parent d88bd66 commit 0b63b6e
20 files changed
Lines changed: 1056 additions & 153 deletions
File tree
- firmware
- components
- button
- include
- mesh
- include
- motion
- include
- status_led
- include
- webui
- main
- frontend/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
56 | 58 | | |
57 | 59 | | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
58 | 79 | | |
59 | 80 | | |
60 | 81 | | |
| |||
0 commit comments