module(..., package.seeall)
require 'pins'
local btnDown = false
local st = 0
pins.setup(pio.P0_2, function()
if btnDown then
local d = os.time() - st
if d > 4 then
log.info('BUTTON', 'RESTORE DEVICE...')
assert(false)
elseif d > 1 then
log.INFO('BUTTON', 'RESTART DEVICE...')
sys.restart('BUTTON')
end
st = 0
else
st = os.time()
end
btnDown = not btnDown
end)
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!