- 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
View File
@@ -1,3 +1,4 @@
Icon?
Tools*
.DS_Store
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
+35 -10
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))
--
+4 -2
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
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
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
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
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
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
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
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
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())
]]
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
-5
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" })
-4
View File
@@ -1,4 +0,0 @@
-- Déconnecte le WIFI
-- zf180713.1453
wifi.sta.disconnect()