Repository navigation
Commit 67f21fe
add touch-sync usermod: UDP sensor-event bus for cross-device effects (#3)
* add touch-sync usermod: UDP sensor-event bus for cross-device effects
New usermods/ampworks/usermod_touch_sync.h (USERMOD_ID_TOUCH_SYNC=56) broadcasts
MPR121 press/release edges as typed sensor-event packets over UDP broadcast and
receives remote events into a ring buffer. Touch Pond drains the queue and spawns
distinct-hue waves for remote touches; the effect now also runs on sensor-less
display-only nodes. Registered behind -D USERMOD_TOUCH_SYNC in the ampworks env.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
* redesign touch-sync wire format: generic header + per-sensor data
Addresses review on PR #3:
- Generic 4-byte-aligned TouchSyncHeader (magic 'ATS1', version, msgType,
sensorType, dataLen, deviceId, seq, timestamp) common to all sensor types;
per-type data struct follows, length carried in header.dataLen.
- Send ALL MPR121 sensors (12 electrodes + proximity) in one snapshot message
(TsTouchData bitmask) instead of one packet per electrode edge.
- Receiver derives per-device rising/falling edges from successive snapshots and
enqueues discrete RemoteSensorEvents; consumer API (popRemoteEvent) unchanged.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
* rename touch-sync -> sensor-sync; producer-side edges; split .h/.cpp
Addresses review on PR #3:
- Rename usermod touch_sync -> sensor_sync (file, class UsermodSensorSync,
USERMOD_ID_SENSOR_SYNC, -D USERMOD_SENSOR_SYNC, structs, magic 'AMPS') since
the bus carries all sensor types, not just touch.
- Producer derives rising/falling edges once and transmits them (SensorEdge
records, all changed channels in one message); consumers read edges directly,
removing per-consumer peer-snapshot state and the associated edge re-derivation.
- Split into usermod_sensor_sync.h (struct defs + prototypes) and
usermod_sensor_sync.cpp (implementations), per the .h-decls-only preference.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
* revert to producer-snapshot + consumer-side edge derivation
Per follow-up on PR #3: move edge derivation back to the consumer. The producer
broadcasts a full SensorSnapshot (channel bitmask) whenever its state changes; each
consumer keeps the last snapshot per origin device and diffs to derive edges. This
restores self-healing resync (a dropped datagram is corrected by the next snapshot)
that the producer-side-edge approach lost. Keeps the sensor_sync rename and .h/.cpp
split. Also: send only advances prevLocalMask on success; meaningful static_assert on
the data-struct size.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
* widen deviceId to 32-bit FNV-1a hash of full MAC
Per follow-up on PR #3: the 16-bit low-2-MAC-byte id discarded mac[3] and was
birthday-limited (~0.3% collision at 20 devices). deviceId is now a 32-bit FNV-1a
hash of the full 6-byte MAC, collision-free in practice at fleet scale; explicit
`id` config override retained. Wire-format change: header grows to 20 bytes (added
a reserved u16 to keep timestamp 4-byte aligned), version bumped to 5; deviceId
fields in the header, RemoteSensorEvent, and per-peer state widened to u32.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
---------
Co-authored-by: aphelps-claude-bot <[email protected]>
Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>1 parent c6941cf commit 67f21fe
6 files changed
Lines changed: 358 additions & 8 deletions
File tree
- usermods/ampworks
- wled00
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
448 | 448 | | |
449 | 449 | | |
450 | 450 | | |
451 | | - | |
| 451 | + | |
452 | 452 | | |
453 | 453 | | |
454 | 454 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
5 | 8 | | |
6 | 9 | | |
7 | 10 | | |
| |||
323 | 326 | | |
324 | 327 | | |
325 | 328 | | |
326 | | - | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
327 | 335 | | |
328 | 336 | | |
329 | 337 | | |
| |||
334 | 342 | | |
335 | 343 | | |
336 | 344 | | |
337 | | - | |
| 345 | + | |
338 | 346 | | |
339 | 347 | | |
340 | 348 | | |
| |||
346 | 354 | | |
347 | 355 | | |
348 | 356 | | |
| 357 | + | |
| 358 | + | |
349 | 359 | | |
350 | | - | |
| 360 | + | |
351 | 361 | | |
352 | | - | |
| 362 | + | |
353 | 363 | | |
354 | 364 | | |
355 | 365 | | |
| |||
378 | 388 | | |
379 | 389 | | |
380 | 390 | | |
381 | | - | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
382 | 407 | | |
| 408 | + | |
383 | 409 | | |
384 | 410 | | |
385 | 411 | | |
| |||
397 | 423 | | |
398 | 424 | | |
399 | 425 | | |
400 | | - | |
| 426 | + | |
401 | 427 | | |
402 | 428 | | |
403 | 429 | | |
| |||
447 | 473 | | |
448 | 474 | | |
449 | 475 | | |
450 | | - | |
| 476 | + | |
| 477 | + | |
451 | 478 | | |
452 | 479 | | |
453 | 480 | | |
| |||
| 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 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
0 commit comments