* Ajouté le dossier zpackage contenant tout ce qu'il faut pour bien débuter un nouveau projet NodeMCU * Ajouté un dossier, générateur de signaux pour le workshop sur l'oscilloscope * Rangé le dossier genefunc * Ajouté le dossier AD9833 pour commencer à travailler avec le module générateur de fonction AD9833
53 lines
1.5 KiB
Lua
53 lines
1.5 KiB
Lua
--Script de bootstrap, test au moment du boot qui a été la cause de boot.
|
|
-- Si la cause est un power on ou une connexion depuis l'IDE, alors
|
|
-- le script repair.lua pendant xx secondes avant de continuer
|
|
--Source: https://nodemcu.readthedocs.io/en/master/en/modules/node/#nodebootreason
|
|
|
|
print("\n init.lua zf190310.1549 \n")
|
|
|
|
zswitch=3 --switch flash
|
|
gpio.mode(zswitch, gpio.INT, gpio.PULLUP)
|
|
|
|
function hvbouton()
|
|
-- gpio.trig(zswitch, "none")
|
|
tmr.unregister(initalarme)
|
|
f= "boot.lua" if file.exists(f) then dofile(f) end
|
|
end
|
|
|
|
gpio.trig(zswitch, "both", hvbouton)
|
|
|
|
function second_chance()
|
|
print("seconde chance...")
|
|
f= "repair.lua" if file.exists(f) then dofile(f) end
|
|
initalarme=tmr.create()
|
|
tmr.alarm(initalarme, 4*1000, tmr.ALARM_SINGLE, function()
|
|
f= "boot.lua" if file.exists(f) then dofile(f) end
|
|
end)
|
|
end
|
|
|
|
_, reset_reason = node.bootreason()
|
|
print("reset_reason:",reset_reason)
|
|
if reset_reason == 0 then
|
|
print("power on")
|
|
second_chance()
|
|
elseif reset_reason == 4 then
|
|
print("node.restart")
|
|
gpio.trig(zswitch)
|
|
hvbouton=nil
|
|
second_chance=nil
|
|
zswitch=nil
|
|
reset_reason=nil
|
|
f= "boot.lua" if file.exists(f) then dofile(f) end
|
|
elseif reset_reason == 5 then
|
|
print("dsleep wake up")
|
|
f= "boot.lua" if file.exists(f) then dofile(f) end
|
|
elseif reset_reason == 6 then
|
|
print("external reset")
|
|
second_chance()
|
|
-- f= "boot.lua" if file.exists(f) then dofile(f) end
|
|
else
|
|
print("autre raison")
|
|
second_chance()
|
|
end
|
|
|