Super bien avancé sur ma démo de chapeau
* ajouté un mini WEB IDE qui permet directement sur le NodeMCU d'éditer un script LUA * refactorisé un poil mes deux WEB IDE * rangé au bon endroit mes dexu WEB IDE
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
-- Petit script de serveur WEB pour piloter les effets des LED RGB
|
||||
-- source: https://github.com/nodemcu/nodemcu-firmware/blob/master/lua_examples/webap_toggle_pin.lua
|
||||
|
||||
print("\n webleds.lua zf181205.2048 \n")
|
||||
print("\n webleds.lua zf181205.2101 \n")
|
||||
|
||||
|
||||
-- send a file from memory to the client; max. line length = 1024 bytes!
|
||||
@@ -22,9 +22,6 @@ srv = net.createServer(net.TCP)
|
||||
srv:listen(80, function(conn)
|
||||
conn:on("receive", function(client, request)
|
||||
local _, _, method, path, vars = string.find(request, "([A-Z]+) (.+)?(.+) HTTP")
|
||||
|
||||
|
||||
|
||||
if not string.find(request, "/favicon.ico") then
|
||||
--print("coucou")
|
||||
if (method == nil) then
|
||||
@@ -76,35 +73,7 @@ srv:listen(80, function(conn)
|
||||
|
||||
print("send html...")
|
||||
send_file(client, 'index.html')
|
||||
end
|
||||
|
||||
|
||||
|
||||
--[[
|
||||
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+)=([a-z0-9_]+)&*") do
|
||||
_GET[k] = v
|
||||
end
|
||||
end
|
||||
if (_GET.set == "effect") then
|
||||
print("setting effect", _GET.effect)
|
||||
ws2812_effects.set_mode(_GET.effect)
|
||||
ws2812_effects.set_speed(200)
|
||||
ws2812_effects.set_brightness(50)
|
||||
ws2812_effects.start()
|
||||
end
|
||||
if (_GET.set == "color") then
|
||||
print("setting color (RGB)", _GET.r, _GET.g, _GET.b)
|
||||
ws2812_effects.set_color(_GET.g, _GET.r, _GET.b) -- obviously our strip is GRB and not RGB
|
||||
end
|
||||
send_file(client, 'index.html')
|
||||
--]]
|
||||
|
||||
|
||||
end
|
||||
end)
|
||||
conn:on("sent", function(c) c:close() end)
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user