first commit
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,3 +1,6 @@
|
|||||||
|
Tools*
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
# Compiled Lua sources
|
# Compiled Lua sources
|
||||||
luac.out
|
luac.out
|
||||||
|
|
||||||
|
|||||||
0
Documentation/Icon
Normal file
0
Documentation/Icon
Normal file
BIN
Documentation/NODEMCU_DEVKIT_V1.0.PDF
Normal file
BIN
Documentation/NODEMCU_DEVKIT_V1.0.PDF
Normal file
Binary file not shown.
BIN
Documentation/l293dd.pdf
Normal file
BIN
Documentation/l293dd.pdf
Normal file
Binary file not shown.
BIN
Documentation/user-mannual-for-esp-12e-motor-shield.pdf
Normal file
BIN
Documentation/user-mannual-for-esp-12e-motor-shield.pdf
Normal file
Binary file not shown.
0
Firmware/Icon
Normal file
0
Firmware/Icon
Normal file
BIN
Firmware/nodemcu-master-13-modules-2018-07-11-14-45-04-float.bin
Normal file
BIN
Firmware/nodemcu-master-13-modules-2018-07-11-14-45-04-float.bin
Normal file
Binary file not shown.
Binary file not shown.
BIN
Firmware/nodemcu-master-17-modules-2018-07-12-07-10-01-float.bin
Normal file
BIN
Firmware/nodemcu-master-17-modules-2018-07-12-07-10-01-float.bin
Normal file
Binary file not shown.
Binary file not shown.
BIN
Firmware/nodemcu-master-21-modules-2018-07-14-14-34-12-float.bin
Normal file
BIN
Firmware/nodemcu-master-21-modules-2018-07-14-14-34-12-float.bin
Normal file
Binary file not shown.
Binary file not shown.
BIN
Firmware/nodemcu-master-25-modules-2018-07-16-08-14-30-float.bin
Normal file
BIN
Firmware/nodemcu-master-25-modules-2018-07-16-08-14-30-float.bin
Normal file
Binary file not shown.
Binary file not shown.
BIN
Firmware/nodemcu-master-7-modules-2018-07-09-09-44-57-float.bin
Normal file
BIN
Firmware/nodemcu-master-7-modules-2018-07-09-09-44-57-float.bin
Normal file
Binary file not shown.
Binary file not shown.
0
Oldies/Icon
Normal file
0
Oldies/Icon
Normal file
BIN
Robot_Lua/Capture d’écran 2018-07-11 à 17.19.47.png
Normal file
BIN
Robot_Lua/Capture d’écran 2018-07-11 à 17.19.47.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 190 KiB |
BIN
Robot_Lua/Capture d’écran 2018-07-11 à 17.21.06.png
Normal file
BIN
Robot_Lua/Capture d’écran 2018-07-11 à 17.21.06.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 389 KiB |
0
Robot_Lua/Icon
Normal file
0
Robot_Lua/Icon
Normal file
388
Robot_Lua/t1.dxf
Normal file
388
Robot_Lua/t1.dxf
Normal file
@@ -0,0 +1,388 @@
|
|||||||
|
0
|
||||||
|
SECTION
|
||||||
|
2
|
||||||
|
HEADER
|
||||||
|
9
|
||||||
|
$INSUNITS
|
||||||
|
70
|
||||||
|
4
|
||||||
|
9
|
||||||
|
$ACADVER
|
||||||
|
1
|
||||||
|
AC1014
|
||||||
|
9
|
||||||
|
$HANDSEED
|
||||||
|
5
|
||||||
|
FFFF
|
||||||
|
0
|
||||||
|
ENDSEC
|
||||||
|
0
|
||||||
|
SECTION
|
||||||
|
2
|
||||||
|
TABLES
|
||||||
|
0
|
||||||
|
TABLE
|
||||||
|
2
|
||||||
|
VPORT
|
||||||
|
5
|
||||||
|
8
|
||||||
|
100
|
||||||
|
AcDbSymbolTable
|
||||||
|
0
|
||||||
|
ENDTAB
|
||||||
|
0
|
||||||
|
TABLE
|
||||||
|
2
|
||||||
|
LTYPE
|
||||||
|
5
|
||||||
|
5
|
||||||
|
100
|
||||||
|
AcDbSymbolTable
|
||||||
|
0
|
||||||
|
LTYPE
|
||||||
|
5
|
||||||
|
14
|
||||||
|
100
|
||||||
|
AcDbSymbolTableRecord
|
||||||
|
100
|
||||||
|
AcDbLinetypeTableRecord
|
||||||
|
2
|
||||||
|
BYBLOCK
|
||||||
|
70
|
||||||
|
0
|
||||||
|
0
|
||||||
|
LTYPE
|
||||||
|
5
|
||||||
|
15
|
||||||
|
100
|
||||||
|
AcDbSymbolTableRecord
|
||||||
|
100
|
||||||
|
AcDbLinetypeTableRecord
|
||||||
|
2
|
||||||
|
BYLAYER
|
||||||
|
70
|
||||||
|
0
|
||||||
|
0
|
||||||
|
ENDTAB
|
||||||
|
0
|
||||||
|
TABLE
|
||||||
|
2
|
||||||
|
LAYER
|
||||||
|
5
|
||||||
|
2
|
||||||
|
100
|
||||||
|
AcDbSymbolTable
|
||||||
|
70
|
||||||
|
2
|
||||||
|
0
|
||||||
|
LAYER
|
||||||
|
5
|
||||||
|
50
|
||||||
|
100
|
||||||
|
AcDbSymbolTableRecord
|
||||||
|
100
|
||||||
|
AcDbLayerTableRecord
|
||||||
|
2
|
||||||
|
0
|
||||||
|
70
|
||||||
|
0
|
||||||
|
6
|
||||||
|
CONTINUOUS
|
||||||
|
0
|
||||||
|
ENDTAB
|
||||||
|
0
|
||||||
|
TABLE
|
||||||
|
2
|
||||||
|
STYLE
|
||||||
|
5
|
||||||
|
3
|
||||||
|
100
|
||||||
|
AcDbSymbolTable
|
||||||
|
70
|
||||||
|
1
|
||||||
|
0
|
||||||
|
STYLE
|
||||||
|
5
|
||||||
|
11
|
||||||
|
100
|
||||||
|
AcDbSymbolTableRecord
|
||||||
|
100
|
||||||
|
AcDbTextStyleTableRecord
|
||||||
|
2
|
||||||
|
STANDARD
|
||||||
|
70
|
||||||
|
0
|
||||||
|
0
|
||||||
|
ENDTAB
|
||||||
|
0
|
||||||
|
TABLE
|
||||||
|
2
|
||||||
|
VIEW
|
||||||
|
5
|
||||||
|
6
|
||||||
|
100
|
||||||
|
AcDbSymbolTable
|
||||||
|
70
|
||||||
|
0
|
||||||
|
0
|
||||||
|
ENDTAB
|
||||||
|
0
|
||||||
|
TABLE
|
||||||
|
2
|
||||||
|
UCS
|
||||||
|
5
|
||||||
|
7
|
||||||
|
100
|
||||||
|
AcDbSymbolTable
|
||||||
|
70
|
||||||
|
0
|
||||||
|
0
|
||||||
|
ENDTAB
|
||||||
|
0
|
||||||
|
TABLE
|
||||||
|
2
|
||||||
|
APPID
|
||||||
|
5
|
||||||
|
9
|
||||||
|
100
|
||||||
|
AcDbSymbolTable
|
||||||
|
70
|
||||||
|
2
|
||||||
|
0
|
||||||
|
APPID
|
||||||
|
5
|
||||||
|
12
|
||||||
|
100
|
||||||
|
AcDbSymbolTableRecord
|
||||||
|
100
|
||||||
|
AcDbRegAppTableRecord
|
||||||
|
2
|
||||||
|
ACAD
|
||||||
|
70
|
||||||
|
0
|
||||||
|
0
|
||||||
|
ENDTAB
|
||||||
|
0
|
||||||
|
TABLE
|
||||||
|
2
|
||||||
|
DIMSTYLE
|
||||||
|
5
|
||||||
|
A
|
||||||
|
100
|
||||||
|
AcDbSymbolTable
|
||||||
|
70
|
||||||
|
1
|
||||||
|
0
|
||||||
|
ENDTAB
|
||||||
|
0
|
||||||
|
TABLE
|
||||||
|
2
|
||||||
|
BLOCK_RECORD
|
||||||
|
5
|
||||||
|
1
|
||||||
|
100
|
||||||
|
AcDbSymbolTable
|
||||||
|
70
|
||||||
|
1
|
||||||
|
0
|
||||||
|
BLOCK_RECORD
|
||||||
|
5
|
||||||
|
1F
|
||||||
|
100
|
||||||
|
AcDbSymbolTableRecord
|
||||||
|
100
|
||||||
|
AcDbBlockTableRecord
|
||||||
|
2
|
||||||
|
*MODEL_SPACE
|
||||||
|
0
|
||||||
|
BLOCK_RECORD
|
||||||
|
5
|
||||||
|
1B
|
||||||
|
100
|
||||||
|
AcDbSymbolTableRecord
|
||||||
|
100
|
||||||
|
AcDbBlockTableRecord
|
||||||
|
2
|
||||||
|
*PAPER_SPACE
|
||||||
|
0
|
||||||
|
ENDTAB
|
||||||
|
0
|
||||||
|
ENDSEC
|
||||||
|
0
|
||||||
|
SECTION
|
||||||
|
2
|
||||||
|
BLOCKS
|
||||||
|
0
|
||||||
|
BLOCK
|
||||||
|
5
|
||||||
|
20
|
||||||
|
100
|
||||||
|
AcDbEntity
|
||||||
|
100
|
||||||
|
AcDbBlockBegin
|
||||||
|
2
|
||||||
|
*MODEL_SPACE
|
||||||
|
0
|
||||||
|
ENDBLK
|
||||||
|
5
|
||||||
|
21
|
||||||
|
100
|
||||||
|
AcDbEntity
|
||||||
|
100
|
||||||
|
AcDbBlockEnd
|
||||||
|
0
|
||||||
|
BLOCK
|
||||||
|
5
|
||||||
|
1C
|
||||||
|
100
|
||||||
|
AcDbEntity
|
||||||
|
100
|
||||||
|
AcDbBlockBegin
|
||||||
|
2
|
||||||
|
*PAPER_SPACE
|
||||||
|
0
|
||||||
|
ENDBLK
|
||||||
|
5
|
||||||
|
1D
|
||||||
|
100
|
||||||
|
AcDbEntity
|
||||||
|
100
|
||||||
|
AcDbBlockEnd
|
||||||
|
0
|
||||||
|
ENDSEC
|
||||||
|
0
|
||||||
|
SECTION
|
||||||
|
2
|
||||||
|
ENTITIES
|
||||||
|
0
|
||||||
|
CIRCLE
|
||||||
|
5
|
||||||
|
100
|
||||||
|
100
|
||||||
|
AcDbEntity
|
||||||
|
8
|
||||||
|
0
|
||||||
|
100
|
||||||
|
AcDbCircle
|
||||||
|
10
|
||||||
|
-45
|
||||||
|
20
|
||||||
|
20
|
||||||
|
30
|
||||||
|
0
|
||||||
|
40
|
||||||
|
4.0000000000000036
|
||||||
|
0
|
||||||
|
CIRCLE
|
||||||
|
5
|
||||||
|
101
|
||||||
|
100
|
||||||
|
AcDbEntity
|
||||||
|
8
|
||||||
|
0
|
||||||
|
100
|
||||||
|
AcDbCircle
|
||||||
|
10
|
||||||
|
45
|
||||||
|
20
|
||||||
|
20
|
||||||
|
30
|
||||||
|
0
|
||||||
|
40
|
||||||
|
4.0000000000000036
|
||||||
|
0
|
||||||
|
LWPOLYLINE
|
||||||
|
5
|
||||||
|
102
|
||||||
|
100
|
||||||
|
AcDbEntity
|
||||||
|
8
|
||||||
|
0
|
||||||
|
100
|
||||||
|
AcDbPolyline
|
||||||
|
90
|
||||||
|
8
|
||||||
|
70
|
||||||
|
1
|
||||||
|
43
|
||||||
|
0.0
|
||||||
|
10
|
||||||
|
-93.674969975975969
|
||||||
|
20
|
||||||
|
35.000000000000021
|
||||||
|
42
|
||||||
|
-0.69388866648871095
|
||||||
|
10
|
||||||
|
93.674969975975984
|
||||||
|
20
|
||||||
|
34.999999999999972
|
||||||
|
10
|
||||||
|
64.999999417074449
|
||||||
|
20
|
||||||
|
35
|
||||||
|
10
|
||||||
|
65
|
||||||
|
20
|
||||||
|
-35
|
||||||
|
10
|
||||||
|
93.674969975975984
|
||||||
|
20
|
||||||
|
-34.999999999999993
|
||||||
|
42
|
||||||
|
-0.69388866648871095
|
||||||
|
10
|
||||||
|
-93.674969975975984
|
||||||
|
20
|
||||||
|
-35
|
||||||
|
10
|
||||||
|
-65
|
||||||
|
20
|
||||||
|
-35
|
||||||
|
10
|
||||||
|
-65
|
||||||
|
20
|
||||||
|
35
|
||||||
|
0
|
||||||
|
ENDSEC
|
||||||
|
0
|
||||||
|
SECTION
|
||||||
|
2
|
||||||
|
OBJECTS
|
||||||
|
0
|
||||||
|
DICTIONARY
|
||||||
|
5
|
||||||
|
C
|
||||||
|
100
|
||||||
|
AcDbDictionary
|
||||||
|
3
|
||||||
|
ACAD_GROUP
|
||||||
|
350
|
||||||
|
D
|
||||||
|
3
|
||||||
|
ACAD_MLINESTYLE
|
||||||
|
350
|
||||||
|
17
|
||||||
|
0
|
||||||
|
DICTIONARY
|
||||||
|
5
|
||||||
|
D
|
||||||
|
100
|
||||||
|
AcDbDictionary
|
||||||
|
0
|
||||||
|
DICTIONARY
|
||||||
|
5
|
||||||
|
1A
|
||||||
|
330
|
||||||
|
C
|
||||||
|
100
|
||||||
|
AcDbDictionary
|
||||||
|
0
|
||||||
|
DICTIONARY
|
||||||
|
5
|
||||||
|
17
|
||||||
|
100
|
||||||
|
AcDbDictionary
|
||||||
|
0
|
||||||
|
ENDSEC
|
||||||
|
0
|
||||||
|
EOF
|
||||||
1756
Robot_Lua/t2.dxf
Normal file
1756
Robot_Lua/t2.dxf
Normal file
File diff suppressed because it is too large
Load Diff
0
SonOff/Icon
Normal file
0
SonOff/Icon
Normal file
12
SonOff/get_ip.lua
Normal file
12
SonOff/get_ip.lua
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
-- get_ip.lua
|
||||||
|
-- affiche l'adresse IP
|
||||||
|
-- zf180715.2347
|
||||||
|
|
||||||
|
tmr.alarm(0, 1000, tmr.ALARM_AUTO , function()
|
||||||
|
if wifi.sta.getip() == nil then
|
||||||
|
print("Connecting to AP...")
|
||||||
|
else
|
||||||
|
print("Connected! IP: ",wifi.sta.getip())
|
||||||
|
tmr.stop(0)
|
||||||
|
end
|
||||||
|
end)
|
||||||
94
SonOff/init.lua
Normal file
94
SonOff/init.lua
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
-- init.lua
|
||||||
|
-- test si clic sur le bouton
|
||||||
|
-- clic <2s goto start.lua
|
||||||
|
-- clic >2s goto config wifi
|
||||||
|
print("\ninit.lua zf180717.1125 \n")
|
||||||
|
|
||||||
|
zBTN = 3 -- GPIO0 button
|
||||||
|
--zRelay = 6 -- GPIO12 PWM0 relay (active high)
|
||||||
|
zLED = 0 -- SonOff: 7 GPIO13 PWM1, NodeMCU: 0, (active low)
|
||||||
|
zFlag_LED = 0
|
||||||
|
|
||||||
|
function blink_LED ()
|
||||||
|
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)
|
||||||
|
end
|
||||||
|
gpio.write(zLED, zFlag_LED)
|
||||||
|
end
|
||||||
|
|
||||||
|
gpio.mode(zLED, gpio.OUTPUT)
|
||||||
|
ztmr_LED = tmr.create()
|
||||||
|
--pwm.setup(zLED, 1, 500)
|
||||||
|
--pwm.start(zLED)
|
||||||
|
zTm_On_LED = 500 --> en ms
|
||||||
|
zTm_Off_LED = 500 --> en ms
|
||||||
|
blink_LED ()
|
||||||
|
|
||||||
|
function btn_test()
|
||||||
|
print("test")
|
||||||
|
t2=tmr.now()
|
||||||
|
t3=(t2-t1)/1000000
|
||||||
|
print("t3: "..t3)
|
||||||
|
if gpio.read(zBTN)==1 then
|
||||||
|
tmr.stop(0)
|
||||||
|
gpio.trig(zBTN)
|
||||||
|
--pwm.stop(zLED)
|
||||||
|
tmr.stop(ztmr_LED)
|
||||||
|
gpio.write(zLED,1)
|
||||||
|
print("start.lua")
|
||||||
|
dofile("start.lua")
|
||||||
|
end
|
||||||
|
if t3>2 then
|
||||||
|
tmr.stop(0)
|
||||||
|
gpio.trig(zBTN)
|
||||||
|
--pwm.setup(zLED, 10, 500)
|
||||||
|
--pwm.start(zLED)
|
||||||
|
zTm_On_LED = 100 --> en ms
|
||||||
|
zTm_Off_LED = 100 --> en ms
|
||||||
|
blink_LED ()
|
||||||
|
wifi.sta.disconnect()
|
||||||
|
wifi.sta.clearconfig()
|
||||||
|
print("\nwifi config http://192.168.4.1\n")
|
||||||
|
tmr.alarm(0, 1000, tmr.ALARM_AUTO , get_ip)
|
||||||
|
enduser_setup.start()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function btn_clic()
|
||||||
|
print("clic")
|
||||||
|
t1=tmr.now()
|
||||||
|
--pwm.stop(zLED)
|
||||||
|
tmr.stop(ztmr_LED)
|
||||||
|
gpio.write(zLED,0)
|
||||||
|
tmr.alarm(0,100,tmr.ALARM_AUTO, btn_test)
|
||||||
|
end
|
||||||
|
|
||||||
|
function get_ip()
|
||||||
|
if wifi.sta.getip() == nil then
|
||||||
|
print("Connecting to AP...")
|
||||||
|
else
|
||||||
|
tmr.stop(0)
|
||||||
|
print("Connected! IP: ",wifi.sta.getip())
|
||||||
|
tmr.alarm(0,3000,tmr.ALARM_SINGLE, function() node.restart() end)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function dir()
|
||||||
|
l=file.list()
|
||||||
|
for k,v in pairs(l) do
|
||||||
|
print(k.." "..v)
|
||||||
|
end
|
||||||
|
print('\nusage: dofile("file.lua")\n')
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
gpio.mode(zBTN,gpio.INT)
|
||||||
|
gpio.trig(zBTN, "down", btn_clic)
|
||||||
|
|
||||||
|
wifi.sta.connect()
|
||||||
|
dofile("telnet_srv.lua")
|
||||||
|
|
||||||
34
SonOff/script1 - copie.lua
Normal file
34
SonOff/script1 - copie.lua
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
zBTN = 3 -- GPIO0 button
|
||||||
|
zRelay = 6 -- GPIO12 PWM0 relay (active high)
|
||||||
|
zLED = 7 -- GPIO13 PWM1 GREEN LED (active low)
|
||||||
|
|
||||||
|
--pwm.setup(zLED, 1, 500)
|
||||||
|
--pwm.start(zLED)
|
||||||
|
|
||||||
|
gpio.mode(zBTN,gpio.INT)
|
||||||
|
pwm.stop(zLED)
|
||||||
|
gpio.write(zLED,1)
|
||||||
|
|
||||||
|
gpio.trig(zBTN, "both",function()
|
||||||
|
if gpio.read(zBTN)==0 then
|
||||||
|
pwm.stop(zLED)
|
||||||
|
gpio.write(zLED,0)
|
||||||
|
t1=tmr.now()
|
||||||
|
else
|
||||||
|
gpio.write(zLED,1)
|
||||||
|
t2=tmr.now()
|
||||||
|
t3=(t2-t1)/1000000
|
||||||
|
print(t3)
|
||||||
|
if t3<2 then
|
||||||
|
gpio.write(zLED,1)
|
||||||
|
print("start")
|
||||||
|
pwm.setup(zLED, 1, 500)
|
||||||
|
pwm.start(zLED)
|
||||||
|
else
|
||||||
|
print("config")
|
||||||
|
pwm.setup(zLED, 10, 500)
|
||||||
|
pwm.start(zLED)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end)
|
||||||
11
SonOff/start.lua
Normal file
11
SonOff/start.lua
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
-- start.lua
|
||||||
|
-- programme de start
|
||||||
|
-- zf180715.2359
|
||||||
|
|
||||||
|
zBTN = 3 -- GPIO0 button
|
||||||
|
zRelay = 6 -- GPIO12 PWM0 relay (active high)
|
||||||
|
zLED = 7 -- GPIO13 PWM1 GREEN LED (active low)
|
||||||
|
|
||||||
|
gpio.mode(zLED,gpio.OUTPUT)
|
||||||
|
pwm.setup(zLED, 2, 900)
|
||||||
|
pwm.start(zLED)
|
||||||
13
SonOff/stop.lua
Normal file
13
SonOff/stop.lua
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
-- stop.lua
|
||||||
|
-- programme de stop
|
||||||
|
-- zf180716.0010
|
||||||
|
|
||||||
|
zBTN = 3 -- GPIO0 button
|
||||||
|
zRelay = 6 -- GPIO12 PWM0 relay (active high)
|
||||||
|
zLED = 7 -- GPIO13 PWM1 GREEN LED (active low)
|
||||||
|
|
||||||
|
gpio.mode(zLED,gpio.OUTPUT)
|
||||||
|
pwm.stop(zLED)
|
||||||
|
gpio.write(zLED,1)
|
||||||
|
|
||||||
|
|
||||||
42
SonOff/telnet_srv.lua
Normal file
42
SonOff/telnet_srv.lua
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
-- a simple telnet server
|
||||||
|
|
||||||
|
-- restart server if needed
|
||||||
|
if telnet_srv ~= nil then
|
||||||
|
telnet_srv:close()
|
||||||
|
end
|
||||||
|
telnet_srv = net.createServer(net.TCP, 180)
|
||||||
|
|
||||||
|
telnet_srv:listen(23, function(socket)
|
||||||
|
local fifo = {}
|
||||||
|
local fifo_drained = true
|
||||||
|
|
||||||
|
local function sender(c)
|
||||||
|
if #fifo > 0 then
|
||||||
|
c:send(table.remove(fifo, 1))
|
||||||
|
else
|
||||||
|
fifo_drained = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function s_output(str)
|
||||||
|
table.insert(fifo, str)
|
||||||
|
if socket ~= nil and fifo_drained then
|
||||||
|
fifo_drained = false
|
||||||
|
sender(socket)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
node.output(s_output, 0) -- re-direct output to function s_ouput.
|
||||||
|
|
||||||
|
socket:on("receive", function(c, l)
|
||||||
|
node.input(l) -- works like pcall(loadstring(l)) but support multiple separate line
|
||||||
|
end)
|
||||||
|
socket:on("disconnection", function(c)
|
||||||
|
node.output(nil) -- un-regist the redirect output function, output goes to serial
|
||||||
|
end)
|
||||||
|
socket:on("sent", sender)
|
||||||
|
|
||||||
|
print("Welcome to NodeMCU world.")
|
||||||
|
end)
|
||||||
|
|
||||||
|
print("Telnet server running...")
|
||||||
51
Wifi_led_onoff.lua
Normal file
51
Wifi_led_onoff.lua
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
--Petit serveur WEB pour allumer/éteindre une LED en mode client WIFI
|
||||||
|
--hv20180711.1606
|
||||||
|
|
||||||
|
print("Démarrage")
|
||||||
|
--wifi.sta.disconnect()
|
||||||
|
--wifi.setmode(wifi.STATION)
|
||||||
|
--print("set mode=STATION (mode="..wifi.getmode()..")")
|
||||||
|
--wifi.sta.config{ssid="Hugo", pwd="tototutu"}
|
||||||
|
|
||||||
|
wifi.sta.connect()
|
||||||
|
|
||||||
|
tmr.alarm(0, 1000, tmr.ALARM_AUTO , function()
|
||||||
|
if wifi.sta.getip() == nil then
|
||||||
|
print("Connecting to AP...")
|
||||||
|
else
|
||||||
|
print("Connected! IP: ",wifi.sta.getip())
|
||||||
|
tmr.stop(0)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
zLED=0
|
||||||
|
gpio.mode(zLED, gpio.OUTPUT)
|
||||||
|
gpio.write(zLED, gpio.HIGH)
|
||||||
|
srv = net.createServer(net.TCP)
|
||||||
|
srv:listen(80, function(conn)
|
||||||
|
conn:on("receive", function(client, request)
|
||||||
|
local buf = ""
|
||||||
|
local _, _, method, path, vars = string.find(request, "([A-Z]+) (.+)?(.+) HTTP")
|
||||||
|
if (method == nil) then
|
||||||
|
_, _, method, path = string.find(request, "([A-Z]+) (.+) HTTP")
|
||||||
|
end
|
||||||
|
local _GET = {}
|
||||||
|
if (vars ~= nil) then
|
||||||
|
for k, v in string.gmatch(vars, "(%w+)=(%w+)&*") do
|
||||||
|
_GET[k] = v
|
||||||
|
end
|
||||||
|
end
|
||||||
|
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"
|
||||||
|
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>"
|
||||||
|
client:send(buf)
|
||||||
|
end)
|
||||||
|
conn:on("sent", function(c) c:close() end)
|
||||||
|
end)
|
||||||
22
blink_led1 - copie.lua
Normal file
22
blink_led1 - copie.lua
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
-- programme pour faire clignoter un LED
|
||||||
|
--hv20180711.1007
|
||||||
|
|
||||||
|
zpin=1
|
||||||
|
valeur=gpio.HIGH
|
||||||
|
duration = 300 --> en ms
|
||||||
|
|
||||||
|
|
||||||
|
function clignoter ()
|
||||||
|
if valeur==gpio.LOW then
|
||||||
|
valeur=gpio.HIGH
|
||||||
|
else
|
||||||
|
valeur=gpio.LOW
|
||||||
|
end
|
||||||
|
gpio.write(zpin, valeur)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
gpio.mode(zpin, gpio.OUTPUT)
|
||||||
|
gpio.write(zpin, valeur)
|
||||||
|
|
||||||
|
tmr.alarm(0,duration, tmr.ALARM_AUTO, clignoter)
|
||||||
22
blink_led1.lua
Normal file
22
blink_led1.lua
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
-- programme pour faire clignoter une LED avec un rapport on/off
|
||||||
|
--zf20180717.1118
|
||||||
|
|
||||||
|
zLED=0
|
||||||
|
zTm_On_LED = 900 --> en ms
|
||||||
|
zTm_Off_LED = 900 --> en ms
|
||||||
|
zFlag_LED = 0
|
||||||
|
|
||||||
|
function blink_LED ()
|
||||||
|
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)
|
||||||
|
end
|
||||||
|
gpio.write(zLED, zFlag_LED)
|
||||||
|
end
|
||||||
|
|
||||||
|
gpio.mode(zLED, gpio.OUTPUT)
|
||||||
|
ztmr_LED = tmr.create()
|
||||||
|
blink_LED ()
|
||||||
17
btn_led.lua
Normal file
17
btn_led.lua
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
-- 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)
|
||||||
38
clear_bootstrap.lua
Normal file
38
clear_bootstrap.lua
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
-- test de clearing de functions
|
||||||
|
print("\n clear_bootstrap.lua zf180720.1510 \n")
|
||||||
|
|
||||||
|
zRelay=nil
|
||||||
|
|
||||||
|
-- blink LED
|
||||||
|
if ztmr_LEDz then
|
||||||
|
tmr.stop(ztmr_LEDz)
|
||||||
|
tmr.unregister(ztmr_LEDz)
|
||||||
|
ztmr_LEDz=nil
|
||||||
|
end
|
||||||
|
if zLEDz then
|
||||||
|
gpio.mode(zLEDz, gpio.INPUT)
|
||||||
|
end
|
||||||
|
blink_LEDz=nil zLEDz=nil zFlag_LEDz=nil zTm_On_LEDz=nil zTm_Off_LEDz=nil
|
||||||
|
|
||||||
|
-- btn read
|
||||||
|
if ztmr_btnz then
|
||||||
|
tmr.stop(ztmr_btnz)
|
||||||
|
tmr.unregister(ztmr_btnz)
|
||||||
|
ztmr_btnz=nil
|
||||||
|
end
|
||||||
|
if zBTNz then
|
||||||
|
gpio.trig(zBTNz, "none")
|
||||||
|
gpio.mode(zBTNz, gpio.INPUT)
|
||||||
|
zBTNz=nil
|
||||||
|
end
|
||||||
|
btn_clicz=nil btn_testz=nil t1z=nil t2z=nil t3z=nil
|
||||||
|
|
||||||
|
-- get ip
|
||||||
|
if ztmr_get_ipz then
|
||||||
|
tmr.stop(ztmr_get_ipz)
|
||||||
|
get_ipz=nil
|
||||||
|
end
|
||||||
|
|
||||||
|
-- dir files
|
||||||
|
dir=nil l=nil k=nil v=nil i=nil
|
||||||
|
|
||||||
11
code2file.lua
Normal file
11
code2file.lua
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
-- écriture d'un script dans un fichier et l'exécute
|
||||||
|
-- zf180717.1517
|
||||||
|
jj = [[
|
||||||
|
print("toto")
|
||||||
|
print("tutu")
|
||||||
|
]]
|
||||||
|
|
||||||
|
file.open("toto1518.lua","w")
|
||||||
|
file.write(jj)
|
||||||
|
file.close()
|
||||||
|
dofile("toto1518.lua")
|
||||||
15
dir.lua
Normal file
15
dir.lua
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
-- fonction dir() pour afficher les fichiers dans la flash
|
||||||
|
-- zf180717.1542
|
||||||
|
|
||||||
|
function dir()
|
||||||
|
print("\n-------------------------------")
|
||||||
|
l=file.list() i=0
|
||||||
|
for k,v in pairs(l) do
|
||||||
|
i=i+v
|
||||||
|
print(k..string.rep(" ",19-string.len(k)).." : "..v.." bytes")
|
||||||
|
end
|
||||||
|
print("-------------------------------")
|
||||||
|
print('\nUsed: '..i..' bytes\nusage: dofile("file.lua")\n')
|
||||||
|
end
|
||||||
|
|
||||||
|
dir()
|
||||||
22
fleche.lua
Normal file
22
fleche.lua
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
print("Hello zuzu\nVersion 0.1.1")
|
||||||
|
|
||||||
|
-- Dessine une flèche sur la console
|
||||||
|
-- hv 180706.1059
|
||||||
|
-- source:
|
||||||
|
|
||||||
|
taille_fleche= 6
|
||||||
|
|
||||||
|
for i=1, 2*taille_fleche do
|
||||||
|
-- pointe de la fleche
|
||||||
|
if i==1 then print(string.rep(" ",taille_fleche).."*")
|
||||||
|
|
||||||
|
-- tete de la fleche
|
||||||
|
elseif i==2 or i<taille_fleche then print(string.rep(" ",taille_fleche-i).."*"..string.rep(" ",2*i-1).."*")
|
||||||
|
|
||||||
|
-- bas de la tete de la fleche
|
||||||
|
elseif i==taille_fleche then print(string.rep("*",taille_fleche*2+1))
|
||||||
|
|
||||||
|
-- queue de la fleche
|
||||||
|
elseif i>taille_fleche then print(string.rep(" ",taille_fleche).."*")
|
||||||
|
end
|
||||||
|
end
|
||||||
14
get_ip.lua
Normal file
14
get_ip.lua
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
-- get_ip.lua
|
||||||
|
-- branche le wifi et affiche l'adresse IP
|
||||||
|
-- zf180719.1039
|
||||||
|
|
||||||
|
wifi.sta.connect()
|
||||||
|
|
||||||
|
tmr.alarm(0, 1000, tmr.ALARM_AUTO , function()
|
||||||
|
if wifi.sta.getip() == nil then
|
||||||
|
print("Connecting to AP...")
|
||||||
|
else
|
||||||
|
print("Connected! IP: ",wifi.sta.getip())
|
||||||
|
tmr.stop(0)
|
||||||
|
end
|
||||||
|
end)
|
||||||
13
helloworld.lua
Normal file
13
helloworld.lua
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
-- blink the blue led builting
|
||||||
|
-- zf180709.2200
|
||||||
|
|
||||||
|
zpin=0 --led blue builting
|
||||||
|
gpio.mode(zpin, gpio.OUTPUT)
|
||||||
|
|
||||||
|
for i=1,20 do
|
||||||
|
print("Hello World "..i)
|
||||||
|
gpio.write(zpin, gpio.LOW)
|
||||||
|
tmr.delay(100000)
|
||||||
|
gpio.write(zpin, gpio.HIGH)
|
||||||
|
tmr.delay(100000)
|
||||||
|
end
|
||||||
2
init_minizf.lua
Normal file
2
init_minizf.lua
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
print("\nzinit zf180713.1449\n")
|
||||||
|
|
||||||
90
initz - copie 2.lua
Normal file
90
initz - copie 2.lua
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
-- initz.lua
|
||||||
|
-- test si clic sur le bouton
|
||||||
|
-- clic <2s goto start.lua
|
||||||
|
-- clic >2s goto config wifi
|
||||||
|
print("\ninit.lua zf180719.1100 \n")
|
||||||
|
|
||||||
|
zBTNz = 3 -- GPIO0 button
|
||||||
|
--zRelay = 6 -- GPIO12 PWM0 relay (active high)
|
||||||
|
zLEDz = 0 -- SonOff: 7 GPIO13 PWM1, NodeMCU: 0, (active low)
|
||||||
|
zFlag_LEDz = 0
|
||||||
|
|
||||||
|
function blink_LEDz ()
|
||||||
|
if zFlag_LEDz==gpio.LOW then
|
||||||
|
zFlag_LEDz=gpio.HIGH
|
||||||
|
tmr.alarm(ztmr_LEDz, zTm_Off_LEDz, tmr.ALARM_SINGLE, blink_LEDz)
|
||||||
|
else
|
||||||
|
zFlag_LEDz=gpio.LOW
|
||||||
|
tmr.alarm(ztmr_LEDz, zTm_On_LEDz, tmr.ALARM_SINGLE, blink_LEDz)
|
||||||
|
end
|
||||||
|
gpio.write(zLEDz, zFlag_LEDz)
|
||||||
|
end
|
||||||
|
|
||||||
|
gpio.mode(zLEDz, gpio.OUTPUT)
|
||||||
|
ztmr_LEDz = tmr.create()
|
||||||
|
zTm_On_LEDz = 500
|
||||||
|
zTm_Off_LEDz = 500
|
||||||
|
blink_LEDz ()
|
||||||
|
|
||||||
|
function btn_testz()
|
||||||
|
t2z=tmr.now()
|
||||||
|
t3z=(t2z-t1z)/1000000
|
||||||
|
if gpio.read(zBTNz)==1 then
|
||||||
|
tmr.stop(0)
|
||||||
|
gpio.trig(zBTNz)
|
||||||
|
tmr.stop(ztmr_LEDz)
|
||||||
|
gpio.write(zLEDz,1)
|
||||||
|
print("start.lua")
|
||||||
|
|
||||||
|
ztmr_clear_bootstrapz = tmr.create()
|
||||||
|
-- tmr.alarm(ztmr_clear_bootstrapz,1000,tmr.ALARM_SINGLE, function() dofile("clear_bootstrap.lua") end)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
dofile("start.lua")
|
||||||
|
end
|
||||||
|
if t3z>2 then
|
||||||
|
tmr.stop(0)
|
||||||
|
gpio.trig(zBTNz)
|
||||||
|
zTm_On_LEDz = 100
|
||||||
|
zTm_Off_LEDz = 100
|
||||||
|
blink_LEDz ()
|
||||||
|
wifi.sta.disconnect()
|
||||||
|
wifi.sta.clearconfig()
|
||||||
|
print("\nwifi config http://192.168.4.1\n")
|
||||||
|
tmr.alarm(0, 1000, tmr.ALARM_AUTO , get_ipz)
|
||||||
|
enduser_setup.start()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function btn_clicz()
|
||||||
|
t1z=tmr.now()
|
||||||
|
tmr.stop(ztmr_LEDz)
|
||||||
|
gpio.write(zLEDz,0)
|
||||||
|
tmr.alarm(0,100,tmr.ALARM_AUTO, btn_testz)
|
||||||
|
end
|
||||||
|
|
||||||
|
function get_ipz()
|
||||||
|
if wifi.sta.getip() == nil then
|
||||||
|
print("Connecting to AP...")
|
||||||
|
else
|
||||||
|
tmr.stop(0)
|
||||||
|
print("Connected! IP: ",wifi.sta.getip())
|
||||||
|
tmr.alarm(0,4000,tmr.ALARM_SINGLE, function() node.restart() end)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function dir()
|
||||||
|
l=file.list() i=0
|
||||||
|
for k,v in pairs(l) do
|
||||||
|
i=i+v print(k..string.rep(" ",19-string.len(k)).." : "..v.." bytes")
|
||||||
|
end
|
||||||
|
print('\nUsed: '..i..' bytes\nusage: dofile("file.lua")\n')
|
||||||
|
end
|
||||||
|
|
||||||
|
gpio.mode(zBTNz,gpio.INT)
|
||||||
|
gpio.trig(zBTNz, "down", btn_clicz)
|
||||||
|
|
||||||
|
wifi.sta.connect()
|
||||||
|
dofile("telnet_srv.lua")
|
||||||
|
|
||||||
90
initz - copie.lua
Normal file
90
initz - copie.lua
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
-- initz.lua
|
||||||
|
-- test si clic sur le bouton
|
||||||
|
-- clic <2s goto start.lua
|
||||||
|
-- clic >2s goto config wifi
|
||||||
|
print("\ninit.lua zf180719.1045 \n")
|
||||||
|
|
||||||
|
zBTN = 3 -- GPIO0 button
|
||||||
|
--zRelay = 6 -- GPIO12 PWM0 relay (active high)
|
||||||
|
zLED = 0 -- SonOff: 7 GPIO13 PWM1, NodeMCU: 0, (active low)
|
||||||
|
zFlag_LED = 0
|
||||||
|
|
||||||
|
function blink_LED ()
|
||||||
|
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)
|
||||||
|
end
|
||||||
|
gpio.write(zLED, zFlag_LED)
|
||||||
|
end
|
||||||
|
|
||||||
|
gpio.mode(zLED, gpio.OUTPUT)
|
||||||
|
ztmr_LED = tmr.create()
|
||||||
|
zTm_On_LED = 500
|
||||||
|
zTm_Off_LED = 500
|
||||||
|
blink_LED ()
|
||||||
|
|
||||||
|
function btn_test()
|
||||||
|
t2=tmr.now()
|
||||||
|
t3=(t2-t1)/1000000
|
||||||
|
if gpio.read(zBTN)==1 then
|
||||||
|
tmr.stop(0)
|
||||||
|
gpio.trig(zBTN)
|
||||||
|
tmr.stop(ztmr_LED)
|
||||||
|
gpio.write(zLED,1)
|
||||||
|
print("start.lua")
|
||||||
|
|
||||||
|
ztmr_clear_bootstrap = tmr.create()
|
||||||
|
tmr.alarm(ztmr_clear_bootstrap,1000,tmr.ALARM_SINGLE, function() dofile("clear_bootstrap.lua") end)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
dofile("start.lua")
|
||||||
|
end
|
||||||
|
if t3>2 then
|
||||||
|
tmr.stop(0)
|
||||||
|
gpio.trig(zBTN)
|
||||||
|
zTm_On_LED = 100
|
||||||
|
zTm_Off_LED = 100
|
||||||
|
blink_LED ()
|
||||||
|
wifi.sta.disconnect()
|
||||||
|
wifi.sta.clearconfig()
|
||||||
|
print("\nwifi config http://192.168.4.1\n")
|
||||||
|
tmr.alarm(0, 1000, tmr.ALARM_AUTO , get_ip)
|
||||||
|
enduser_setup.start()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function btn_clic()
|
||||||
|
t1=tmr.now()
|
||||||
|
tmr.stop(ztmr_LED)
|
||||||
|
gpio.write(zLED,0)
|
||||||
|
tmr.alarm(0,100,tmr.ALARM_AUTO, btn_test)
|
||||||
|
end
|
||||||
|
|
||||||
|
function get_ip()
|
||||||
|
if wifi.sta.getip() == nil then
|
||||||
|
print("Connecting to AP...")
|
||||||
|
else
|
||||||
|
tmr.stop(0)
|
||||||
|
print("Connected! IP: ",wifi.sta.getip())
|
||||||
|
tmr.alarm(0,4000,tmr.ALARM_SINGLE, function() node.restart() end)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function dir()
|
||||||
|
l=file.list() i=0
|
||||||
|
for k,v in pairs(l) do
|
||||||
|
i=i+v print(k..string.rep(" ",19-string.len(k)).." : "..v.." bytes")
|
||||||
|
end
|
||||||
|
print('\nUsed: '..i..' bytes\nusage: dofile("file.lua")\n')
|
||||||
|
end
|
||||||
|
|
||||||
|
gpio.mode(zBTN,gpio.INT)
|
||||||
|
gpio.trig(zBTN, "down", btn_clic)
|
||||||
|
|
||||||
|
wifi.sta.connect()
|
||||||
|
dofile("telnet_srv.lua")
|
||||||
|
|
||||||
75
initz.lua
Normal file
75
initz.lua
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
-- initz.lua
|
||||||
|
-- test si clic sur le bouton
|
||||||
|
-- clic <2s goto start.lua
|
||||||
|
-- clic >2s goto config wifi
|
||||||
|
print("\ninit.lua zf180720.1550 \n")
|
||||||
|
|
||||||
|
zBTNz = 3 -- GPIO0 button
|
||||||
|
--zRelay = 6 -- GPIO12 PWM0 relay (active high)
|
||||||
|
zLEDz = 0 -- SonOff: 7 GPIO13 PWM1, NodeMCU: 0, (active low)
|
||||||
|
zFlag_LEDz = 0
|
||||||
|
|
||||||
|
function blink_LEDz ()
|
||||||
|
if zFlag_LEDz==gpio.LOW then
|
||||||
|
zFlag_LEDz=gpio.HIGH tmr.alarm(ztmr_LEDz, zTm_Off_LEDz, tmr.ALARM_SINGLE, blink_LEDz)
|
||||||
|
else
|
||||||
|
zFlag_LEDz=gpio.LOW tmr.alarm(ztmr_LEDz, zTm_On_LEDz, tmr.ALARM_SINGLE, blink_LEDz)
|
||||||
|
end
|
||||||
|
gpio.write(zLEDz, zFlag_LEDz)
|
||||||
|
end
|
||||||
|
|
||||||
|
gpio.mode(zLEDz, gpio.OUTPUT)
|
||||||
|
ztmr_LEDz = tmr.create() zTm_On_LEDz = 500 zTm_Off_LEDz = 500 blink_LEDz ()
|
||||||
|
|
||||||
|
function btn_testz()
|
||||||
|
t2z=tmr.now()
|
||||||
|
t3z=(t2z-t1z)/1000000
|
||||||
|
if gpio.read(zBTNz)==1 then
|
||||||
|
tmr.stop(ztmr_btnz)
|
||||||
|
tmr.stop(ztmr_LEDz) gpio.write(zLEDz,1)
|
||||||
|
print("start.lua")
|
||||||
|
ztmr_clear_bootstrapz = tmr.create()
|
||||||
|
tmr.alarm(ztmr_clear_bootstrapz, 1000, tmr.ALARM_SINGLE, function() dofile("clear_bootstrap.lua") end)
|
||||||
|
dofile("start.lua")
|
||||||
|
else
|
||||||
|
if t3z>3 then
|
||||||
|
tmr.stop(ztmr_btnz)
|
||||||
|
zTm_On_LEDz = 100 zTm_Off_LEDz = 100 blink_LEDz ()
|
||||||
|
wifi.sta.disconnect() wifi.sta.clearconfig()
|
||||||
|
print("\nwifi config http://192.168.4.1\n")
|
||||||
|
ztmr_get_ipz = tmr.create() tmr.alarm(ztmr_get_ipz, 4000, tmr.ALARM_AUTO , get_ipz)
|
||||||
|
enduser_setup.start()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function btn_clicz()
|
||||||
|
gpio.trig(zBTNz, "none") gpio.mode(zBTNz,gpio.INPUT)
|
||||||
|
t1z=tmr.now()
|
||||||
|
tmr.stop(ztmr_LEDz) gpio.write(zLEDz,0)
|
||||||
|
ztmr_btnz = tmr.create() tmr.alarm(ztmr_btnz, 500,tmr.ALARM_AUTO, btn_testz)
|
||||||
|
end
|
||||||
|
|
||||||
|
function get_ipz()
|
||||||
|
if wifi.sta.getip() == nil then
|
||||||
|
print("Connecting to AP...")
|
||||||
|
else
|
||||||
|
tmr.stop(ztmr_get_ipz)
|
||||||
|
print("Connected! IP: ",wifi.sta.getip())
|
||||||
|
tmr.alarm(ztmr_get_ipz,1000,tmr.ALARM_SINGLE, function() node.restart() end)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function dir()
|
||||||
|
l=file.list() i=0
|
||||||
|
for k,v in pairs(l) do
|
||||||
|
i=i+v print(k..string.rep(" ",19-string.len(k)).." : "..v.." bytes")
|
||||||
|
end
|
||||||
|
print('\nUsed: '..i..' bytes\nusage: dofile("file.lua")\n')
|
||||||
|
end
|
||||||
|
|
||||||
|
gpio.mode(zBTNz,gpio.INT) gpio.trig(zBTNz, "down", btn_clicz)
|
||||||
|
|
||||||
|
wifi.sta.connect()
|
||||||
|
dofile("telnet_srv.lua")
|
||||||
|
|
||||||
11
show_ip.lua
Normal file
11
show_ip.lua
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
--Affiche l'adresse IP
|
||||||
|
--zf20180712.1110
|
||||||
|
|
||||||
|
tmr.alarm(0, 1000, tmr.ALARM_AUTO , function()
|
||||||
|
if wifi.sta.getip() == nil then
|
||||||
|
print("Connecting to AP...")
|
||||||
|
else
|
||||||
|
print("Connected! IP: ",wifi.sta.getip())
|
||||||
|
tmr.stop(0)
|
||||||
|
end
|
||||||
|
end)
|
||||||
27
start - copie.lua
Normal file
27
start - copie.lua
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
-- start.lua
|
||||||
|
-- programme de start
|
||||||
|
-- zf180719.1057
|
||||||
|
|
||||||
|
do
|
||||||
|
|
||||||
|
local zLED=0
|
||||||
|
local zTm_On_LED = 100 --> en ms
|
||||||
|
local zTm_Off_LED = 900 --> en ms
|
||||||
|
local zFlag_LED = 0
|
||||||
|
|
||||||
|
local function blink_LED ()
|
||||||
|
local ztmr_LED = tmr.create()
|
||||||
|
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)
|
||||||
|
end
|
||||||
|
gpio.write(zLED, zFlag_LED)
|
||||||
|
end
|
||||||
|
|
||||||
|
gpio.mode(zLED, gpio.OUTPUT)
|
||||||
|
blink_LED ()
|
||||||
|
|
||||||
|
end
|
||||||
23
start.lua
Normal file
23
start.lua
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
-- start.lua
|
||||||
|
-- programme de start
|
||||||
|
-- zf180717.1141
|
||||||
|
|
||||||
|
zLED=0
|
||||||
|
zTm_On_LED = 100 --> en ms
|
||||||
|
zTm_Off_LED = 900 --> en ms
|
||||||
|
zFlag_LED = 0
|
||||||
|
|
||||||
|
function blink_LED ()
|
||||||
|
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)
|
||||||
|
end
|
||||||
|
gpio.write(zLED, zFlag_LED)
|
||||||
|
end
|
||||||
|
|
||||||
|
gpio.mode(zLED, gpio.OUTPUT)
|
||||||
|
ztmr_LED = tmr.create()
|
||||||
|
blink_LED()
|
||||||
13
stop.lua
Normal file
13
stop.lua
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
-- stop.lua
|
||||||
|
-- programme de stop
|
||||||
|
-- zf180716.0010
|
||||||
|
|
||||||
|
zBTN = 3 -- GPIO0 button
|
||||||
|
zRelay = 6 -- GPIO12 PWM0 relay (active high)
|
||||||
|
zLED = 7 -- GPIO13 PWM1 GREEN LED (active low)
|
||||||
|
|
||||||
|
gpio.mode(zLED,gpio.OUTPUT)
|
||||||
|
pwm.stop(zLED)
|
||||||
|
gpio.write(zLED,1)
|
||||||
|
|
||||||
|
|
||||||
45
telnet_srv.lua
Normal file
45
telnet_srv.lua
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
-- a simple telnet server
|
||||||
|
print("\nzf180719.1043 \n")
|
||||||
|
|
||||||
|
-- restart server if needed
|
||||||
|
if telnet_srv ~= nil then
|
||||||
|
telnet_srv:close()
|
||||||
|
end
|
||||||
|
telnet_srv = net.createServer(net.TCP, 180)
|
||||||
|
|
||||||
|
telnet_srv:listen(23, function(socket)
|
||||||
|
local fifo = {}
|
||||||
|
local fifo_drained = true
|
||||||
|
|
||||||
|
local function sender(c)
|
||||||
|
if #fifo > 0 then
|
||||||
|
c:send(table.remove(fifo, 1))
|
||||||
|
else
|
||||||
|
fifo_drained = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function s_output(str)
|
||||||
|
table.insert(fifo, str)
|
||||||
|
if socket ~= nil and fifo_drained then
|
||||||
|
fifo_drained = false
|
||||||
|
sender(socket)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
node.output(s_output, 0) -- re-direct output to function s_ouput.
|
||||||
|
|
||||||
|
socket:on("receive", function(c, l)
|
||||||
|
node.input(l) -- works like pcall(loadstring(l)) but support multiple separate line
|
||||||
|
end)
|
||||||
|
socket:on("disconnection", function(c)
|
||||||
|
node.output(nil) -- un-regist the redirect output function, output goes to serial
|
||||||
|
end)
|
||||||
|
socket:on("sent", sender)
|
||||||
|
|
||||||
|
print("Welcome to NodeMCU world.")
|
||||||
|
end)
|
||||||
|
|
||||||
|
print("Telnet server running...\nUsage: telnet -r ip\n")
|
||||||
|
dofile("get_ip.lua")
|
||||||
|
|
||||||
51
web_on_off1.lua
Normal file
51
web_on_off1.lua
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
--Petit serveur WEB pour allumer/éteindre une LED en mode client WIFI
|
||||||
|
print("\nDémarrage hv&zf20180718.1041\n")
|
||||||
|
|
||||||
|
--wifi.sta.disconnect()
|
||||||
|
--wifi.setmode(wifi.STATION)
|
||||||
|
--print("set mode=STATION (mode="..wifi.getmode()..")")
|
||||||
|
--wifi.sta.config{ssid="Hugo", pwd="tototutu"}
|
||||||
|
|
||||||
|
wifi.sta.connect()
|
||||||
|
tmr.alarm(0, 1000, tmr.ALARM_AUTO , function()
|
||||||
|
if wifi.sta.getip() == nil then
|
||||||
|
print("Connecting to AP...")
|
||||||
|
else
|
||||||
|
print("Connected! IP: ",wifi.sta.getip())
|
||||||
|
tmr.stop(0)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
zLED=0
|
||||||
|
|
||||||
|
gpio.mode(zLED, gpio.OUTPUT)
|
||||||
|
gpio.write(zLED, gpio.HIGH)
|
||||||
|
srv = net.createServer(net.TCP)
|
||||||
|
srv:listen(80, function(conn)
|
||||||
|
conn:on("receive", function(client, request)
|
||||||
|
local buf = ""
|
||||||
|
local _, _, method, path, vars = string.find(request, "([A-Z]+) (.+)?(.+) HTTP")
|
||||||
|
if (method == nil) then
|
||||||
|
_, _, method, path = string.find(request, "([A-Z]+) (.+) HTTP")
|
||||||
|
end
|
||||||
|
local _GET = {}
|
||||||
|
if (vars ~= nil) then
|
||||||
|
for k, v in string.gmatch(vars, "(%w+)=(%w+)&*") do
|
||||||
|
_GET[k] = v
|
||||||
|
end
|
||||||
|
end
|
||||||
|
buf = buf .. "<!DOCTYPE html><html><body><h1>Hello, this is NodeMCU.</h1>Turn PIN : </br></br>"
|
||||||
|
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 .. "<a href=\"?pin=ON\"><button>ON</button></a> <a href=\"?pin=OFF\"><button>OFF</button></a>"
|
||||||
|
client:send(buf)
|
||||||
|
end)
|
||||||
|
conn:on("sent", function(c) c:close() end)
|
||||||
|
end)
|
||||||
|
|
||||||
8
web_stop.lua
Normal file
8
web_stop.lua
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
--Pour arrêter le petit serveur WEB
|
||||||
|
print("\nzf20180718.1049")
|
||||||
|
|
||||||
|
srv:close()
|
||||||
|
srv:listen(80, function(conn)
|
||||||
|
end)
|
||||||
|
|
||||||
|
print("\nWEB stopped\n")
|
||||||
4
wifi_off.lua
Normal file
4
wifi_off.lua
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
-- Déconnecte le WIFI
|
||||||
|
-- zf180713.1453
|
||||||
|
|
||||||
|
wifi.sta.disconnect()
|
||||||
19
wificnf_start.lua
Normal file
19
wificnf_start.lua
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
-- Enclenche le mode configuration WIFI
|
||||||
|
print("\nzf180718.1107\n")
|
||||||
|
|
||||||
|
function get_ip()
|
||||||
|
if wifi.sta.getip() == nil then
|
||||||
|
print("Connecting to AP...")
|
||||||
|
else
|
||||||
|
tmr.stop(0)
|
||||||
|
print("Connected! IP: ",wifi.sta.getip())
|
||||||
|
tmr.alarm(0,3000,tmr.ALARM_SINGLE, function() node.restart() end)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
wifi.sta.disconnect()
|
||||||
|
wifi.sta.clearconfig()
|
||||||
|
print("\nwifi config http://192.168.4.1\n")
|
||||||
|
tmr.alarm(0, 1000, tmr.ALARM_AUTO , get_ip)
|
||||||
|
enduser_setup.start()
|
||||||
|
|
||||||
4
wificnf_stop.lua
Normal file
4
wificnf_stop.lua
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
-- Déclenche le mode configuration WIFI
|
||||||
|
-- zf180713.1453
|
||||||
|
|
||||||
|
enduser_setup.stop()
|
||||||
Reference in New Issue
Block a user