One or double click the button and time duration for long or short press? #4928
Replies: 1 comment
-
Posted at 2015-08-23 by @gfwilliams @allObjects made some code to handle this - there's a post on it here: http://forum.espruino.com/conversations/1781/ It might be quite fun to do it yourself though. Using setWatch it's pretty easy to measure the time between button presses and to set/cancel timeouts. Posted at 2015-08-23 by @gfwilliams And doing short and long press is very easy:
Posted at 2015-08-23 by bigplik Hi, I was trying to set led to turn it on or off depends of how long I press the button, I used your code above.
but I have same sequence on the board, when press the button my LED(D23) is ON for a 1000ms and then off, so when I press button short or long time not change nothing Posted at 2015-08-24 by @gfwilliams Unless I'm totally misunderstanding, you need to actually check the value in the
It's still going to get a bit confusing though - it'd be easier to check if you had 2 different LEDs. Posted at 2015-08-24 by bigplik cool, thank you, it is working now ;) Posted at 2015-08-24 by @gfwilliams Great! Espruino is actually JavaScript, not Python. The thing that you will find strange is the 'event-based' nature of JavaScript that is different to most C code. It does have its advantages though! Espruino's JavaScript is the same as 'strict' JavaScript - it is missing one or two features that you might find in desktop JavaScript (like regular expressions), but there are no language features specific to Espruino. There are one or two extra functions in Espruino though - like Learning some JavaScript might help, but I think you would find it easiest just to experiment on Espruino itself. It's really quite easy once you get over the initial hurdles. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2015-08-22 by bigplik
hi anyone tried to deal with this? I mean that could help to control few functions just by one button,
I've seen some tutorials for Arduino, is anything for Espruino as well?
Beta Was this translation helpful? Give feedback.
All reactions