- complètement remanié les scripts pour le WIFI, mais ce n'est pas encore terminé

This commit is contained in:
Christian Zufferey
2018-08-22 14:57:27 +02:00
parent e43b6f7540
commit 03686ac105
49 changed files with 207 additions and 21 deletions

1
.gitignore vendored
View File

@@ -1,3 +1,4 @@
Icon?
Tools*
.DS_Store

0
Hugo/README.md Executable file → Normal file
View File

0
Hugo/init.lua Executable file → Normal file
View File

0
Hugo/led_blink_1.lua Executable file → Normal file
View File

0
Hugo/led_blink_2.lua Executable file → Normal file
View File

0
Hugo/led_intensite.lua Executable file → Normal file
View File

0
Hugo/led_intensite_variable.lua Executable file → Normal file
View File

0
Hugo/led_press_button.lua Executable file → Normal file
View File

0
Hugo/luatool.py Executable file → Normal file
View File

0
Hugo/meter_mesure.lua Executable file → Normal file
View File

0
Hugo/oled_first.lua Executable file → Normal file
View File

0
Hugo/robot_avance_arrete.lua Executable file → Normal file
View File

0
Hugo/robot_mesure_turn_right.lua Executable file → Normal file
View File

0
Hugo/robot_random_mesure.lua Executable file → Normal file
View File

0
Hugo/start_EPSlorer.sh Executable file → Normal file
View File

0
Hugo/start_screen.sh Executable file → Normal file
View File

0
Hugo/test_blink_1.lua Executable file → Normal file
View File

0
Hugo/test_blink_2.lua Executable file → Normal file
View File

0
Hugo/test_get_ip_1.lua Executable file → Normal file
View File

0
Hugo/test_init_1.lua Executable file → Normal file
View File

0
Hugo/test_press_button_1.lua Executable file → Normal file
View File

0
Hugo/test_web_1.lua Executable file → Normal file
View File

0
Hugo/u_dir.lua Executable file → Normal file
View File

0
Hugo/u_get_ip.lua Executable file → Normal file
View File

0
Hugo/u_start_job.lua Executable file → Normal file
View File

0
Hugo/u_telnet_srv.lua Executable file → Normal file
View File

0
Hugo/u_web_stop.lua Executable file → Normal file
View File

0
Hugo/web_liste_deroulante_led_change.lua Executable file → Normal file
View File

0
Hugo/web_oled_decode_url.lua Executable file → Normal file
View File

0
Hugo/web_press_button_led.lua Executable file → Normal file
View File

0
Hugo/web_robot_on_off.lua Executable file → Normal file
View File

View File

@@ -1,24 +1,49 @@
-- tests des routines trigonométriques pour NodeMCU
print("\ntest_trigo1.lua zf180820.2209 \n")
print("\ntest_trigo1.lua zf1808201.1758 \n")
-- chargement des routines trigonométriques
dofile("trigo3.lua")
for i = 0, 2*math.pi, 2*math.pi/32 do
for i = 0, 4*math.pi, 4*math.pi/64 do
a=i
-- b=math.tan(a)
-- print("arctangente: "..a..", "..b..", "..math.atan(b)..", "..zatan(b)..", "..math.atan(b)/zatan(b))
b=math.tan(a)
print("arctangente: "..a..", "..b..", "..math.atan(b)..", "..zatan(b)..", "..math.atan(b)/zatan(b))
-- print("sinus: "..a..", "..math.sin(a)..", "..zsin(a)..", "..math.sin(a)/zsin(a))
-- print("cosinus: "..a..", "..math.cos(a)..", "..zcos(a)..", "..math.cos(a)/zcos(a))
-- print("tangente: "..a..", "..math.tan(a)..", "..ztan(a)..", "..math.tan(a)/ztan(a))
-- b=math.sin(a)
b=math.sin(a)
-- print("arcsinus: "..a..", "..b..", "..math.asin(b)..", "..zasin(b)..", "..math.asin(b)/zasin(b))
b=math.cos(a)
print("arccosinus: "..a..", "..b..", "..math.acos(b)..", "..zacos(b)..", "..math.acos(b)/zacos(b))
-- print("arccosinus: "..a..", "..b..", "..math.acos(b)..", "..zacos(b)..", "..math.acos(b)/zacos(b))
end
print("\n")
x=-0.70710678118655
print(math.acos(x))
print(zatan(math.sqrt(1-x*x)/x))
print(math.sqrt(1-x*x)/x)
y=2.5525440310417
print("y: "..y)
x=math.cos(y)
print("x: "..x)
print("math.acos: "..math.acos(x))
z=math.sqrt(1-x*x)/x
print("z: "..z)
print("zatan: "..zatan(z))
--

View File

@@ -5,7 +5,7 @@
print("\ntrigo3.lua zf180820.2205 \n")
Gros problème encore avec les atan négatives et du coup avec les acos, zf180820.2252
-- encore des problèmes, 8% d'erreur, avec les atan vers pi/4, zf180821.1849
function zsin(x)
@@ -33,7 +33,9 @@ function zasin(x)
end
function zacos(x)
return zatan(math.sqrt(1-x*x)/x)
-- return zatan(math.sqrt(1-x*x)/x)
--return math.pi/2-zatan(x/math.sqrt(1-x*x))
return math.pi/2-zasin(x)
end

22
Wifi/wifi_ap_start.lua Normal file
View File

