Refactorisé le projet Cigales et corrigé un bug de timer dans init.lua

This commit is contained in:
Christian Zufferey
2019-07-21 16:14:13 +02:00
parent 486c897771
commit 8fbff636bc
21 changed files with 25 additions and 15 deletions

View File

@@ -1,6 +1,6 @@
-- Scripts à charger après le boot pour démarrer son appli -- Scripts à charger après le boot pour démarrer son appli
print("\n boot.lua zf190119.1933 \n") print("\n boot.lua zf190721.1603 \n")
function heartbeat() function heartbeat()
f= "flash_led_xfois.lua" if file.exists(f) then dofile(f) end f= "flash_led_xfois.lua" if file.exists(f) then dofile(f) end
@@ -11,6 +11,7 @@ function heartbeat()
end) end)
end end
f= "wifi_off.lua" if file.exists(f) then dofile(f) end
--f= "wifi_ap_start.lua" if file.exists(f) then dofile(f) end --f= "wifi_ap_start.lua" if file.exists(f) then dofile(f) end
--f= "wifi_cli_conf.lua" if file.exists(f) then dofile(f) end --f= "wifi_cli_conf.lua" if file.exists(f) then dofile(f) end
--f= "wifi_cli_start.lua" if file.exists(f) then dofile(f) end --f= "wifi_cli_start.lua" if file.exists(f) then dofile(f) end

View File

