Add event service for gestures, button actions, and raw message bus events#124
Add event service for gestures, button actions, and raw message bus events#124microbit-matt-hillsdon merged 1 commit intoappsfrom
Conversation
|
For discussion/experimentation rather than a quick review + merge. |
|
Had a play and it looks good. It was a bit unexpected that the Gestures section would affect the Raw Events section. Listening to gestures would cause it to stream raw events, and stopping listening to the gestures would not stop gesture raw events, but after some thought, it makes sense because gestures get subscribed. Also, not sure if there is a root for getting the touch logo press event as well. |
|
I've tried to separate out the notifications so you only get low level ones if you ask for them. I've added the logo as a button and it seems to work well. I also added detail to the demo about what requires what service as otherwise the split of the button-related behaviours is inexplicable (similar to JSDoc already added). |
microbit-grace
left a comment
There was a problem hiding this comment.
LGTM, glad adding logo press was straightforward!
…bus events Expose the micro:bit's BLE Event Service as high-level typed events (gesturechanged, buttonaaction, buttonbaction, buttonabaction, logoaction) and a low-level microbitevent channel for arbitrary message bus traffic via subscribeToEvent/sendEvent. Named events demux incoming notifications by source ID (V1 DAL / V2 CODAL) so listeners receive structured data without needing to know the underlying message bus layout. The raw microbitevent channel is opt-in: only events matching explicit subscribeToEvent registrations are dispatched, keeping it isolated from the named event traffic. Client requirements and BLE notification subscriptions are replayed on reconnect so the micro:bit re-registers its event forwarding. Adds an Events tab to the demo app for interactive testing.
6d84c6a to
8455a6a
Compare
|
Thanks. Pushed a rebase with a better message but otherwise unchanged. Will merge once built in CI. |
Pin events can be added as a high-level feature later if there's demand. They make much less sense for a general purpose "control/monitor the micro:bit over BLE" program. Though maybe useful for digital twin projects as they can observe pins without changing the pin mode (but can't read values, just transitions).
For now they're accessible via the numeric API with CODAL/DAL constants in the user program.
I do slightly wonder what the point of the button service is now...