wip
This commit is contained in:
33
Workshop/181015/btn_led_remote/btn/flash_led_xfois.lua
Normal file
33
Workshop/181015/btn_led_remote/btn/flash_led_xfois.lua
Normal file
@@ -0,0 +1,33 @@
|
||||
-- programme pour faire clignoter x fois une LED avec un rapport on/off
|
||||
print("\n flash_led_xfois.lua zf181015.1641 \n")
|
||||
|
||||
|
||||
zLED=0
|
||||
zTm_On_LED = 100 --> en ms
|
||||
zTm_Off_LED = 100 --> en ms
|
||||
zFlag_LED = 0
|
||||
zxfois = 0
|
||||
zxfois_max =2
|
||||
|
||||
function blink_LED ()
|
||||
if zxfois > zxfois_max-1 then
|
||||
print(zxfois)
|
||||
tmr.stop(ztmr_LED)
|
||||
zFlag_LED=gpio.HIGH
|
||||
else
|
||||
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)
|
||||
zxfois = zxfois+1
|
||||
end
|
||||
end
|
||||
gpio.write(zLED, zFlag_LED)
|
||||
|
||||
end
|
||||
|
||||
gpio.mode(zLED, gpio.OUTPUT)
|
||||
ztmr_LED = tmr.create()
|
||||
blink_LED ()
|
||||
@@ -1,8 +1,10 @@
|
||||
-- Scripts à charger au moment du boot afin de pouvoir travailler avec le robot à distance
|
||||
print("\n start_boot.lua zf181011.2342 \n")
|
||||
print("\n start_boot.lua zf181015.1642 \n")
|
||||
|
||||
dofile("wifi_ap_stop.lua")
|
||||
dofile("wifi_cli_conf.lua")
|
||||
dofile("wifi_cli_start.lua")
|
||||
dofile("web_cli.lua")
|
||||
dofile("btn_led.lua")
|
||||
dofile("flash_led_xfois.lua")
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
-- Petit script pour envoyer quelque chose sur un serveur WEB
|
||||
print("\n web_cli.lua zf181011.2352 \n")
|
||||
print("\n web_cli.lua zf181015.1625 \n")
|
||||
|
||||
function disp_send()
|
||||
-- http.get("http://192.168.4.1/?line1="..zlength.."m", nil, function(code, data)
|
||||
print("web_cli: "..zled_state)
|
||||
http.get("http://192.168.0.122/?pin="..zled_state, nil, function(code, data)
|
||||
http.get("http://192.168.4.1/?pin="..zled_state, nil, function(code, data)
|
||||
if (code < 0) then
|
||||
print("HTTP request failed")
|
||||
else
|
||||
|
||||
10
Workshop/181015/btn_led_remote/btn/wifi_ap_stop.lua
Normal file
10
Workshop/181015/btn_led_remote/btn/wifi_ap_stop.lua
Normal file
@@ -0,0 +1,10 @@
|
||||
-- Démarre le WIFI en mode AP
|
||||
print("\n wifi_ap_stop.lua zf180824.2000 \n")
|
||||
|
||||
local zmodewifi=wifi.getmode()
|
||||
if zmodewifi == wifi.SOFTAP then
|
||||
wifi.setmode(wifi.NULLMODE)
|
||||
elseif zmodewifi == wifi.STATIONAP then
|
||||
wifi.setmode(wifi.STATION)
|
||||
end
|
||||
print("WIFI AP arrêté")
|
||||
@@ -1,4 +1,5 @@
|
||||
-- Petit script pour configurer le client WIFI du NodeMCU
|
||||
print("\n wifi_cli_conf.lua zf181011.2338 \n")
|
||||
print("\n wifi_cli_conf.lua zf181015.1624 \n")
|
||||
|
||||
wifi.sta.config{ssid="NodeMCU btn 3a:2b:78:04:2d:2d", pwd="12345678", save=true}
|
||||
|
||||
wifi.sta.config{ssid="apzuzu6", pwd="12234567", save=true}
|
||||
|
||||
33
Workshop/181015/btn_led_remote/led/flash_led_xfois.lua
Normal file
33
Workshop/181015/btn_led_remote/led/flash_led_xfois.lua
Normal file
@@ -0,0 +1,33 @@
|
||||
-- programme pour faire clignoter x fois une LED avec un rapport on/off
|
||||
print("\n flash_led_xfois.lua zf181015.1641 \n")
|
||||
|
||||
|
||||
zLED=0
|
||||
zTm_On_LED = 100 --> en ms
|
||||
zTm_Off_LED = 100 --> en ms
|
||||
zFlag_LED = 0
|
||||
zxfois = 0
|
||||
zxfois_max =2
|
||||
|
||||
function blink_LED ()
|
||||
if zxfois > zxfois_max-1 then
|
||||
print(zxfois)
|
||||
tmr.stop(ztmr_LED)
|
||||
zFlag_LED=gpio.HIGH
|
||||
else
|
||||
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)
|
||||
zxfois = zxfois+1
|
||||
end
|
||||
end
|
||||
gpio.write(zLED, zFlag_LED)
|
||||
|
||||
end
|
||||
|
||||
gpio.mode(zLED, gpio.OUTPUT)
|
||||
ztmr_LED = tmr.create()
|
||||
blink_LED ()
|
||||
12
Workshop/181015/btn_led_remote/led/rm_files.lua
Normal file
12
Workshop/181015/btn_led_remote/led/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")
|
||||
@@ -1,7 +1,9 @@
|
||||
-- Scripts à charger au moment du boot afin de pouvoir travailler avec le robot à distance
|
||||
print("\n start_boot.lua zf181011.2338 \n")
|
||||
print("\n start_boot.lua zf181015.1643 \n")
|
||||
|
||||
dofile("wifi_cli_conf.lua")
|
||||
dofile("wifi_cli_start.lua")
|
||||
dofile("wifi_cli_stop.lua")
|
||||
dofile("wifi_ap_start.lua")
|
||||
dofile("web_led_onoff.lua")
|
||||
dofile("flash_led_xfois.lua")
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
--Petit serveur WEB pour allumer/éteindre une LED en mode client WIFI
|
||||
--hv20180711.1606
|
||||
|
||||
print("\n web_led_onoff.lua zf181015.1622 \n")
|
||||
|
||||
print("Démarrage")
|
||||
--wifi.sta.disconnect()
|
||||
@@ -7,7 +8,7 @@ print("Démarrage")
|
||||
--print("set mode=STATION (mode="..wifi.getmode()..")")
|
||||
--wifi.sta.config{ssid="Hugo", pwd="tototutu"}
|
||||
|
||||
wifi.sta.connect()
|
||||
--[[wifi.sta.connect()
|
||||
|
||||
tmr.alarm(0, 1000, tmr.ALARM_AUTO , function()
|
||||
if wifi.sta.getip() == nil then
|
||||
@@ -17,6 +18,7 @@ tmr.alarm(0, 1000, tmr.ALARM_AUTO , function()
|
||||
tmr.stop(0)
|
||||
end
|
||||
end)
|
||||
]]
|
||||
|
||||
zLED=0
|
||||
gpio.mode(zLED, gpio.OUTPUT)
|
||||
@@ -38,13 +40,13 @@ srv:listen(80, function(conn)
|
||||
buf = buf .. "<!DOCTYPE html><html><body><h1>Hello, this is NodeMCU.</h1><form src=\"/\">Turn PIN <select name=\"pin\" onchange=\"form.submit()\">"
|
||||
local _on, _off = "", ""
|
||||
if (_GET.pin == "ON") then
|
||||
_on = " selected=true"
|
||||
_on = " selected=\"true\""
|
||||
gpio.write(zLED, gpio.LOW)
|
||||
elseif (_GET.pin == "OFF") then
|
||||
_off = " selected=\"true\""
|
||||
gpio.write(zLED, gpio.HIGH)
|
||||
end
|
||||
buf = buf .. "<option" .. _on .. ">ON</option><option" .. _off .. ">OFF</option></select></form></body></html>"
|
||||
buf = buf .. "<option" .. _off .. ">OFF</option><option" .. _on .. ">ON</option></select></form></body></html>"
|
||||
client:send(buf)
|
||||
end)
|
||||
conn:on("sent", function(c) c:close() end)
|
||||
|
||||
13
Workshop/181015/btn_led_remote/led/wifi_ap_start.lua
Normal file
13
Workshop/181015/btn_led_remote/led/wifi_ap_start.lua
Normal file
@@ -0,0 +1,13 @@
|
||||
-- Démarre le WIFI en mode AP
|
||||
print("\n wifi_ap_start.lua zf180824.2000 \n")
|
||||
|
||||
local zmodewifi=wifi.getmode()
|
||||
if zmodewifi == wifi.NULLMODE then
|
||||
print("WIFI mode AP only")
|
||||
wifi.setmode(wifi.SOFTAP)
|
||||
elseif zmodewifi == wifi.STATION then
|
||||
print("WIFI mode AP+CLI")
|
||||
wifi.setmode(wifi.STATIONAP)
|
||||
end
|
||||
wifi.ap.config({ ssid = "NodeMCU ".."btn "..wifi.ap.getmac(), pwd = "12345678" })
|
||||
dofile("wifi_info.lua")
|
||||
@@ -1,4 +0,0 @@
|
||||
-- Petit script pour configurer le client WIFI du NodeMCU
|
||||
print("\n wifi_cli_conf.lua zf181011.2338 \n")
|
||||
|
||||
wifi.sta.config{ssid="apzuzu6", pwd="12234567", save=true}
|
||||
@@ -1,14 +0,0 @@
|
||||
-- Petit script pour connecter le NodeMCU sur un AP Wifi avec l'accompte sauvé en EEPROM
|
||||
print("\n wifi_cli_start.lua zf180824.2000 \n")
|
||||
|
||||
local zmodewifi=wifi.getmode()
|
||||
if zmodewifi == wifi.NULLMODE then
|
||||
print("WIFI mode CLI only")
|
||||
wifi.setmode(wifi.STATION)
|
||||
elseif zmodewifi == wifi.SOFTAP then
|
||||
print("WIFI mode AP+CLI")
|
||||
wifi.setmode(wifi.STATIONAP)
|
||||
end
|
||||
wifi.sta.autoconnect(1)
|
||||
wifi.sta.connect()
|
||||
dofile("wifi_get_ip.lua")
|
||||
10
Workshop/181015/btn_led_remote/led/wifi_cli_stop.lua
Normal file
10
Workshop/181015/btn_led_remote/led/wifi_cli_stop.lua
Normal file
@@ -0,0 +1,10 @@
|
||||
-- Démarre le WIFI en mode AP
|
||||
print("\n wifi_cli_stop.lua zf180824.2000 \n")
|
||||
|
||||
local zmodewifi=wifi.getmode()
|
||||
if zmodewifi == wifi.STATION then
|
||||
wifi.setmode(wifi.NULLMODE)
|
||||
elseif zmodewifi == wifi.STATIONAP then
|
||||
wifi.setmode(wifi.SOFTAP)
|
||||
end
|
||||
print("WIFI CLI arrêté")
|
||||
3
Workshop/181015/btn_led_remote/script1.lua
Normal file
3
Workshop/181015/btn_led_remote/script1.lua
Normal file
@@ -0,0 +1,3 @@
|
||||
a=3
|
||||
b=77
|
||||
print(a*b)
|
||||
Reference in New Issue
Block a user