@@ -0,0 +1,22 @@
-- Démarre le WIFI en mode AP
print("\wifi_ap_start.lua zf180822.1447 \n")
function zap_start()
wifi.ap.config({ ssid = "NodeMCU "..wifi.ap.getmac(), pwd = "12345678" })
end
local zmodewifi=wifi.getmode()
if zmodewifi == wifi.NULLMODE then
print("WIFI mode AP only")
wifi.setmode(wifi.SOFTAP)
zap_start()
elseif zmodewifi == wifi.STATION then
print("WIFI mode AP+CLI")
wifi.setmode(wifi.STATIONAP)
zap_start()
else
print("on ne fait rien car cela tourne déjà !")
end
dofile("wifi_info.lua")

26
Wifi/wifi_ap_stop.lua Normal file
View File

@@ -0,0 +1,26 @@
-- Démarre le WIFI en mode AP
print("\wifi_ap_stop.lua zf180822.1425 \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é")
--[[
wifi.setmode(wifi.NULLMODE)
print(wifi.ap.getconfig())
print(wifi.ap.getmac())
print(wifi.getdefaultmode())
print(wifi.getmode())
print(wifi.NULLMODE, wifi.STATION, wifi.SOFTAP, wifi.STATIONAP)
print(wifi.getphymode())
print(wifi.PHYMODE_B, wifi.PHYMODE_G, wifi.PHYMODE_N)
]]

4
Wifi/wifi_cli_conf.lua Normal file
View File

@@ -0,0 +1,4 @@
-- Petit script pour configurer le client WIFI du NodeMCU
print("\wifi_cli_conf.lua zf180822.1407 \n")
wifi.sta.config{ssid="Hugo", pwd="tototutu", save=true}

17
Wifi/wifi_cli_start.lua Normal file
View File

@@ -0,0 +1,17 @@
-- Petit script pour connecter le NodeMCU sur un AP Wifi avec l'accompte sauvé en EEPROM
print("\wifi_clidef_start.lua zf180822.1412 \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)
else
print("on ne fait rien car cela tourne déjà !")
end
wifi.sta.connect()
dofile("wifi_get_ip.lua")

26
Wifi/wifi_cli_stop.lua Normal file
View File

@@ -0,0 +1,26 @@
-- Démarre le WIFI en mode AP
print("\wifi_ap_stop.lua zf180822.1425 \n")
local zmodewifi=wifi.getmode()
if zmodewifi == wifi.STATIONAP then
wifi.setmode(wifi.NULLMODE)
elseif zmodewifi == wifi.SOFTAP then
wifi.setmode(wifi.STATION)
end
print("WIFI AP arrêté")
--[[
wifi.setmode(wifi.NULLMODE)
print(wifi.ap.getconfig())
print(wifi.ap.getmac())
print(wifi.getdefaultmode())
print(wifi.getmode())
print(wifi.NULLMODE, wifi.STATION, wifi.SOFTAP, wifi.STATIONAP)
print(wifi.getphymode())
print(wifi.PHYMODE_B, wifi.PHYMODE_G, wifi.PHYMODE_N)
]]

17
Wifi/wifi_get_ip.lua Normal file
View File

@@ -0,0 +1,17 @@
-- Petit script pour obtenir l'adresse IP du NodeMCU connecté sur un AP Wifi
print("\wifi_get_ip.lua zf180822.1422 \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)
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("Connected IP:\n\t"..wifi.sta.getip())
end
end)

44
Wifi/wifi_info.lua Normal file
View File

@@ -0,0 +1,44 @@
-- Petit script pour afficher les infos actuel du WIFI
print("\wifi_info.lua zf180822.1452 \n")
local zmodewifi=wifi.getmode()
--wifi.NULLMODE, wifi.STATION, wifi.SOFTAP, wifi.STATIONAP
if zmodewifi == wifi.NULLMODE then
print("WIFI OFF")
elseif zmodewifi == wifi.STATION then
print("WIFI mode CLI")
print("Client IP:\n\t"..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("Client IP:\n\t"..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
--[[
wifi.setmode(wifi.NULLMODE)
print(wifi.ap.getconfig())
print(wifi.ap.getmac())
print(wifi.getdefaultmode())
print(wifi.getmode())
print(wifi.NULLMODE, wifi.STATION, wifi.SOFTAP, wifi.STATIONAP)
print(wifi.getphymode())
print(wifi.PHYMODE_B, wifi.PHYMODE_G, wifi.PHYMODE_N)
]]

11
Wifi/wifi_off.lua Normal file
View File

@@ -0,0 +1,11 @@
-- Déconnecte le WIFI
print("\wifi_off.lua zf180822.0959 \n")
wifi.setmode(wifi.NULLMODE)
--[[
print(wifi.NULLMODE, wifi.STATION, wifi.SOFTAP, wifi.STATIONAP)
print(wifi.getmode())
]]

0
oled_demo_minid1.lua Executable file → Normal file
View File

0
oled_first_minid1.lua Executable file → Normal file
View File

0
web_oled_minid1.lua Executable file → Normal file
View File

View File

@@ -1,5 +0,0 @@
-- Démarre un WIFI AP
print("\wifi_ap_start.lua zf20180724.2220 \n")
wifi.setmode(wifi.SOFTAP)
wifi.ap.config({ ssid = "NodeMCU", pwd = "12345678" })

View File

@@ -1,4 +0,0 @@
-- Déconnecte le WIFI
-- zf180713.1453
wifi.sta.disconnect()