diff --git a/Workshop/181015/script1.lua b/Workshop/181015/script1.lua deleted file mode 100644 index 6cb3532..0000000 --- a/Workshop/181015/script1.lua +++ /dev/null @@ -1,13 +0,0 @@ --- Exemple de programme à ne PAS faire sur NodeMCU Lua script --- programme pour faire clignoter une LED avec un rapport on/off ---zf20181004.1430 - -zLED=0 -gpio.mode(zLED, gpio.OUTPUT) - -while true do - gpio.write(zLED, 0) - tmr.delay(1000*500) - gpio.write(zLED, 1) - tmr.delay(1000*500) -end diff --git a/Workshop/181015/web_srv/start_boot.lua b/Workshop/181015/web_srv/a_start_boot.lua similarity index 70% rename from Workshop/181015/web_srv/start_boot.lua rename to Workshop/181015/web_srv/a_start_boot.lua index 46a4183..e6565b8 100644 --- a/Workshop/181015/web_srv/start_boot.lua +++ b/Workshop/181015/web_srv/a_start_boot.lua @@ -1,6 +1,6 @@ -- Scripts à charger au moment du boot -print("\n start_boot.lua zf181018.1116 \n") +print("\n a_start_boot.lua zf181018.1624 \n") --dofile("wifi_ap_stop.lua") --dofile("wifi_cli_conf.lua") @@ -9,7 +9,7 @@ dofile("wifi_cli_start.lua") dofile("led_job.lua") dofile("web_srv.lua") ---dofile("flash_led_xfois.lua") +dofile("flash_led_xfois.lua") diff --git a/Workshop/181015/web_srv/initz.lua b/Workshop/181015/web_srv/initz.lua index 97951ca..feb1614 100644 --- a/Workshop/181015/web_srv/initz.lua +++ b/Workshop/181015/web_srv/initz.lua @@ -1,7 +1,7 @@ --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") +print("\n init.lua zf181018.1623\n") zswitch=3 --switch flash gpio.mode(zswitch, gpio.INT, gpio.PULLUP) @@ -10,7 +10,7 @@ initalarme=tmr.create() function hvbouton() gpio.trig(zswitch, "none") tmr.unregister(initalarme) - dofile("start_boot.lua") + dofile("a_start_boot.lua") -- dofile("start_job.lua") end @@ -18,6 +18,6 @@ gpio.trig(zswitch, "both", hvbouton) tmr.alarm(initalarme, 8000, tmr.ALARM_SINGLE, function() print("\nStart\n") - dofile("start_boot.lua") + dofile("a_start_boot.lua") -- dofile("start_job.lua") end) diff --git a/Workshop/181015/web_srv/led_job.lua b/Workshop/181015/web_srv/led_job.lua index 11b19c3..f960175 100644 --- a/Workshop/181015/web_srv/led_job.lua +++ b/Workshop/181015/web_srv/led_job.lua @@ -1,6 +1,6 @@ --Petit script pour la gestion de la LED, juste pour comprendre la prog ;-) -print("\n led_job.lua zf181018.1104 \n") +print("\n led_job.lua zf181018.1616 \n") zLED=0 gpio.mode(zLED, gpio.OUTPUT) @@ -19,14 +19,3 @@ end led_on() led_off() - - - local _on, _off = "", "" - if (_GET.pin == "ON") then - _on = " selected=\"true\"" - gpio.write(zLED, gpio.LOW) - elseif (_GET.pin == "OFF") then - _off = " selected=\"true\"" - gpio.write(zLED, gpio.HIGH) - end - buf = buf .. "OFFON" diff --git a/Workshop/181015/web_srv/web_get.lua b/Workshop/181015/web_srv/web_get.lua index 926bfd6..ddfd1c6 100644 --- a/Workshop/181015/web_srv/web_get.lua +++ b/Workshop/181015/web_srv/web_get.lua @@ -1,12 +1,16 @@ -- petit script pour la gestion du GET du serveur web -print("\n web_get.lua zf181018.1142 \n") +print("\n web_get.lua zf181018.1649 \n") function web_get() if (_GET.led == "on") then led_on() + html_home() elseif (_GET.led == "off") then led_off() + html_home() + else + html_home() end end diff --git a/Workshop/181015/web_srv/web_html.lua b/Workshop/181015/web_srv/web_html.lua index e27a5ae..b0c6275 100644 --- a/Workshop/181015/web_srv/web_html.lua +++ b/Workshop/181015/web_srv/web_html.lua @@ -1,16 +1,14 @@ -- petit script pour le HTML du serveur web -print("\n web_html.lua zf181018.1142 \n") +print("\n web_html.lua zf181018.1621 \n") --Partie HTML et CSS pour la page web -function web_html() +function html_home() buf = "\n" - buf = buf .. "

Hello, this is NodeMCU. 1142

\n" - + buf = buf .. "

Hello, this is NodeMCU. 1608

\n" buf = buf .. "Usage:

\n" buf = buf .. "pour allumer la LED, http://xxx/?led=on
\n" buf = buf .. "pour éteindre la LED, http://xxx/?led=off
\n" - buf = buf .. "" - end + diff --git a/Workshop/181015/web_srv/web_srv.lua b/Workshop/181015/web_srv/web_srv.lua index 4843fb5..9cb7b73 100644 --- a/Workshop/181015/web_srv/web_srv.lua +++ b/Workshop/181015/web_srv/web_srv.lua @@ -1,6 +1,6 @@ -- petit script de serveur WEB Wifi -print("\n web_srv.lua zf181018.1031 \n") +print("\n web_srv.lua zf181018.1610 \n") dofile("web_get.lua") dofile("web_html.lua") @@ -29,8 +29,6 @@ srv:listen(80, function(conn) end end web_get() - web_html() - --print("send html...") client:send(buf) buf=nil end