Super bien avancé sur la démo du chapeau, good job
* il y a maintenant un petit serveur WEB qui permet de modifier certains paramètres de l'effet lumineux
This commit is contained in:
@@ -2,12 +2,12 @@
|
||||
-- tout sur la couleur: https://www.w3schools.com/colors/default.asp
|
||||
-- roue des couleurs: https://iro.js.org/?ref=oldsite
|
||||
|
||||
print("\n a_train3.lua zf181205.1903 \n")
|
||||
print("\n a_train3.lua zf181205.1919 \n")
|
||||
|
||||
nbleds=36
|
||||
fade1=0.05 ; fade2=0.2 ; fade3=0.4 ; fade4=1
|
||||
R1=255 ; G1=0 ; B1=0
|
||||
R2=255 ; G2=0 ; B2=0
|
||||
fade1=0.05 fade2=0.2 fade3=0.4 fade4=1
|
||||
R1=255 G1=0 B1=0
|
||||
R2=255 G2=0 B2=0
|
||||
train_speed=50
|
||||
ws2812.init()
|
||||
myLedStrip = ws2812.newBuffer(nbleds, 3)
|
||||
@@ -15,7 +15,7 @@ myLedStrip1 = ws2812.newBuffer(nbleds, 3)
|
||||
myLedStrip2 = ws2812.newBuffer(nbleds, 3)
|
||||
|
||||
function RGB_clear()
|
||||
myLedStrip:fill(0, 0, 0) ; ws2812.write(myLedStrip)
|
||||
myLedStrip:fill(0, 0, 0) ws2812.write(myLedStrip)
|
||||
end
|
||||
|
||||
function train1_fill()
|
||||
|
||||
@@ -1,6 +1,15 @@
|
||||
-- Scripts à charger après le boot pour démarrer son appli
|
||||
|
||||
print("\n boot.lua zf181204.2059 \n")
|
||||
print("\n boot.lua zf181205.2048 \n")
|
||||
|
||||
function heartbeat()
|
||||
f= "flash_led_xfois.lua" if file.exists(f) then dofile(f) end
|
||||
boottimer1=tmr.create()
|
||||
tmr.alarm(boottimer1, 1*1000, tmr.ALARM_AUTO, function()
|
||||
xfois =2
|
||||
blink_LED ()
|
||||
end)
|
||||
end
|
||||
|
||||
--f= "wifi_ap_stop.lua" if file.exists(f) then dofile(f) end
|
||||
--f= "wifi_cli_conf.lua" if file.exists(f) then dofile(f) end
|
||||
@@ -8,16 +17,12 @@ print("\n boot.lua zf181204.2059 \n")
|
||||
--f= "telnet_srv.lua" if file.exists(f) then dofile(f) end
|
||||
--f= "web_ide2.lua" if file.exists(f) then dofile(f) end
|
||||
f= "az_init_led.lua" if file.exists(f) then dofile(f) end
|
||||
f= "wifi_cli_start.lua" if file.exists(f) then dofile(f) end
|
||||
f= "webleds.lua" if file.exists(f) then dofile(f) end
|
||||
f= "a_train3.lua" if file.exists(f) then dofile(f) end
|
||||
|
||||
heartbeat()
|
||||
|
||||
|
||||
|
||||
f= "flash_led_xfois.lua" if file.exists(f) then dofile(f) end
|
||||
boottimer1=tmr.create()
|
||||
tmr.alarm(boottimer1, 1*1000, tmr.ALARM_AUTO, function()
|
||||
xfois =2
|
||||
blink_LED ()
|
||||
end)
|
||||
|
||||
|
||||
|
||||
9
LED_RGB_WS2812/chapeau_led/credentials.lua
Normal file
9
LED_RGB_WS2812/chapeau_led/credentials.lua
Normal file
@@ -0,0 +1,9 @@
|
||||
-- Petit script pour configurer les choses secrètes que l'on n'aimerait
|
||||
-- pas être exportées sur Internet (github)
|
||||
-- faut donc le mettre ailleurs que dans le dépôt !
|
||||
|
||||
print("\n credential.lua zf181205.1910 \n")
|
||||
|
||||
cli_ssid="3g-s7"
|
||||
cli_pwd="12234567"
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>LED Strip Control</title>
|
||||
<style>
|
||||
|
||||
body {
|
||||
font-family: Bitstream Vera Sans, Verdana, Helvetica, Arial, sans-serif;
|
||||
font-size: 12px;
|
||||
background-color: #dddddd;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 32px;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
/* this matches 'retina' displays */
|
||||
@media screen and (-webkit-min-device-pixel-ratio: 2) {
|
||||
body {
|
||||
font-size: 24px;
|
||||
}
|
||||
h1 {
|
||||
font-size: 64px;
|
||||
}
|
||||
h2 {
|
||||
font-size: 48px;
|
||||
}
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>LED strip control page</h1>
|
||||
|
||||
<h2>Choose an effect:</h2>
|
||||
<ul>
|
||||
<li><a href="/?set=effect&effect=rainbow_cycle">Rainbow Cycle</a></li>
|
||||
<li><a href="/?set=effect&effect=larson_scanner">Larson Scanner</a></li>
|
||||
<li><a href="/?set=effect&effect=fire">Fire</a></li>
|
||||
<li><a href="/?set=effect&effect=blink">Blink</a></li>
|
||||
<li><a href="/?set=effect&effect=circus_combustus">Circus Combustus</a></li>
|
||||
</ul>
|
||||
|
||||
<h2>Pick a color:</h2>
|
||||
<ul>
|
||||
<li><a href="/?set=color&r=255&g=0&b=0">Red</a></li>
|
||||
<li><a href="/?set=color&r=0&g=255&b=0">Green</a></li>
|
||||
<li><a href="/?set=color&r=0&g=0&b=255">Blue</a></li>
|
||||
<li><a href="/?set=color&r=255&g=255&b=255">White</a></li>
|
||||
<li><a href="/?set=color&r=0&g=0&b=0">Black</a></li>
|
||||
</ul>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
-- initially based on https://github.com/nodemcu/nodemcu-firmware/blob/master/lua_examples/webap_toggle_pin.lua
|
||||
|
||||
-- start wifi client or AP mode
|
||||
--dofile('wificlient.lua')
|
||||
dofile('wifiap.lua')
|
||||
|
||||
-- LED init (strip with 72 leds)
|
||||
print("Initializing LED strip...")
|
||||
ws2812.init()
|
||||
strip_buffer = ws2812.newBuffer(6, 3)
|
||||
ws2812_effects.init(strip_buffer)
|
||||
-- initially all leds off
|
||||
ws2812_effects.set_speed(200)
|
||||
ws2812_effects.set_brightness(0)
|
||||
ws2812_effects.set_color(0,0,0)
|
||||
ws2812_effects.start()
|
||||
print("done.")
|
||||
print()
|
||||
|
||||
-- helper functions
|
||||
-- send a file from memory to the client; max. line length = 1024 bytes!
|
||||
function send_file(client, filename)
|
||||
if file.open(filename, "r") then
|
||||
repeat
|
||||
local line=file.read('\n')
|
||||
if line then
|
||||
client:send(line)
|
||||
end
|
||||
until not line
|
||||
file.close()
|
||||
end
|
||||
end
|
||||
|
||||
-- web server
|
||||
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 (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)
|
||||
conn:on("sent", function(c) c:close() end)
|
||||
end)
|
||||
|
||||
10
LED_RGB_WS2812/chapeau_led/goodies/wifi_ap_stop.lua
Normal file
10
LED_RGB_WS2812/chapeau_led/goodies/wifi_ap_stop.lua
Normal file
@@ -0,0 +1,10 @@
|
||||
-- Démarre le WIFI en mode AP
|
||||
print("\n wifi_ap_stop.lua zf180824.2000 \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é")
|
||||
10
LED_RGB_WS2812/chapeau_led/goodies/wifi_cli_stop.lua
Normal file
10
LED_RGB_WS2812/chapeau_led/goodies/wifi_cli_stop.lua
Normal file
@@ -0,0 +1,10 @@
|
||||
-- Démarre le WIFI en mode AP
|
||||
print("\n wifi_cli_stop.lua zf180824.2000 \n")
|
||||
|
||||
local zmodewifi=wifi.getmode()
|
||||
if zmodewifi == wifi.STATION then
|
||||
wifi.setmode(wifi.NULLMODE)
|
||||
elseif zmodewifi == wifi.STATIONAP then
|
||||
wifi.setmode(wifi.SOFTAP)
|
||||
end
|
||||
print("WIFI CLI arrêté")
|
||||
68
LED_RGB_WS2812/chapeau_led/index.html
Normal file
68
LED_RGB_WS2812/chapeau_led/index.html
Normal file
@@ -0,0 +1,68 @@
|
||||
<!DOCTYPE html>
|
||||
<!-- code HTML pour piloter les effets des LED RGB -->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>LED RGB zf181205.2048</title>
|
||||
<style>
|
||||
|
||||
body {
|
||||
font-family: Bitstream Vera Sans, Verdana, Helvetica, Arial, sans-serif;
|
||||
font-size: 12px;
|
||||
background-color: #dddddd;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 32px;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
/* this matches 'retina' displays */
|
||||
@media screen and (-webkit-min-device-pixel-ratio: 2) {
|
||||
body {
|
||||
font-size: 24px;
|
||||
}
|
||||
h1 {
|
||||
font-size: 64px;
|
||||
}
|
||||
h2 {
|
||||
font-size: 48px;
|
||||
}
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<meta charset='utf-8'>
|
||||
<h1>Contrôle des effets des LED's RGB du chapeau</h1>
|
||||
|
||||
<a href="/">Home</a>
|
||||
|
||||
<h2>Start & Stop:</h2>
|
||||
<ul>
|
||||
<li><a href="/?fonction=start">Start</a></li>
|
||||
<li><a href="/?fonction=stop">Stop</a></li>
|
||||
</ul>
|
||||
|
||||
<h2>Vitesse de l'effet:</h2>
|
||||
<ul>
|
||||
<li><a href="/?set=speed&speed=inc">Plus vite</a></li>
|
||||
<li><a href="/?set=speed&speed=dec">Plus lent</a></li>
|
||||
</ul>
|
||||
|
||||
<h2>Couleurs des trains:</h2>
|
||||
<ul>
|
||||
<li><a href="/?set=color&R1=255&G1=255&B1=255&R2=255&G2=255&B2=255">Blanc</a></li>
|
||||
<li><a href="/?set=color&R1=255&G1=0&B1=0&R2=255&G2=0&B2=0">Rouge</a></li>
|
||||
<li><a href="/?set=color&R1=255&G1=0&B1=0&R2=0&G2=0&B2=255">Brexit</a></li>
|
||||
<li><a href="/?set=color&R1=0&G1=255&B1=0&R2=0&G2=255&B2=0">Ecolo</a></li>
|
||||
</ul>
|
||||
|
||||
<a href="/?restart=1">Restart</a>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
111
LED_RGB_WS2812/chapeau_led/webleds.lua
Normal file
111
LED_RGB_WS2812/chapeau_led/webleds.lua
Normal file
@@ -0,0 +1,111 @@
|
||||
-- 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")
|
||||
|
||||
|
||||
-- send a file from memory to the client; max. line length = 1024 bytes!
|
||||
function send_file(client, filename)
|
||||
if file.open(filename, "r") then
|
||||
repeat
|
||||
local line=file.read('\n')
|
||||
if line then
|
||||
client:send(line)
|
||||
end
|
||||
until not line
|
||||
file.close()
|
||||
end
|
||||
end
|
||||
|
||||
-- web server
|
||||
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
|
||||
_, _, method, path = string.find(request, "([A-Z]+) (.+) HTTP")
|
||||
end
|
||||
_GET = {}
|
||||
if (vars ~= nil) then
|
||||
for k, v in string.gmatch(vars, "(%w+)=(%w+)&*") do
|
||||
_GET[k] = v
|
||||
print(k..": "..v)
|
||||
end
|
||||
end
|
||||
|
||||
if (_GET.fonction == "start") then
|
||||
train_start()
|
||||
end
|
||||
|
||||
if (_GET.fonction == "stop") then
|
||||
train_stop()
|
||||
end
|
||||
|
||||
if (_GET.set == "speed") then
|
||||
train_stop()
|
||||
if (_GET.speed == "inc") then
|
||||
train_speed=train_speed*0.8
|
||||
else
|
||||
train_speed=train_speed*1.2
|
||||
end
|
||||
train_start()
|
||||
end
|
||||
|
||||
if (_GET.set == "color") then
|
||||
print("setting color (RGB)", _GET.R1, _GET.G1, _GET.B1)
|
||||
train_stop()
|
||||
R1=_GET.R1 G1=_GET.G1 B1=_GET.B1
|
||||
R2=_GET.R2 G2=_GET.G2 B2=_GET.B2
|
||||
train1_fill()
|
||||
train2_fill()
|
||||
train_start()
|
||||
end
|
||||
|
||||
if (_GET.restart == "1") then
|
||||
restarttimer1=tmr.create()
|
||||
tmr.alarm(restarttimer1, 2*1000, tmr.ALARM_SINGLE, function()
|
||||
node.restart()
|
||||
end)
|
||||
end
|
||||
|
||||
|
||||
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)
|
||||
conn:on("sent", function(c) c:close() end)
|
||||
end)
|
||||
|
||||
12
LED_RGB_WS2812/chapeau_led/wifi_cli_conf.lua
Normal file
12
LED_RGB_WS2812/chapeau_led/wifi_cli_conf.lua
Normal file
@@ -0,0 +1,12 @@
|
||||
-- Petit script pour configurer le client WIFI du NodeMCU
|
||||
|
||||
print("\n wifi_cli_conf.lua zf181205.1931 \n")
|
||||
|
||||
--credentials par défaut
|
||||
cli_ssid="3g-s7"
|
||||
cli_pwd="12234567"
|
||||
|
||||
--ses propre credentials
|
||||
f= "credentials.lua" if file.exists(f) then dofile(f) end
|
||||
|
||||
wifi.sta.config{ssid=cli_ssid, pwd=cli_pwd, save=true}
|
||||
14
LED_RGB_WS2812/chapeau_led/wifi_cli_start.lua
Normal file
14
LED_RGB_WS2812/chapeau_led/wifi_cli_start.lua
Normal file
@@ -0,0 +1,14 @@
|
||||
-- Petit script pour connecter le NodeMCU sur un AP Wifi avec l'accompte sauvé en EEPROM
|
||||
print("\n wifi_cli_start.lua zf181119.2359 \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)
|
||||
end
|
||||
wifi.sta.autoconnect(1)
|
||||
wifi.sta.connect()
|
||||
f= "wifi_get_ip.lua" if file.exists(f) then dofile(f) end
|
||||
@@ -2,68 +2,67 @@
|
||||
-- tout sur la couleur: https://www.w3schools.com/colors/default.asp
|
||||
-- roue des couleurs: https://iro.js.org/?ref=oldsite
|
||||
|
||||
print("\n a_chapeau_z.lua zf181204.2057 \n")
|
||||
print("\n a_train3.lua zf181205.1903 \n")
|
||||
|
||||
znbled=36
|
||||
nbleds=36
|
||||
fade1=0.05 ; fade2=0.2 ; fade3=0.4 ; fade4=1
|
||||
R1=255 ; G1=0 ; B1=0
|
||||
R2=255 ; G2=0 ; B2=0
|
||||
train_speed=50
|
||||
ws2812.init()
|
||||
myLedStrip = ws2812.newBuffer(nbleds, 3)
|
||||
myLedStrip1 = ws2812.newBuffer(nbleds, 3)
|
||||
myLedStrip2 = ws2812.newBuffer(nbleds, 3)
|
||||
|
||||
function RGB_clear()
|
||||
ws2812.init()
|
||||
buffer = ws2812.newBuffer(znbled, 3)
|
||||
buffer:fill(0, 0, 0)
|
||||
ws2812.write(buffer)
|
||||
myLedStrip:fill(0, 0, 0) ; ws2812.write(myLedStrip)
|
||||
end
|
||||
|
||||
function train1_fill()
|
||||
myLedStrip1:fill(0,0,0)
|
||||
myLedStrip1:set(1, G1*fade1, R1*fade1, B1*fade1)
|
||||
myLedStrip1:set(2, G1*fade2, R1*fade2, B1*fade2)
|
||||
myLedStrip1:set(3, G1*fade3, R1*fade3, B1*fade3)
|
||||
myLedStrip1:set(4, G1*fade4, R1*fade4, B1*fade4)
|
||||
end
|
||||
|
||||
function train2_fill()
|
||||
myLedStrip2:fill(0,0,0)
|
||||
myLedStrip2:set(nbleds, G2*fade1, R2*fade1, B2*fade1)
|
||||
myLedStrip2:set(nbleds-1, G2*fade2, R2*fade2, B2*fade2)
|
||||
myLedStrip2:set(nbleds-2, G2*fade3, R2*fade3, B2*fade3)
|
||||
myLedStrip2:set(nbleds-3, G2*fade4, R2*fade4, B2*fade4)
|
||||
end
|
||||
|
||||
function train_mix()
|
||||
myLedStrip:mix(255, myLedStrip1, 255, myLedStrip2)
|
||||
end
|
||||
|
||||
function train_shift()
|
||||
myLedStrip1:shift(1, ws2812.SHIFT_CIRCULAR)
|
||||
myLedStrip2:shift(-1, ws2812.SHIFT_CIRCULAR)
|
||||
end
|
||||
|
||||
function train_write()
|
||||
ws2812.write(myLedStrip)
|
||||
end
|
||||
|
||||
function train_start()
|
||||
train3timer1=tmr.create()
|
||||
tmr.alarm(train3timer1, train_speed, tmr.ALARM_AUTO, function()
|
||||
train_shift()
|
||||
train_mix()
|
||||
train_write()
|
||||
end)
|
||||
end
|
||||
|
||||
function train_stop()
|
||||
tmr.unregister(train3timer1)
|
||||
RGB_clear()
|
||||
end
|
||||
|
||||
RGB_clear()
|
||||
train1_fill()
|
||||
train2_fill()
|
||||
train_start()
|
||||
|
||||
|
||||
fadeLevel=3
|
||||
|
||||
train1_R=255
|
||||
train1_G=0
|
||||
train1_B=0
|
||||
|
||||
train2_R=255
|
||||
train2_G=0
|
||||
train2_B=0
|
||||
|
||||
-- Buffer Train 1
|
||||
myLedStrip1 = ws2812.newBuffer(znbled, 3)
|
||||
myLedStrip1:fill(0,0,0)
|
||||
myLedStrip1:set(1, train1_G, train1_R, train1_B)
|
||||
myLedStrip1:fade(fadeLevel)
|
||||
myLedStrip1:set(2, train1_G, train1_R, train1_B)
|
||||
myLedStrip1:fade(fadeLevel)
|
||||
myLedStrip1:set(3, train1_G, train1_R, train1_B)
|
||||
myLedStrip1:fade(fadeLevel)
|
||||
myLedStrip1:set(4, train1_G, train1_R, train1_B)
|
||||
ws2812.write(myLedStrip1)
|
||||
|
||||
-- Buffer Train 2
|
||||
myLedStrip2 = ws2812.newBuffer(znbled, 3)
|
||||
myLedStrip2:fill(0,0,0)
|
||||
myLedStrip2:set(znbled, train2_G, train2_R, train2_B)
|
||||
myLedStrip2:fade(fadeLevel)
|
||||
myLedStrip2:set(znbled-1, train2_G, train2_R, train2_B)
|
||||
myLedStrip2:fade(fadeLevel)
|
||||
myLedStrip2:set(znbled-2, train2_G, train2_R, train2_B)
|
||||
myLedStrip2:fade(fadeLevel)
|
||||
myLedStrip2:set(znbled-3, train2_G, train2_R, train2_B)
|
||||
ws2812.write(myLedStrip2)
|
||||
|
||||
-- Buffer Train Total
|
||||
myLedStrip = ws2812.newBuffer(znbled, 3)
|
||||
myLedStrip:mix(255, myLedStrip1, 255, myLedStrip2)
|
||||
ws2812.write(myLedStrip)
|
||||
|
||||
-- Train move
|
||||
zspeed=25
|
||||
train2timer1=tmr.create()
|
||||
tmr.alarm(train2timer1, zspeed, tmr.ALARM_AUTO, function()
|
||||
|
||||
myLedStrip1:shift(1, ws2812.SHIFT_CIRCULAR) -- direction →
|
||||
myLedStrip2:shift(-1, ws2812.SHIFT_CIRCULAR) -- direction ←
|
||||
|
||||
myLedStrip:mix(255, myLedStrip1, 255, myLedStrip2) -- mix both train
|
||||
ws2812.write(myLedStrip)
|
||||
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user