I need node.key() This module avaitable only in old version firmware build20150127 and older. How I can do it?

I write this code:
pin = 0
gpio.mode(pin, gpio.INPUT)
pressed = false
started = 0
tmr.alarm(6, 50, 1, function()
if gpio.read(pin) == 0 then
if not pressed then
started = tmr.now()
end
pressed = true
gpio.write(pin, 1)
gpio.mode(pin, gpio.INPUT)
else
if pressed then

if tmr.now() – started > 3000000 then
print(‘Long press’)
else
print(‘Short press’)
end

pressed = false
end
end
end)

How I do it this old functions:
node.key(‘long’, function()
\–[HERE my make code for long or short press button]
end)
or how create new module with this function?
Please help me.
Thanks
~kszere

Leave a Reply

Your email address will not be published. Required fields are marked *

Captcha loading...