@@ -3,14 +3,14 @@
-- le script repair.lua pendant xx secondes avant de continuer -- le script repair.lua pendant xx secondes avant de continuer
--Source: https://nodemcu.readthedocs.io/en/master/en/modules/node/#nodebootreason --Source: https://nodemcu.readthedocs.io/en/master/en/modules/node/#nodebootreason
print("\n init.lua zf190131.009 \n") print("\n init.lua zf190601.1612 \n")
zswitch=3 --switch flash zswitch=3 --switch flash
gpio.mode(zswitch, gpio.INT, gpio.PULLUP) gpio.mode(zswitch, gpio.INT, gpio.PULLUP)
function hvbouton() function hvbouton()
-- gpio.trig(zswitch, "none") -- gpio.trig(zswitch, "none")
tmr.unregister(initalarme) initalarme:unregister()
f= "boot.lua" if file.exists(f) then dofile(f) end f= "boot.lua" if file.exists(f) then dofile(f) end
end end
@@ -20,7 +20,8 @@ function second_chance()
print("seconde chance...") print("seconde chance...")
f= "repair.lua" if file.exists(f) then dofile(f) end f= "repair.lua" if file.exists(f) then dofile(f) end
initalarme=tmr.create() initalarme=tmr.create()
tmr.alarm(initalarme, 8*1000, tmr.ALARM_SINGLE, function() -- tmr.alarm(initalarme, 4*1000, tmr.ALARM_SINGLE, function()
initalarme:alarm(4*1000, tmr.ALARM_SINGLE, function()
f= "boot.lua" if file.exists(f) then dofile(f) end f= "boot.lua" if file.exists(f) then dofile(f) end
end) end)
end end
@@ -32,6 +33,11 @@ if reset_reason == 0 then
second_chance() second_chance()
elseif reset_reason == 4 then elseif reset_reason == 4 then
print("node.restart") 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 f= "boot.lua" if file.exists(f) then dofile(f) end
elseif reset_reason == 5 then elseif reset_reason == 5 then
print("dsleep wake up") print("dsleep wake up")

View File

@@ -1,6 +1,6 @@
-- Scripts pour jouer un fichier son sur un HP -- Scripts pour jouer un fichier son sur un HP
print("\n play_file.lua zf190721.1238 \n") print("\n play_file.lua zf190721.1600 \n")
-- **************************************************************************** -- ****************************************************************************
@@ -17,6 +17,8 @@ function cb_drained(d)
file.seek("set", 0) file.seek("set", 0)
-- uncomment the following line for continuous playback -- uncomment the following line for continuous playback
--d:play(pcm.RATE_8K) --d:play(pcm.RATE_8K)
d:play(pcm.RATE_16K)
end end
function cb_stopped(d) function cb_stopped(d)
@@ -28,7 +30,7 @@ function cb_paused(d)
print("playback paused") print("playback paused")
end end
file.open("cigale_10s_16k.wav", "r") file.open("cigale_1mn_16k.wav", "r")
drv = pcm.new(pcm.SD, 5) drv = pcm.new(pcm.SD, 5)

View File

Before

Width:  |  Height:  |  Size: 289 KiB

After

Width:  |  Height:  |  Size: 289 KiB

View File

@@ -3,14 +3,14 @@
-- le script repair.lua pendant xx secondes avant de continuer -- le script repair.lua pendant xx secondes avant de continuer
--Source: https://nodemcu.readthedocs.io/en/master/en/modules/node/#nodebootreason --Source: https://nodemcu.readthedocs.io/en/master/en/modules/node/#nodebootreason
print("\n init.lua zf190601.1620 \n") print("\n init.lua zf190601.1612 \n")
zswitch=3 --switch flash zswitch=3 --switch flash
gpio.mode(zswitch, gpio.INT, gpio.PULLUP) gpio.mode(zswitch, gpio.INT, gpio.PULLUP)
function hvbouton() function hvbouton()
-- gpio.trig(zswitch, "none") -- gpio.trig(zswitch, "none")
tmr.unregister(initalarme) initalarme:unregister()
f= "boot.lua" if file.exists(f) then dofile(f) end f= "boot.lua" if file.exists(f) then dofile(f) end
end end

View File

@@ -3,14 +3,14 @@
-- le script repair.lua pendant xx secondes avant de continuer -- le script repair.lua pendant xx secondes avant de continuer
--Source: https://nodemcu.readthedocs.io/en/master/en/modules/node/#nodebootreason --Source: https://nodemcu.readthedocs.io/en/master/en/modules/node/#nodebootreason
print("\n init.lua zf190601.1620 \n") print("\n init.lua zf190601.1612 \n")
zswitch=3 --switch flash zswitch=3 --switch flash
gpio.mode(zswitch, gpio.INT, gpio.PULLUP) gpio.mode(zswitch, gpio.INT, gpio.PULLUP)
function hvbouton() function hvbouton()
-- gpio.trig(zswitch, "none") -- gpio.trig(zswitch, "none")
tmr.unregister(initalarme) initalarme:unregister()
f= "boot.lua" if file.exists(f) then dofile(f) end f= "boot.lua" if file.exists(f) then dofile(f) end
end end

View File

@@ -3,14 +3,14 @@
-- le script repair.lua pendant xx secondes avant de continuer -- le script repair.lua pendant xx secondes avant de continuer
--Source: https://nodemcu.readthedocs.io/en/master/en/modules/node/#nodebootreason --Source: https://nodemcu.readthedocs.io/en/master/en/modules/node/#nodebootreason
print("\n init.lua zf190601.1620 \n") print("\n init.lua zf190601.1612 \n")
zswitch=3 --switch flash zswitch=3 --switch flash
gpio.mode(zswitch, gpio.INT, gpio.PULLUP) gpio.mode(zswitch, gpio.INT, gpio.PULLUP)
function hvbouton() function hvbouton()
-- gpio.trig(zswitch, "none") -- gpio.trig(zswitch, "none")
tmr.unregister(initalarme) initalarme:unregister()
f= "boot.lua" if file.exists(f) then dofile(f) end f= "boot.lua" if file.exists(f) then dofile(f) end
end end

View File

@@ -3,14 +3,14 @@
-- le script repair.lua pendant xx secondes avant de continuer -- le script repair.lua pendant xx secondes avant de continuer
--Source: https://nodemcu.readthedocs.io/en/master/en/modules/node/#nodebootreason --Source: https://nodemcu.readthedocs.io/en/master/en/modules/node/#nodebootreason
print("\n init.lua zf190310.1549 \n") print("\n init.lua zf190601.1612 \n")
zswitch=3 --switch flash zswitch=3 --switch flash
gpio.mode(zswitch, gpio.INT, gpio.PULLUP) gpio.mode(zswitch, gpio.INT, gpio.PULLUP)
function hvbouton() function hvbouton()
-- gpio.trig(zswitch, "none") -- gpio.trig(zswitch, "none")
tmr.unregister(initalarme) initalarme:unregister()
f= "boot.lua" if file.exists(f) then dofile(f) end f= "boot.lua" if file.exists(f) then dofile(f) end
end end
@@ -20,7 +20,8 @@ function second_chance()
print("seconde chance...") print("seconde chance...")
f= "repair.lua" if file.exists(f) then dofile(f) end f= "repair.lua" if file.exists(f) then dofile(f) end
initalarme=tmr.create() initalarme=tmr.create()
tmr.alarm(initalarme, 4*1000, tmr.ALARM_SINGLE, function() -- tmr.alarm(initalarme, 4*1000, tmr.ALARM_SINGLE, function()
initalarme:alarm(4*1000, tmr.ALARM_SINGLE, function()
f= "boot.lua" if file.exists(f) then dofile(f) end f= "boot.lua" if file.exists(f) then dofile(f) end
end) end)
end end