- ajouté toute la partie web_oled pour le mini display remote et surtout la partie web_cli pour la partie send to display remote

This commit is contained in:
Christian Zufferey
2018-08-29 12:50:52 +02:00
parent 2f9cbb10a3
commit d2ca9a4d3a
9 changed files with 172586 additions and 0 deletions

172443
ESPlorer.Log Normal file

File diff suppressed because it is too large Load Diff

0
ESPlorer.Log.lck Normal file
View File

View File

@@ -0,0 +1,39 @@
-- Affiche plusieurs lignes sur le mini display OLED du MiniD1
-- Source: https://wiki.wemos.cc/products:d1_mini_shields:oled_shield
-- font_10x20,font_6x10,font_7x13,font_8x13,font_9x15,font_chikita
print("\n disp_oled.lua zf180826.1807 \n")
-- config pour le mini display OLED du Wemos Mini_D1
pin_scl = 1
pin_sda = 2
disp_sla = 0x3c
function init_OLED(sda, scl)
i2c.setup(0, sda, scl, i2c.SLOW)
disp = u8g.ssd1306_64x48_i2c(disp_sla)
disp:setFontRefHeightExtendedText()
disp:setDefaultForegroundColor()
end
-- font_10x20,font_6x10,font_7x13,font_8x13,font_9x15,font_chikita
--..string.char(233)..":") -- pour afficher un é !
function draw()
disp:setFont(u8g.font_10x20)
disp:setFontPosTop()
disp:drawStr(0,00,oled_line1)
disp:setFont(u8g.font_chikita)
disp:setFontPosTop()
disp:drawStr(0,17,oled_line2)
disp:drawStr(0,24,oled_line3)
disp:drawStr(0,31,oled_line4)
disp:drawStr(0,38,oled_line5)
end
function disp_oled()
disp:firstPage()
repeat
draw()
until disp:nextPage() == false
end
init_OLED(pin_sda, pin_scl)

View File

@@ -0,0 +1,19 @@
-- super mini bootstrap
print("\n init_minizf1.lua zf180828.1825 \n")
tmr.alarm(0, 5000, tmr.ALARM_SINGLE, function()
dofile("disp_oled.lua")
oled_line1="RESET"
oled_line2=""
oled_line3=""
oled_line4=""
oled_line5=""
disp_oled()
dofile("wifi_ap_start.lua")
dofile("telnet_srv.lua")
dofile("web_oled_minid1.lua")
dofile("start_demo.lua")
end)

View File

@@ -0,0 +1,12 @@
-- Permet de démarrer une petite démo simplement via telnet
print("\n start_demo1.lua zf180828.1816 \n")
--dofile("disp_oled.lua")
oled_line1="DEMO"
oled_line2="hauteur cuve:"
oled_line3="2.57 m"
oled_line4=""
oled_line5=wifi.ap.getip()
disp_oled()

View File

@@ -0,0 +1,51 @@
--Petit serveur WEB pour afficher des choses sur un mini display OLED minid1
print("\n web_oled_minid1.lua zf180828.1812 \n")
--source: https://github.com/diegonehab/luasocket/blob/master/src/url.lua
function unescape(s)
return (string.gsub(s, "%%(%x%x)", function(hex)
return string.char(tonumber(hex, 16))
end))
end
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 = {}
print("\nNouvelle entrée !")
if (vars ~= nil) then
print("Input: "..vars)
for k, v in string.gmatch(vars, "(%w+)=([%w+-@%%]+)&*") do
_GET[k] = v
print(k..": "..v)
end
end
f1=false
if _GET.line1 then oled_line1=_GET.line1 f1=true else oled_line1="" end
if _GET.line2 then oled_line2=_GET.line2 f1=true else oled_line2="" end
if _GET.line3 then oled_line3=_GET.line3 f1=true else oled_line3="" end
if _GET.line4 then oled_line4=_GET.line4 f1=true else oled_line4="" end
if _GET.line5 then oled_line5=_GET.line5 f1=true else oled_line5="" end
if f1 then disp_oled() end
buf = "<!DOCTYPE html><html><body><h1>web_oled</h1>".."\n"
buf = buf.."<form action='/' method='get' id='hform'>"
buf = buf.."line1: <input type='text' name='line1' value='"..oled_line1.."'><br>".."\n"
buf = buf.."line2: <input type='text' name='line2' value='"..oled_line2.."'><br>".."\n"
buf = buf.."line3: <input type='text' name='line3' value='"..oled_line3.."'><br>".."\n"
buf = buf.."line4: <input type='text' name='line4' value='"..oled_line4.."'><br>".."\n"
buf = buf.."line5: <input type='text' name='line5' value='"..oled_line5.."'><br>".."\n"
buf = buf.."</form><br>".."\n"
buf = buf.."<button type='submit' form='hform' value='Submit'>ok</button>".."\n"
buf = buf.."</body></html>".."\n"
client:send(buf)
end)
conn:on("sent", function(c) c:close() end)
end)

View File

@@ -18,7 +18,11 @@ function disp_mesure ()
oled_line4=""
oled_line5="180826.2213"
disp_oled()
disp_send()
end
dofile("web_cli.lua")
dofile("ultra_son.lua")
tmr.alarm(detectortimer1, 1000, tmr.ALARM_AUTO, zmesure_pulse)

View File

@@ -0,0 +1,12 @@
-- Petit script pour envoyer quelque chose sur un serveur WEB
print("\n web_cli.lua zf180828.1849 \n")
function disp_send()
http.get("http://192.168.4.1/?line1="..zlength.."m", nil, function(code, data)
if (code < 0) then
-- print("HTTP request failed")
else
-- print(code, data)
end
end)
end

6
start_ESPlorer.sh Executable file
View File

@@ -0,0 +1,6 @@
#!/bin/bash
#Petit script pour lancer facilement ESPlorer en JAVA
#zf180822.0848
java -jar ESPlorer.jar &