blob: 25a33aa1eb9dafa4180ca389d063426ba572ce48 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
-- allows to interrupt start up in the first 5 seconds by hitting <ENTER>
-- borrowed from https://bigdanzblog.wordpress.com/2015/04/24/esp8266-nodemcu-interrupting-init-lua-during-boot/
function abortInit()
-- initailize abort boolean flag
abort = false
print('Press ENTER within 5 seconds to abort startup')
-- if <CR> is pressed, call abortTest
uart.on('data', '\r', abortTest, 0)
-- start timer to execute startup function in 5 seconds
tmr.create():alarm(5000,tmr.ALARM_SINGLE,startup)
end
function abortTest(data)
-- user requested abort
abort = true
-- turns off uart scanning
uart.on('data')
end
function startup()
uart.on('data')
-- if user requested abort, exit
if abort == true then
print('startup aborted')
return
end
-- otherwise, start up
print('in startup')
dofile('main.lua')
end
tmr.create():alarm(1000,tmr.ALARM_SINGLE,abortInit) -- call abortInit after 1s
|