Refactorisé dossiers et écrit l'effet pour le chapeau
* l'effet train3 est le shift décalé de deux buffers avec mix des deux * refactorisé encore une fois les dossiers de LED RGB
This commit is contained in:
13
LED_RGB_WS2812/fill_effect/README.md
Normal file
13
LED_RGB_WS2812/fill_effect/README.md
Normal file
@@ -0,0 +1,13 @@
|
||||
# Gurilande effects
|
||||
|
||||
Tests fait pour ma guirlande du balcon pour Noël
|
||||
|
||||
Problème, j'ai 5 mètres de ruban avec 300 LED RGB et quand je les allume tous à fond, le courant n'arrive pas à arriver au bout du ruban.
|
||||
|
||||
Il faut donc jouer sur la puissance des LED et l'écartement, c'est à dire allumer que une sur deux ou trois.
|
||||
|
||||
|
||||
zf181201.1153
|
||||
|
||||
|
||||
|
||||
40
LED_RGB_WS2812/fill_effect/a_guirlande.lua
Normal file
40
LED_RGB_WS2812/fill_effect/a_guirlande.lua
Normal file
@@ -0,0 +1,40 @@
|
||||
-- Scripts effet guirlande de Noël pour le balcon
|
||||
-- tout sur la couleur: https://www.w3schools.com/colors/default.asp
|
||||
-- roue des couleurs: https://iro.js.org/?ref=oldsite
|
||||
|
||||
print("\n a_guirlande.lua zf181201.1146 \n")
|
||||
|
||||
znbled=300
|
||||
zstep=3
|
||||
zpower=0.8
|
||||
|
||||
function RGB_clear()
|
||||
ws2812.init()
|
||||
buffer = ws2812.newBuffer(znbled, 3)
|
||||
buffer:fill(0, 0, 0)
|
||||
ws2812.write(buffer)
|
||||
end
|
||||
|
||||
RGB_clear()
|
||||
|
||||
for i=1, znbled, zstep do
|
||||
buffer:set(i, 123*zpower, 124*zpower, 125*zpower)
|
||||
end
|
||||
ws2812.write(buffer)
|
||||
|
||||
a={}
|
||||
a=buffer:get(1)
|
||||
print(buffer:get(1))
|
||||
print(a)
|
||||
|
||||
|
||||
a={}
|
||||
a[0]=123
|
||||
a[1]=124
|
||||
a[2]=125
|
||||
|
||||
print(a[0],a[1],a[2])
|
||||
|
||||
|
||||
|
||||
|
||||
19
LED_RGB_WS2812/fill_effect/az_init_led.lua
Normal file
19
LED_RGB_WS2812/fill_effect/az_init_led.lua
Normal file
@@ -0,0 +1,19 @@
|
||||
-- Scripts juste pour éteindre toutes les LED du ruban
|
||||
-- tout sur la couleur: https://www.w3schools.com/colors/default.asp
|
||||
-- roue des couleurs: https://iro.js.org/?ref=oldsite
|
||||
|
||||
print("\n az_init_led.lua zf181201.1751 \n")
|
||||
|
||||
znbled=300
|
||||
|
||||
function RGB_clear()
|
||||
ws2812.init()
|
||||
buffer = ws2812.newBuffer(znbled, 3)
|
||||
buffer:fill(0, 0, 0)
|
||||
ws2812.write(buffer)
|
||||
end
|
||||
|
||||
print("Initializing LED strip...")
|
||||
RGB_clear()
|
||||
print("done.")
|
||||
|
||||
33
LED_RGB_WS2812/fill_effect/boot.lua
Normal file
33
LED_RGB_WS2812/fill_effect/boot.lua
Normal file
@@ -0,0 +1,33 @@
|
||||
-- Scripts à charger après le boot pour démarrer son appli
|
||||
|
||||
print("\n boot.lua zf181125.1635 \n")
|
||||
|
||||
--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
|
||||
--f= "wifi_cli_start.lua" if file.exists(f) then dofile(f) end
|
||||
--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= "dsleep.lua" if file.exists(f) then dofile(f) end
|
||||
|
||||
f= "a_test_train.lua" if file.exists(f) then dofile(f) end
|
||||
--f= "a_test_fill.lua" if file.exists(f) then dofile(f) end
|
||||
|
||||
|
||||
|
||||
|
||||
--[[
|
||||
x_dsleep=7 y_dsleep=30 dsleep()
|
||||
|
||||
i=1
|
||||
jobtimer1=tmr.create()
|
||||
tmr.alarm(jobtimer1, 1*1000, tmr.ALARM_AUTO, function()
|
||||
print(i) i=i+1
|
||||
if wifi.sta.getip() ~= nil then
|
||||
tmr.stop(jobtimer1)
|
||||
tmr.stop(ztmr_SLEEP)
|
||||
x_dsleep=300 y_dsleep=30 dsleep()
|
||||
print("c'est connecté...")
|
||||
end
|
||||
end)
|
||||
]]
|
||||
|
||||
31
LED_RGB_WS2812/fill_effect/initz.lua
Normal file
31
LED_RGB_WS2812/fill_effect/initz.lua
Normal file
@@ -0,0 +1,31 @@
|
||||
--Script de bootstrap, test au moment du boot qui a été la cause de boot.
|
||||
-- Si la cause est un power on ou une connexion depuis l'IDE, alors
|
||||
-- le script repair.lua pendant xx secondes avant de continuer
|
||||
--Source: https://nodemcu.readthedocs.io/en/master/en/modules/node/#nodebootreason
|
||||
|
||||
print("\n init.lua zf181125.1428 \n")
|
||||
|
||||
function second_chance()
|
||||
print("seconde chance...")
|
||||
f= "repair.lua" if file.exists(f) then dofile(f) end
|
||||
initalarme=tmr.create()
|
||||
tmr.alarm(initalarme, 8*1000, tmr.ALARM_SINGLE, function()
|
||||
f= "boot.lua" if file.exists(f) then dofile(f) end
|
||||
end)
|
||||
end
|
||||
|
||||
_, reset_reason = node.bootreason()
|
||||
print("reset_reason:",reset_reason)
|
||||
if reset_reason == 0 then
|
||||
print("power on")
|
||||
second_chance()
|
||||
elseif reset_reason == 4 then
|
||||
print("node.restart")
|
||||
f= "boot.lua" if file.exists(f) then dofile(f) end
|
||||
elseif reset_reason == 6 then
|
||||
print("reset")
|
||||
second_chance()
|
||||
else
|
||||
print("autre raison")
|
||||
end
|
||||
|
||||
30
LED_RGB_WS2812/fill_effect/oldies/a_test_fill.lua
Normal file
30
LED_RGB_WS2812/fill_effect/oldies/a_test_fill.lua
Normal file
@@ -0,0 +1,30 @@
|
||||
-- Scripts juste pour tester des effets à la mano
|
||||
-- tout sur la couleur: https://www.w3schools.com/colors/default.asp
|
||||
-- roue des couleurs: https://iro.js.org/?ref=oldsite
|
||||
|
||||
print("\n a_tst_fill.lua zf181125.1632 \n")
|
||||
|
||||
znbled=300
|
||||
|
||||
function RGB_clear()
|
||||
ws2812.init()
|
||||
buffer = ws2812.newBuffer(znbled, 3)
|
||||
buffer:fill(0, 0, 0)
|
||||
ws2812.write(buffer)
|
||||
end
|
||||
|
||||
function RGB_fill(nbled, Red, Green, Blue)
|
||||
buffer = ws2812.newBuffer(nbled, 3)
|
||||
buffer:fill(Green, Red, Blue) -- Green, Red , Blue
|
||||
ws2812.write(buffer)
|
||||
end
|
||||
|
||||
RGB_clear()
|
||||
RGB_clear() ; RGB_fill(100, 255, 0, 0)
|
||||
RGB_clear() ; RGB_fill(100, 0, 255, 0)
|
||||
RGB_clear() ; RGB_fill(100, 0, 0, 255)
|
||||
RGB_clear() ; l=0.10 ; R=l*(255) ; G=l*(80*0.99) ; B=l*(0*0.99) ; RGB_fill(300, R, G, B)
|
||||
|
||||
|
||||
|
||||
|
||||
17
LED_RGB_WS2812/fill_effect/oldies/blink_led2.lua
Normal file
17
LED_RGB_WS2812/fill_effect/oldies/blink_led2.lua
Normal file
@@ -0,0 +1,17 @@
|
||||
-- programme pour faire clignoter une LED version simplifiée
|
||||
|
||||
print("\n blink_led2.lua zf181015.1138 \n")
|
||||
|
||||
zLED=0
|
||||
gpio.mode(zLED, gpio.OUTPUT)
|
||||
ztmr_LED = tmr.create()
|
||||
value = true
|
||||
|
||||
tmr.alarm(ztmr_LED, 100, tmr.ALARM_AUTO, function ()
|
||||
if value then
|
||||
gpio.write(zLED, gpio.HIGH)
|
||||
else
|
||||
gpio.write(zLED, gpio.LOW)
|
||||
end
|
||||
value = not value
|
||||
end)
|
||||
17
LED_RGB_WS2812/fill_effect/oldies/cat.lua
Normal file
17
LED_RGB_WS2812/fill_effect/oldies/cat.lua
Normal file
@@ -0,0 +1,17 @@
|
||||
-- fonction cat() pour afficher le contenu d'un fichier dans la flash
|
||||
print("\n cat.lua zf180826.1109 \n")
|
||||
|
||||
function cat(zfile)
|
||||
print("\n"..zfile.."\n-------------------------------")
|
||||
|
||||
zfilei = file.open(zfile, "r")
|
||||
i=1
|
||||
zline=file.readline()
|
||||
repeat
|
||||
print(i..": "..string.sub(zline,1,string.len(zline)-1))
|
||||
i=i+1 zline=file.readline()
|
||||
until zline== nil
|
||||
file.close(zfilei)
|
||||
|
||||
print("-------------------------------")
|
||||
end
|
||||
15
LED_RGB_WS2812/fill_effect/oldies/dir.lua
Normal file
15
LED_RGB_WS2812/fill_effect/oldies/dir.lua
Normal file
@@ -0,0 +1,15 @@
|
||||
-- fonction dir() pour afficher les fichiers dans la flash
|
||||
print("\n dir.lua zf180826.1019 \n")
|
||||
|
||||
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()
|
||||
19
LED_RGB_WS2812/fill_effect/oldies/initz - copie.lua
Normal file
19
LED_RGB_WS2812/fill_effect/oldies/initz - copie.lua
Normal file
@@ -0,0 +1,19 @@
|
||||
--Script de bootstrap, test au moment du boot qui a été la cause de boot.
|
||||
-- Si la cause est un power on ou une connexion depuis l'IDE, alors
|
||||
-- le script repair.lua pendant 30 secondes avant de continuer
|
||||
--Source: https://nodemcu.readthedocs.io/en/master/en/modules/node/#nodebootreason
|
||||
|
||||
print("\n init.lua zf181125.1340 \n")
|
||||
|
||||
_, reset_reason = node.bootreason()
|
||||
print("reset_reason:",reset_reason)
|
||||
if reset_reason == 6 or reset_reason == 6 then
|
||||
print("seconde chance...")
|
||||
f= "repair.lua" if file.exists(f) then dofile(f) end
|
||||
initalarme=tmr.create()
|
||||
tmr.alarm(initalarme, 8*1000, tmr.ALARM_SINGLE, function()
|
||||
f= "boot.lua" if file.exists(f) then dofile(f) end
|
||||
end)
|
||||
else
|
||||
f= "boot.lua" if file.exists(f) then dofile(f) end
|
||||
end
|
||||
16
LED_RGB_WS2812/fill_effect/repair.lua
Normal file
16
LED_RGB_WS2812/fill_effect/repair.lua
Normal file
@@ -0,0 +1,16 @@
|
||||
-- Scripts de seconde chance pour réparer une boucle dans le restart
|
||||
|
||||
print("\n repair.lua zf181119.2356 \n")
|
||||
|
||||
--f= "wifi_ap_start.lua" if file.exists(f) then dofile(f) end
|
||||
--f= "telnet_srv.lua" if file.exists(f) then dofile(f) end
|
||||
|
||||
f= "az_init_led.lua" if file.exists(f) then dofile(f) end
|
||||
|
||||
|
||||
--[[
|
||||
jobtimer1=tmr.create()
|
||||
tmr.alarm(jobtimer1, 5*1000, tmr.ALARM_AUTO, function()
|
||||
print("repair...")
|
||||
end)
|
||||
]]
|
||||
12
LED_RGB_WS2812/fill_effect/rm_files.lua
Normal file
12
LED_RGB_WS2812/fill_effect/rm_files.lua
Normal file
@@ -0,0 +1,12 @@
|
||||
-- pour effacer TOUS les fichiers qui se trouve dans la flash du NodeMCU
|
||||
|
||||
print("\n rm_files.lua zf180907.1511 \n")
|
||||
|
||||
|
||||
l=file.list() i=0
|
||||
for k,v in pairs(l) do
|
||||
i=i+v
|
||||
file.remove(k)
|
||||
end
|
||||
print("-------------------------------")
|
||||
print("\nC'est tout effaced :-) \n")
|
||||
Reference in New Issue
Block a user