- fait un petit hello world tout complet avec le init.lua

- refactorisé les initz.lua tous les mêmes
- enlevé les scripts script*
- refactorisé le start_boot
- le worshop est donc tout bien propre maintenant ;-)
This commit is contained in:
Christian Zufferey
2018-10-17 14:44:28 +02:00
parent 142579c5cf
commit 5776cfbdfd
10 changed files with 82 additions and 39 deletions

View File

@@ -1,7 +1,7 @@
-- Programme qui allume la led bleue quand on appuie le bouton flash
-- zf181011.1749
print("\n btn_led_front.lua zf181011.1819 \n")
print("\n btn_led.lua zf181016.1957 \n")
zledbleue=0 --led bleue

View File

@@ -1,6 +1,7 @@
--Programme qui démarre le robot en appuyant sur le bouton flash et le redémarre si le bouton flash est appuyer pendant 3 secondes
--Script de bootstrap, en appuyant sur le bouton ça démarre start_boot,
-- autrement en attendant 8 secondes cela démarre start_boot
print("\n init.lua hv180906.1450\n")
print("\n init.lua zf181017.1026\n")
zswitch=3 --switch flash
gpio.mode(zswitch, gpio.INT, gpio.PULLUP)
@@ -10,10 +11,10 @@ function hvbouton()
gpio.trig(zswitch, "none")
tmr.unregister(initalarme)
dofile("start_boot.lua")
dofile("start_job.lua")
-- dofile("start_job.lua")
end
--gpio.trig(zswitch, "both", hvbouton)
gpio.trig(zswitch, "both", hvbouton)
tmr.alarm(initalarme, 8000, tmr.ALARM_SINGLE, function()
print("\nStart\n")

View File

@@ -1,6 +1,7 @@
--Programme qui démarre le robot en appuyant sur le bouton flash et le redémarre si le bouton flash est appuyer pendant 3 secondes
--Script de bootstrap, en appuyant sur le bouton ça démarre start_boot,
-- autrement en attendant 8 secondes cela démarre start_boot
print("\n init.lua hv180906.1450\n")
print("\n init.lua zf181017.1026\n")
zswitch=3 --switch flash
gpio.mode(zswitch, gpio.INT, gpio.PULLUP)
@@ -10,10 +11,10 @@ function hvbouton()
gpio.trig(zswitch, "none")
tmr.unregister(initalarme)
dofile("start_boot.lua")
dofile("start_job.lua")
-- dofile("start_job.lua")
end
--gpio.trig(zswitch, "both", hvbouton)
gpio.trig(zswitch, "both", hvbouton)
tmr.alarm(initalarme, 8000, tmr.ALARM_SINGLE, function()
print("\nStart\n")

View File

@@ -1,3 +0,0 @@
a=3
b=77
print(a*b)

View File

@@ -0,0 +1,22 @@
-- programme pour faire clignoter une LED avec un rapport on/off
--zf20180717.1118
zLED=0
zTm_On_LED = 500 --> en ms
zTm_Off_LED = 500 --> en ms
zFlag_LED = 0
function blink_LED ()
if zFlag_LED==gpio.LOW then
zFlag_LED=gpio.HIGH
tmr.alarm(ztmr_LED, zTm_Off_LED, tmr.ALARM_SINGLE, blink_LED)
else
zFlag_LED=gpio.LOW
tmr.alarm(ztmr_LED, zTm_On_LED, tmr.ALARM_SINGLE, blink_LED)
end
gpio.write(zLED, zFlag_LED)
end
gpio.mode(zLED, gpio.OUTPUT)
ztmr_LED = tmr.create()
blink_LED ()

View File

@@ -1,6 +1,7 @@
--Programme qui démarre le robot en appuyant sur le bouton flash et le redémarre si le bouton flash est appuyer pendant 3 secondes
--Script de bootstrap, en appuyant sur le bouton ça démarre start_boot,
-- autrement en attendant 8 secondes cela démarre start_boot
print("\n init.lua hv180906.1450\n")
print("\n init.lua zf181017.1026\n")
zswitch=3 --switch flash
gpio.mode(zswitch, gpio.INT, gpio.PULLUP)
@@ -10,7 +11,7 @@ function hvbouton()
gpio.trig(zswitch, "none")
tmr.unregister(initalarme)
dofile("start_boot.lua")
dofile("start_job.lua")
-- dofile("start_job.lua")
end
gpio.trig(zswitch, "both", hvbouton)

View File

@@ -0,0 +1,12 @@
-- pour effacer TOUS les fichiers qui se trouve dans la flash du NodeMCU
print("\n rm_files.lua zf180907.1511 \n")
l=file.list() i=0
for k,v in pairs(l) do
i=i+v
file.remove(k)
end
print("-------------------------------")
print("\nC'est tout effaced :-) \n")

View File

@@ -0,0 +1,7 @@
-- Scripts à charger au moment du boot
print("\n start_boot.lua zf181017.1021 \n")
dofile("blink_led1.lua")

23
Workshop/181015/initz.lua Normal file
View File

@@ -0,0 +1,23 @@
--Script de bootstrap, en appuyant sur le bouton ça démarre start_boot,
-- autrement en attendant 8 secondes cela démarre start_boot
print("\n init.lua zf181017.1026\n")
zswitch=3 --switch flash
gpio.mode(zswitch, gpio.INT, gpio.PULLUP)
initalarme=tmr.create()
function hvbouton()
gpio.trig(zswitch, "none")
tmr.unregister(initalarme)
dofile("start_boot.lua")
-- dofile("start_job.lua")
end
gpio.trig(zswitch, "both", hvbouton)
tmr.alarm(initalarme, 8000, tmr.ALARM_SINGLE, function()
print("\nStart\n")
dofile("start_boot.lua")
-- dofile("start_job.lua")
end)

View File

@@ -1,28 +1,7 @@
-- Scripts à charger au moment du boot afin de pouvoir travailler avec le robot à distance
print("\n start_boot.lua zf180907.1440 \n")
-- Scripts à charger au moment du boot
dofile("disp_oled.lua")
oled_line1="RESET"
oled_line2=""
oled_line3=""
oled_line4=""
oled_line5=""
disp_oled()
print("\n start_boot.lua zf181017.1021 \n")
oled_line1="Waiting..."
oled_line2=""
oled_line3=""
oled_line4=""
oled_line5=""
disp_oled()
dofile("blink_led1.lua")
--dofile("wifi_cnf_start.lua")
dofile("wifi_ap_stop.lua")
dofile("wifi_cli_start.lua")
dofile("web_srv.lua")
dofile("telnet_srv.lua")
zpeed=50
turn_on = 700
zauto=false
dofile("motor.lua")