Hi, hoping somebody can help - even if just by reproducing tthe issue I am seeing.
I have used Peter Hinch’s excellent asyncio repo extensively see here… it has many fantastic modules, including a Pushbutton class, which I’ve been happily using for over a year. So… got a PCB fabbed for my project, so I can migrate off the dodgy breadboard setup my prototype is currently running on. And that’s where the problems surfaced…
I have a 5-way (up/down/left/right/OK) navigation switch… that would not work on my PCB. I suspected ground loop issues. Nope. Same result when I ran the Pico on a second bare-bones breadboard. Changed EVERY component of my setup .. same. Tried a different Pico. Tried re-flashing. Tried different versions of MicroPython. Nup.
The core issue (sorry for the pun) is that the Pushbutton driver uses a delay_ms.py and launch.py…to achieve both debounce, double-click and long-click processing. Nice. Except… this now FAILS. Serious fail… as in:
Task exception wasn’t retrieved
future: coro= <generator object ‘_timer’ at 20013f90>
Traceback (most recent call last):
File “asyncio/core.py”, line 1, in run_until_complete
File “delay_ms.py”, line 49, in _timer
TypeError: ‘module’ object isn’t callable
Is there anyone else using Peter Hinch’s async repo that I can compare notes with? Having changed everything… I am kinda desperate for some fresh eyes,
Thanks,
T
Hi!
From the error you have shared it looks like the delay_ms might be imported incorrectly. _timer expects a fuction oe class, so if the module itself is called, it will fail.
You just try few things:
- Check that you’re importing exactly what pushbutton expects from delay_ms.py
- Test a minimal setup with only one pushbutton on your PCB.
- Double check wiring and switch orientation against your breadboard version.
- Make sure you are using the latest version of Peter Hinch’s repo
Try these things and tell me is it working or not.
Thanks @Aakriti314205 for your input - appreciated.
Yes I check Peter’s repo… there has been no change since I grabbed his code, but note that I have both a) Peter’s original delay_ms (causing crashes)… and b) a cutdown minimal version I have been using for over a year, which is similar, but not identical (it does NOT call the _timer method…) but I am going down rabbit holes. My problem surfaced (initially) using the cut-down version… worked on my prototype… but failed on PCB, and also on my bare-bones B/B. This gets a bit convoluted… stick with me, I am determined to crack this tonight!
I have cut down to a single pushbutton on my breadboard… NOTHING else. So there is not much wiring to check!! I assure you, this weirdness is no simple wiring issue. I am however, seeing other unexpected behaviour, and am now documenting everything I do, every change I make. There is clearly something sus going on… at the MicroPython level, as I just had a 100% perfect operation, using my original Pico, but on a stripped down breadboard… and then in the VS terminal… I got no response… eventually followed by this: (the numbers are just my quick way of testing REPL response… type a number, it should be echoed back. It isn’t…)
>>> Error executing commandException occured
>>>
>>> 1
>>>
>>>
>>> 2
>>> Error executing commandException occured
>>>
>>> 7
>>> Error executing commandException occured
>>>
>>> 5
>>> Error executing commandException occured
So the REPL was NOT responding normally.
I will continue methodical testing and documenting… I now suspect it may have something to do with my import statements… we’ll see (hopefully, before the night is over!)
If you have a Pico 2 and a pushbutton switch… and Peter’s Pushbutton class etc… I’d REALLY appreciate it if you could do a test… but let me poke around a bit more first.
Cheers, T
Problem solved… I discovered my “new” Pico 2 had a slightly different version of launch.py than the old one. No idea how/when that happened. And that is why nothing worked properly.
Peter has recommended I install his full repo on my Picos… had I done that way back, this issue would perhaps never have arisen. Dang…
Cheers,
T.
2 Likes
Ahh makes sense now. Those small version changes can cause big issues.
I’m glad you got it working.
1 Like
Diagnosing this was made more difficult as there were actually two contributing factors (mabe three… if you include my stupidity)
- I messed up the import . Don’t know why I changed it…
- I was using an erzatz launch method - as I could not find Peter’s offical one (now solved)
When I started this project, a) I had never used Python, b) I had never used microcontrollers, and c) it began on a Pico 1… with limited resources. Which contributed to my NOT installing Peter’s repo in full (space consideratons). WHich led to problems downstream.
I’ve learned a lot since then
Good news is that last night I got my made codebase working on my PCB platform… albeit I still have some strange voltages messing up some functions, but that is a whiole other story…
Thanks for you comments. In particular, the one about importing and modules… there was a hint in the error message, I was too focussed on the “launch” failure to heed it.
Cheers,
2 Likes