- repris le projet btn_led_remote dans le workshop, ne fonctionne pas encore
This commit is contained in:
@@ -1,17 +0,0 @@
|
|||||||
-- Programme qui allume la led bleue quand on appuie le bouton flash
|
|
||||||
-- hv180711.1125
|
|
||||||
|
|
||||||
zledbleue=0 --led bleue
|
|
||||||
zswitch=3--switch flash
|
|
||||||
|
|
||||||
gpio.mode(zswitch, gpio.INT, gpio.PULLUP)
|
|
||||||
|
|
||||||
function bouton()
|
|
||||||
if gpio.read(zswitch)==0 then
|
|
||||||
gpio.write(zledbleue, gpio.LOW)
|
|
||||||
else
|
|
||||||
gpio.write(zledbleue, gpio.HIGH)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
gpio.trig(zswitch, "both", bouton)
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
-- Programme qui allume la led bleue quand on appuie le bouton flash
|
|
||||||
-- hv180711.1125
|
|
||||||
|
|
||||||
zledbleue=0 --led bleue
|
|
||||||
zswitch=3--switch flash
|
|
||||||
|
|
||||||
gpio.mode(zswitch, gpio.INT, gpio.PULLUP)
|
|
||||||
|
|
||||||
function bouton()
|
|
||||||
if gpio.read(zswitch)==0 then
|
|
||||||
zstate="OFF"
|
|
||||||
disp_send()
|
|
||||||
--gpio.write(zledbleue, gpio.LOW)
|
|
||||||
else
|
|
||||||
zstate="ON"
|
|
||||||
disp_send()
|
|
||||||
--gpio.write(zledbleue, gpio.HIGH)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
gpio.trig(zswitch, "both", bouton)
|
|
||||||
23
Workshop/181015/btn_led.lua
Normal file
23
Workshop/181015/btn_led.lua
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
-- Programme qui allume la led bleue quand on appuie le bouton flash
|
||||||
|
-- zf181011.1749
|
||||||
|
|
||||||
|
print("\n btn_led_front.lua zf181011.1819 \n")
|
||||||
|
|
||||||
|
|
||||||
|
zledbleue=0 --led bleue
|
||||||
|
zswitch=3 --switch flash
|
||||||
|
|
||||||
|
gpio.mode(zswitch, gpio.INT, gpio.PULLUP)
|
||||||
|
|
||||||
|
function zbtn()
|
||||||
|
if gpio.read(zswitch)==0 then
|
||||||
|
zled_state="ON"
|
||||||
|
gpio.write(zledbleue, gpio.LOW)
|
||||||
|
else
|
||||||
|
zled_state="OFF"
|
||||||
|
gpio.write(zledbleue, gpio.HIGH)
|
||||||
|
end
|
||||||
|
print(zled_state)
|
||||||
|
end
|
||||||
|
|
||||||
|
gpio.trig(zswitch, "both", zbtn)
|
||||||
23
Workshop/181015/btn_led_remote/btn/btn_led.lua
Normal file
23
Workshop/181015/btn_led_remote/btn/btn_led.lua
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
-- Programme qui allume la led bleue quand on appuie le bouton flash
|
||||||
|
-- zf181011.1749
|
||||||
|
|
||||||
|
print("\n btn_led_front.lua zf181011.1819 \n")
|
||||||
|
|
||||||
|
|
||||||
|
zledbleue=0 --led bleue
|
||||||
|
zswitch=3 --switch flash
|
||||||
|
|
||||||
|
gpio.mode(zswitch, gpio.INT, gpio.PULLUP)
|
||||||
|
|
||||||
|
function zbtn()
|
||||||
|
if gpio.read(zswitch)==0 then
|
||||||
|
zled_state="ON"
|
||||||
|
gpio.write(zledbleue, gpio.LOW)
|
||||||
|
else
|
||||||
|
zled_state="OFF"
|
||||||
|
gpio.write(zledbleue, gpio.HIGH)
|
||||||
|
end
|
||||||
|
print(zled_state)
|
||||||
|
end
|
||||||
|
|
||||||
|
gpio.trig(zswitch, "both", zbtn)
|
||||||
22
Workshop/181015/btn_led_remote/initz.lua
Normal file
22
Workshop/181015/btn_led_remote/initz.lua
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
--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
|
||||||
|
|
||||||
|
print("\n init.lua hv180906.1450\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)
|
||||||
7
Workshop/181015/btn_led_remote/start_boot.lua
Normal file
7
Workshop/181015/btn_led_remote/start_boot.lua
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
-- Scripts à charger au moment du boot afin de pouvoir travailler avec le robot à distance
|
||||||
|
print("\n start_boot.lua zf180907.1440 \n")
|
||||||
|
|
||||||
|
dofile("wifi_cli_conf.lua")
|
||||||
|
dofile("wifi_cli_start.lua")
|
||||||
|
dofile("web_led_onoff.lua")
|
||||||
|
|
||||||
12
Workshop/181015/rm_files.lua
Normal file
12
Workshop/181015/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")
|
||||||
4
Workshop/181015/wifi_cli_conf.lua
Normal file
4
Workshop/181015/wifi_cli_conf.lua
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
-- Petit script pour configurer le client WIFI du NodeMCU
|
||||||
|
print("\n wifi_cli_conf.lua zf180824.2000 \n")
|
||||||
|
|
||||||
|
wifi.sta.config{ssid="3G-zf", pwd="12234567", save=true}
|
||||||
14
Workshop/181015/wifi_cli_start.lua
Normal file
14
Workshop/181015/wifi_cli_start.lua
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
-- 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")
|
||||||
12
Workshop/181015/wifi_get_ip.lua
Normal file
12
Workshop/181015/wifi_get_ip.lua
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
-- Petit script pour obtenir l'adresse IP du NodeMCU connecté sur un AP Wifi
|
||||||
|
print("\n wifi_get_ip.lua zf180824.2000 \n")
|
||||||
|
|
||||||
|
wifitimer1=tmr.create()
|
||||||
|
tmr.alarm(wifitimer1, 1000, tmr.ALARM_AUTO , function()
|
||||||
|
if wifi.sta.getip() == nil then
|
||||||
|
print("Connecting to AP...")
|
||||||
|
else
|
||||||
|
tmr.stop(wifitimer1)
|
||||||
|
dofile("wifi_info.lua")
|
||||||
|
end
|
||||||
|
end)
|
||||||
28
Workshop/181015/wifi_info.lua
Normal file
28
Workshop/181015/wifi_info.lua
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
-- Petit script pour afficher les infos actuel du WIFI
|
||||||
|
print("\n wifi_info.lua zf180824.2000 \n")
|
||||||
|
|
||||||
|
local zmodewifi=wifi.getmode()
|
||||||
|
|
||||||
|
if zmodewifi == wifi.NULLMODE then
|
||||||
|
print("WIFI OFF")
|
||||||
|
elseif zmodewifi == wifi.STATION then
|
||||||
|
print("WIFI mode CLI")
|
||||||
|
print("Connected IP:\n",wifi.sta.getip())
|
||||||
|
do
|
||||||
|
local sta_config=wifi.sta.getconfig(true)
|
||||||
|
print(string.format("Current client config:\n\tssid:\"%s\"\tpassword:\"%s\"\n\tbssid:\"%s\"\tbssid_set:%s", sta_config.ssid, sta_config.pwd, sta_config.bssid, (sta_config.bssid_set and "true" or "false")))
|
||||||
|
end
|
||||||
|
elseif zmodewifi == wifi.SOFTAP then
|
||||||
|
print("WIFI mode AP")
|
||||||
|
print("AP MAC:\n\t"..wifi.ap.getmac())
|
||||||
|
print("AP IP:\n\t"..wifi.ap.getip())
|
||||||
|
elseif zmodewifi == wifi.STATIONAP then
|
||||||
|
print("WIFI mode CLI+AP")
|
||||||
|
print("Connected IP:\n",wifi.sta.getip())
|
||||||
|
do
|
||||||
|
local sta_config=wifi.sta.getconfig(true)
|
||||||
|
print(string.format("Current client config:\n\tssid:\"%s\"\tpassword:\"%s\"\n\tbssid:\"%s\"\tbssid_set:%s", sta_config.ssid, sta_config.pwd, sta_config.bssid, (sta_config.bssid_set and "true" or "false")))
|
||||||
|
end
|
||||||
|
print("AP MAC: "..wifi.ap.getmac())
|
||||||
|
print("AP IP: "..wifi.ap.getip())
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user