Problem with edge:"rising" #221
Replies: 11 comments
-
Posted at 2014-02-07 by @gfwilliams Hi bret, Yes, this is because there's no switch debouncing built in to Espruino. There's an issue on GitHub open for this as it'd be nice if you could just say:
It's been relatively low priority so far I'm afraid though! |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-02-07 by bret Hi Gordon, Thank you for verifying what I was seeing and explaining that there was no debouncing in version 1v50. It would certainly be very useful to make projects more reliable and have a polished, quality feel. As I write this and check out the issue on GitHub, it looks like you've added the functionality. Thank you very much for that. I look forward to trying it out! Thanks again for creating and sharing Espruino with the world. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-02-12 by user6438 Hi. My first evening with Espruino... and my first program seems to have a lot in common with this thread...
The intention is that for every press of the button the LEDs count in binary from 000 to 111... Seems to work! Thanks! |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-02-12 by BogdanG I tested simple de-bouncer. The setWatch is used once, then re-enabled after a period of 200ms just after the associated function is called:
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-02-12 by BogdanG I tested this de-bouncer on VL Discovery (BTN1 is an alias to the button available on this board). Not sure if the BTN1 name works on other boards |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-02-12 by randunel Nice solution, Bogdan. I would improve it to allow passing params from one to another, so you would not need to use globals. This does degrade readability though:
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-02-13 by @gfwilliams I should point out that version 1v51 (in development) has debounce, so I wouldn't worry too much about this unless you want to do it for fun :) You can get the development build from www.espruino.com/binaries/git for the Espruino board or https://espruino-nightly.noda.se/ for others. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-02-13 by tage A related question is if the RotaryEncoder module has debounce? I noticed that for each click when I turn the knob I always get four pulses. fortunately that is easy to work around. I have not checked the waveforms from the mechanical encoders yet, but I am using two, and one with and one without RC filter for debouncing. Both give four counts per click. (Mecanical encoders have a lot of contact bounce and need to have hardware or software debouncing) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-02-13 by @gfwilliams The encoders have a really messy waveform but they cope quite well. When 1v51 comes out I'll enable debounce though. 4 counts per click is expected (I was surprised too). Each click represents a whole round of 00,01,11,10 |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-02-13 by tage
this is my workaround for getting one count per click (probably there is a more elegant way - I am new to javascript..) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-03-02 by hcchen I am sure v1.52 is fine. Try, |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2014-02-06 by bret
In another post about the LED and button tutorial, the following was stated:
I used that code but sometimes when I press the button once, my function gets called twice. I thought maybe I was being careless and tried very carefully to press and release it without any hesitation. I found that, no matter how careful I was, sometimes the function would get called once and sometimes 2-3 times. I changed the code to use "falling" instead and it seems to work reliably - the function only gets called once per button press.
Has anyone else experienced this behavior? Perhaps there is a bug? Is the switch debouncing implemented in hardware or software with Espruino?
Beta Was this translation helpful? Give feedback.
All reactions