- 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:
@@ -1,7 +1,7 @@
|
|||||||
-- Programme qui allume la led bleue quand on appuie le bouton flash
|
-- Programme qui allume la led bleue quand on appuie le bouton flash
|
||||||
-- zf181011.1749
|
-- zf181011.1749
|
||||||
|
|
||||||
print("\n btn_led_front.lua zf181011.1819 \n")
|
print("\n btn_led.lua zf181016.1957 \n")
|
||||||
|
|
||||||
|
|
||||||
zledbleue=0 --led bleue
|
zledbleue=0 --led bleue
|
||||||
|
|||||||
@@ -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
|
zswitch=3 --switch flash
|
||||||
gpio.mode(zswitch, gpio.INT, gpio.PULLUP)
|
gpio.mode(zswitch, gpio.INT, gpio.PULLUP)
|
||||||
@@ -10,10 +11,10 @@ function hvbouton()
|
|||||||
gpio.trig(zswitch, "none")
|
gpio.trig(zswitch, "none")
|
||||||
tmr.unregister(initalarme)
|
tmr.unregister(initalarme)
|
||||||
dofile("start_boot.lua")
|
dofile("start_boot.lua")
|
||||||
dofile("start_job.lua")
|
-- dofile("start_job.lua")
|
||||||
end
|
end
|
||||||
|
|
||||||
--gpio.trig(zswitch, "both", hvbouton)
|
gpio.trig(zswitch, "both", hvbouton)
|
||||||
|
|
||||||
tmr.alarm(initalarme, 8000, tmr.ALARM_SINGLE, function()
|
tmr.alarm(initalarme, 8000, tmr.ALARM_SINGLE, function()
|
||||||
print("\nStart\n")
|
print("\nStart\n")
|
||||||
|
|||||||
@@ -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
|
zswitch=3 --switch flash
|
||||||
gpio.mode(zswitch, gpio.INT, gpio.PULLUP)
|
gpio.mode(zswitch, gpio.INT, gpio.PULLUP)
|
||||||
@@ -10,10 +11,10 @@ function hvbouton()
|
|||||||
gpio.trig(zswitch, "none")
|
gpio.trig(zswitch, "none")
|
||||||
tmr.unregister(initalarme)
|
tmr.unregister(initalarme)
|
||||||
dofile("start_boot.lua")
|
dofile("start_boot.lua")
|
||||||
dofile("start_job.lua")
|
-- dofile("start_job.lua")
|
||||||
end
|
end
|
||||||
|
|
||||||
--gpio.trig(zswitch, "both", hvbouton)
|
gpio.trig(zswitch, "both", hvbouton)
|
||||||
|
|
||||||
tmr.alarm(initalarme, 8000, tmr.ALARM_SINGLE, function()
|
tmr.alarm(initalarme, 8000, tmr.ALARM_SINGLE, function()
|
||||||
print("\nStart\n")
|
print("\nStart\n")
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
a=3
|
|
||||||
b=77
|
|
||||||
print(a*b)
|
|
||||||
22
Workshop/181015/hello_world/blink_led1.lua
Normal file
22
Workshop/181015/hello_world/blink_led1.lua
Normal 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 ()
|
||||||
@@ -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
|
zswitch=3 --switch flash
|
||||||
gpio.mode(zswitch, gpio.INT, gpio.PULLUP)
|
gpio.mode(zswitch, gpio.INT, gpio.PULLUP)
|
||||||
@@ -10,7 +11,7 @@ function hvbouton()
|
|||||||
gpio.trig(zswitch, "none")
|
gpio.trig(zswitch, "none")
|
||||||
tmr.unregister(initalarme)
|
tmr.unregister(initalarme)
|
||||||
dofile("start_boot.lua")
|
dofile("start_boot.lua")
|
||||||
dofile("start_job.lua")
|
-- dofile("start_job.lua")
|
||||||
end
|
end
|
||||||
|
|
||||||
gpio.trig(zswitch, "both", hvbouton)
|
gpio.trig(zswitch, "both", hvbouton)
|
||||||
12
Workshop/181015/hello_world/rm_files.lua
Normal file
12
Workshop/181015/hello_world/rm_files.lua
Normal 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")
|
||||||
7
Workshop/181015/hello_world/start_boot.lua
Normal file
7
Workshop/181015/hello_world/start_boot.lua
Normal 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
23
Workshop/181015/initz.lua
Normal 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)
|
||||||
@@ -1,28 +1,7 @@
|
|||||||
-- Scripts à charger au moment du boot afin de pouvoir travailler avec le robot à distance
|
-- Scripts à charger au moment du boot
|
||||||
print("\n start_boot.lua zf180907.1440 \n")
|
|
||||||
|
|
||||||
dofile("disp_oled.lua")
|
print("\n start_boot.lua zf181017.1021 \n")
|
||||||
oled_line1="RESET"
|
|
||||||
oled_line2=""
|
|
||||||
oled_line3=""
|
|
||||||
oled_line4=""
|
|
||||||
oled_line5=""
|
|
||||||
disp_oled()
|
|
||||||
|
|
||||||
oled_line1="Waiting..."
|
dofile("blink_led1.lua")
|
||||||
oled_line2=""
|
|
||||||
oled_line3=""
|
|
||||||
oled_line4=""
|
|
||||||
oled_line5=""
|
|
||||||
disp_oled()
|
|
||||||
|
|
||||||
--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")
|
|
||||||
|
|||||||
Reference in New Issue
Block a user