Comments (5)
Re your first bug, I can replicate this and will fix it.
I cannot replicate your issues with the custom times. These are class variables and it is necessary to set them prior to instantiating the class. The following script works with expected times (I have defined a release_func
to avoid triggering the above bug):
from primitives import Pushbutton
from machine import Pin
import asyncio
sel = Pin(16, Pin.IN, Pin.PULL_UP)
Pushbutton.long_press_ms=2000
Pushbutton.double_click_ms=1000
pb = Pushbutton(sel, True)
def f(a):
print(a)
pb.press_func(f, ('press',))
pb.long_func(f, ('long',))
pb.double_func(f, ('double',))
pb.release_func(f, ('release',))
async def main():
await asyncio.sleep(10)
asyncio.run(main())
I will amend the docs to clarify the use of the class variables.
If you are still encountering a problem with custom times, please provide a script which reproduces the fault.
from micropython-async.
I have now pushed a fix.
It is perhaps worth noting that setting suppress
in the absence of a release function is not an expected condition, since to quote from the docs:
Note:
suppress
affects the behaviour of therelease_func
only.
from micropython-async.
Hi Peter,
Thanks for your so quick action and fix !
I'll test your code above to couble-check whether or not the timing settings actually work, but so far my attempts here tended to demonstrate they didn't.
About suppress
not being intended to be used without a release function, it were my first experiments with these routines and I was testing different methods to check what behaviour was the best for what I intended to do...
That kind of tests tend to unearth unexpected bugs ;)
Many thanks again.
Also many thanks for the nice libraries that save me having to write tedious debouncing code, and asyncio helps much if writing my microcontroller application - I just discovered it and rewrote all of my code to use it, it's really much better this way !
from micropython-async.
I tested your code with the custom timings, and it actually works.
My mistake was that I had used mybutton.long_press_ms=2000
where it is Pushbutton.long_press_ms=2000
i.e. I thought it was a per-button setting, where it seems to be a global one.
from micropython-async.
Glad this is all OK now.
from micropython-async.
Related Issues (20)
- Scheduling HOT 11
- Pushbutton double and long press events HOT 3
- as_GPS problem HOT 5
- ThreadSafeQueue import error HOT 1
- Asyncio and sending serial data to SIM7600 (SMS) HOT 2
- __init__.py: import of Encoder fails. HOT 2
- Queue task_done/join enhancement HOT 3
- `uasyncio` is now renamed to `asyncio` in latest HOT 2
- coroutine not recognized HOT 1
- Feedback related to Quadrature Encoder HOT 1
- Where is ESwitch? HOT 2
- Course/compass direction - wild fluxuations. HOT 2
- Feature request - WaitAny accepts task HOT 3
- question? HOT 2
- queue.py: Tuples are not read back correctly HOT 2
- Import uasyncio HOT 2
- Question about sharing data beween async and non ansync tasks HOT 7
- Detected simultaneous button presses with SwArray HOT 2
- apologies for using this channel. Would you be available for a short consultation gig?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from micropython-async.