@@ -32,7 +32,8 @@ goes outside defined bounds.
32
32
33
33
# 2. Installation and usage
34
34
35
- The drivers are in the primitives package. To install copy the ` primitives `
35
+ The drivers require a daily build of firmware or a release build >=1.15. The
36
+ drivers are in the primitives package. To install copy the ` primitives `
36
37
directory and its contents to the target hardware.
37
38
38
39
Drivers are imported with:
@@ -158,20 +159,21 @@ Constructor arguments:
158
159
159
160
Methods:
160
161
161
- 1 . ` press_func ` Args: ` func ` (mandatory) a ` callable ` to run on button push.
162
- ` args ` a tuple of arguments for the ` callable ` (default ` () ` ) .
163
- 2 . ` release_func ` Args: ` func ` (mandatory) a ` callable ` to run on button
164
- release. ` args ` a tuple of arguments for the ` callable ` (default ` () ` ) .
165
- 3 . ` long_func ` Args: ` func ` (mandatory) a ` callable ` to run on long button
166
- push. ` args ` a tuple of arguments for the ` callable ` (default ` () ` ) .
167
- 4 . ` double_func ` Args: ` func ` (mandatory) a ` callable ` to run on double
168
- push. ` args ` a tuple of arguments for the ` callable ` (default ` () ` ) .
162
+ 1 . ` press_func ` Args: ` func=False ` a ` callable ` to run on button push,
163
+ ` args=() ` a tuple of arguments for the ` callable ` .
164
+ 2 . ` release_func ` Args: ` func=False ` a ` callable ` to run on button release,
165
+ ` args=() ` a tuple of arguments for the ` callable ` .
166
+ 3 . ` long_func ` Args: ` func=False ` a ` callable ` to run on long button push,
167
+ ` args=() ` a tuple of arguments for the ` callable ` .
168
+ 4 . ` double_func ` Args: ` func=False ` a ` callable ` to run on double push,
169
+ ` args=() ` a tuple of arguments for the ` callable ` .
169
170
5 . ` __call__ ` Call syntax e.g. ` mybutton() ` Returns the logical debounced
170
171
state of the button (` True ` corresponds to pressed).
171
172
6 . ` rawstate() ` Returns the logical instantaneous state of the button. There
172
173
is probably no reason to use this.
173
174
174
- Methods 1 - 4 should be called before starting the scheduler.
175
+ Methods 1 - 4 may be called at any time. If ` False ` is passed for a callable,
176
+ any existing callback will be disabled.
175
177
176
178
Class attributes:
177
179
1 . ` debounce_ms ` Debounce time in ms. Default 50.
@@ -188,12 +190,12 @@ def toggle(led):
188
190
led.toggle()
189
191
190
192
async def my_app ():
193
+ pin = Pin(' X1' , Pin.IN , Pin.PULL_UP ) # Pushbutton to gnd
194
+ red = LED(1 )
195
+ pb = Pushbutton(pin)
196
+ pb.press_func(toggle, (red,)) # Note how function and args are passed
191
197
await asyncio.sleep(60 ) # Dummy
192
198
193
- pin = Pin(' X1' , Pin.IN , Pin.PULL_UP ) # Pushbutton to gnd
194
- red = LED(1 )
195
- pb = Pushbutton(pin)
196
- pb.press_func(toggle, (red,)) # Note how function and args are passed
197
199
asyncio.run(my_app()) # Run main application code
198
200
```
199
201
0 commit comments