setwatch doesn't work stable #4521
Replies: 1 comment
-
Posted at 2015-03-15 by fobus smilar error occurs on the boards button BTN1, but it is more stable. Posted at 2015-03-16 by @allObjects Assuming the firmware is ok, I would go for a not really working button... or - because the trigger is on both edges, it may not work by definition (which would though contradict the reference doc which implies both edges work by design). So far, I used buttons - setWatch() - only in one way... If needed it two ways, I do the not-repeat one one edge, but on event, do the other edge... (see Software Buttons - Many buttons from just one hardware button. Note: Because it was very early on in my Espruino experience, I did not use the times delivered with the event... today I would do so and it for sure would render in more terse code...). In this post about Resistive Touchscreen directly (no touch controller) I use setWatch() too with no glitches what so ever... Tat's why I go for a bad button (assume too that your non-standard board and firmware has not 'sicknesses'... and also that your wiring does not add additional bouncing when operating the button...). Posted at 2015-03-16 by fobus I have coded a class for this problem. Works great and stable for me. I'm sharing it.
Posted at 2015-03-16 by @gfwilliams I'm not sure why you'd get 'noise' when the button isn't pressed unless there was a short somewhere (are you able to check and see if the pulldown actually worked?). With only a 10ms debounce you'd definitely expect some bouncing to occur when the button was pressed though - I'd probably suggest 50ms as a good number. While your code will work, it'll mean that the CPU isn't able to sleep and save power. While not a problem on the F4DISCOVERY (the board is power-hungry anyway!) I wouldn't recommend using the code on something where you care about power consumption :) Posted at 2015-03-16 by fobus @gfwilliams Debounce doesn't help me, I have tried various variables. from 1 to 300. I'm trying more than one button, I think it is not a mechanical problem. Power saving is not important for me at the moment, I'm pluging it to direct electric source. Posted at 2015-03-16 by @allObjects Polling eats away from doing more of the other stuff... so figuring out where the noise comes from seems to me beneficial anyway. Of course, it all depends... ...on how much other stuff is running and how time critical it is... Did you time/profile the class? Posted at 2015-03-16 by fobus No I didn't check time/profile, I don't have any idea how to check it. Posted at 2015-03-16 by DrAzzy Uh - wait, is time passing at the correct speed?
How can time be earlier than lastTime? Posted at 2015-03-16 by fobus Yes, I have copied and paste it here. All outputs are correct. Posted at 2015-03-16 by DrAzzy I'd manually try a few getTime()'s at the console, and make sure that it increases at a rate of one second per second. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2015-03-15 by fobus
Hello,
I'm using setwatch to detetch keypress events. I wired up a pin as button. Voltage flows as "5V -> Button -> E2 Pin"
I'm using STMF32F4 Discovery.
Here is my code :
Some times it prints console while I'm not pressing button. Some times prints 2-3 times on a button press. Some times it doesn't print anything. So, I can't understand which is the real button press event;
Here is the output :
Beta Was this translation helpful? Give feedback.
All reactions