mirror of
https://github.com/undera/pylgbst.git
synced 2020-11-18 19:37:26 -08:00
Change button callback into 3-state
This commit is contained in:
parent
544aa82cf5
commit
6ad116fe1c
@ -34,3 +34,10 @@ def callback(is_pressed):
|
||||
hub = MoveHub()
|
||||
hub.button.subscribe(callback)
|
||||
```
|
||||
|
||||
The state for button has 3 possible values:
|
||||
- `0` - not released
|
||||
- `1` - pressed
|
||||
- `2` - pressed
|
||||
|
||||
It is for now unknown why Hub always issues notification with `1` and immediately with `2`, after button is pressed.
|
@ -660,4 +660,4 @@ class Button(Peripheral):
|
||||
:type msg: MsgHubProperties
|
||||
"""
|
||||
if msg.property == MsgHubProperties.BUTTON and msg.operation == MsgHubProperties.UPSTREAM_UPDATE:
|
||||
self._notify_subscribers(bool(usbyte(msg.parameters, 0)))
|
||||
self._notify_subscribers(usbyte(msg.parameters, 0))
|
||||
|
Loading…
x
Reference in New Issue
Block a user