Strange behavior by pressing BTN #6168
Replies: 1 comment
-
Posted at 2019-07-17 by @gfwilliams What you're doing there looks fine to me... You could try:
instead of
I thought debounce on the button should have been automatic but maybe it's not... What can happen is the button actually physically bounces - effectively making two presses. Too fast for a human to see but the microcontroller picks it up. Having Or... what may be happening is you have the code saved twice somehow (once direct to flash, and once from Hope that helps! Posted at 2019-07-17 by PeterD Ive tried debounce before, bit it didn't't help. But !!!! Reset(1) + direct to flash and without save() did the job ;) Posted at 2019-07-17 by @allObjects Because you did the save directly to flash AND did a save() too, you got two watches going on... you do either or... just not both... . Better would be to put your setWatch() into an onInit() function. That's the clean way to make sure what is going on when power cycling. You may even put your counter initialization there, because if you go with save but play a bit before executing the save() command, you save an already incremented counterand and it will start over with the already incremented counter rather than with 0 on power cycle. Take a look at conversation about simple explanation how to save code that espruino run on start? and related ones. It is not anymore all there is because Espruino has evolved and offers additional options, but the explained concepts still apply. If you want to keep the counter going beyond a single power cycle you save its value into the flash store on every increment and pick it up from there in the onInit() for resuming with last value on power cycle. I hope this helps. Posted at 2019-07-17 by Robin Wed 2019.07.17 Hi @user101874,
That 'somewhere' might have been here:
> 'I'm new to Espruino and Java, so it is possible that I'm asking stupid questions ;)' Okay, you did qualify your statement, and to expand that awareness . . . Espruino runs a
"Java was originally developed by James Gosling at Sun Microsystems (which has since been acquired by Oracle) and released in 1995" Brendan Eich developed Javascript and was released with Netscape Navigator with the name |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2019-07-17 by PeterD
Hi,
I've tried to write a program for the Espruino.
I'm new to Espruino and Java, so it is possible that I'm asking stupid questions ;)
I have a Espruino Classic with a ILI9341 connected.
If I run the program while the PC is connected to the board, It works fine.
But when I change (In communications - Save on Send) Direct To Flash, the preset variable "HomeScore" shows "2" on the display, and when pressing the BTN, It goes up with 2 counts or sometimes 3 counts.
Is this a known error, or do I something wrong?
Regards,
Peter
Beta Was this translation helpful? Give feedback.
All reactions