diff --git a/ESP-xx/ESP-01F/Capture d’écran 2018-11-21 à 15.46.45.png b/ESP-xx/ESP-01F/Capture d’écran 2018-11-21 à 15.46.45.png new file mode 100644 index 0000000..71ea5e5 Binary files /dev/null and b/ESP-xx/ESP-01F/Capture d’écran 2018-11-21 à 15.46.45.png differ diff --git a/ESP-xx/ESP-01F/Capture d’écran 2018-11-21 à 15.47.03.png b/ESP-xx/ESP-01F/Capture d’écran 2018-11-21 à 15.47.03.png new file mode 100644 index 0000000..6e52079 Binary files /dev/null and b/ESP-xx/ESP-01F/Capture d’écran 2018-11-21 à 15.47.03.png differ diff --git a/ESP-xx/ESP-01F/Capture d’écran 2018-11-26 à 09.25.42.png b/ESP-xx/ESP-01F/Capture d’écran 2018-11-26 à 09.25.42.png new file mode 100644 index 0000000..e25d359 Binary files /dev/null and b/ESP-xx/ESP-01F/Capture d’écran 2018-11-26 à 09.25.42.png differ diff --git a/ESP-xx/ESP-01F/Capture d’écran 2018-11-26 à 09.25.53.png b/ESP-xx/ESP-01F/Capture d’écran 2018-11-26 à 09.25.53.png new file mode 100644 index 0000000..25cf497 Binary files /dev/null and b/ESP-xx/ESP-01F/Capture d’écran 2018-11-26 à 09.25.53.png differ diff --git a/ESP-xx/ESP-WIFI-Kearboard/Capture d’écran 2018-11-21 à 15.48.57.png b/ESP-xx/ESP-WIFI-Kearboard/Capture d’écran 2018-11-21 à 15.48.57.png new file mode 100644 index 0000000..04dddb3 Binary files /dev/null and b/ESP-xx/ESP-WIFI-Kearboard/Capture d’écran 2018-11-21 à 15.48.57.png differ diff --git a/IR/tst_58khz.lua b/IR/tst_58khz.lua new file mode 100644 index 0000000..f076576 --- /dev/null +++ b/IR/tst_58khz.lua @@ -0,0 +1,26 @@ +-- Script pour la porteuse à 58kHz +-- la gestion de l'émetteur IR à 38kHz (LED, infrared, infrarouge) +-- permet l'envoi d'un code (4bits seulement) avec le protocole zIR, protocole de mon invention ;-) +-- exprès pas standard afin de ne pas être parasité par les autres sources IR ! +-- ATTENTION, on utilise ici l'astuce du gpio.serout pour faire la pulse de 26uS (38kHz), +-- car on n'arrive pas avec le gpio.write à faire une pulse plus courte que 400uS + +print("\n tst_58khz.lua zf181128.1501 \n") + +pin_ir_send = 7 +gpio.mode(pin_ir_send,gpio.OUTPUT) +gpio.write(pin_ir_send,gpio.HIGH) + +-- envoi une série de pulses à 38kHz de durée zduration en uS +function pulse_ir(zduration) +-- print("pulse: "..zduration) + gpio.serout(pin_ir_send,gpio.LOW,{7,7},zduration) +end + +sendir_tmr1=tmr.create() +tmr.alarm(sendir_tmr1, 1000, tmr.ALARM_AUTO, function() + --print("go") + pulse_ir(50 *1000) +end) + + diff --git a/LED_RGB_WS2812/Alex/PoC.tar b/LED_RGB_WS2812/alex effect/PoC.tar similarity index 100% rename from LED_RGB_WS2812/Alex/PoC.tar rename to LED_RGB_WS2812/alex effect/PoC.tar diff --git a/LED_RGB_WS2812/Alex/PoC/cat.lua b/LED_RGB_WS2812/alex effect/PoC/cat.lua similarity index 100% rename from LED_RGB_WS2812/Alex/PoC/cat.lua rename to LED_RGB_WS2812/alex effect/PoC/cat.lua diff --git a/LED_RGB_WS2812/Alex/PoC/dir.lua b/LED_RGB_WS2812/alex effect/PoC/dir.lua similarity index 100% rename from LED_RGB_WS2812/Alex/PoC/dir.lua rename to LED_RGB_WS2812/alex effect/PoC/dir.lua diff --git a/LED_RGB_WS2812/Alex/PoC/dossier sans titre/initz.lua b/LED_RGB_WS2812/alex effect/PoC/dossier sans titre/initz.lua similarity index 100% rename from LED_RGB_WS2812/Alex/PoC/dossier sans titre/initz.lua rename to LED_RGB_WS2812/alex effect/PoC/dossier sans titre/initz.lua diff --git a/LED_RGB_WS2812/Alex/PoC/index.html b/LED_RGB_WS2812/alex effect/PoC/index.html similarity index 100% rename from LED_RGB_WS2812/Alex/PoC/index.html rename to LED_RGB_WS2812/alex effect/PoC/index.html diff --git a/LED_RGB_WS2812/Alex/PoC/initz.lua b/LED_RGB_WS2812/alex effect/PoC/initz.lua similarity index 100% rename from LED_RGB_WS2812/Alex/PoC/initz.lua rename to LED_RGB_WS2812/alex effect/PoC/initz.lua diff --git a/LED_RGB_WS2812/Alex/PoC/just_test_3x.lua b/LED_RGB_WS2812/alex effect/PoC/just_test_3x.lua similarity index 100% rename from LED_RGB_WS2812/Alex/PoC/just_test_3x.lua rename to LED_RGB_WS2812/alex effect/PoC/just_test_3x.lua diff --git a/LED_RGB_WS2812/Alex/PoC/just_test_6x.lua b/LED_RGB_WS2812/alex effect/PoC/just_test_6x.lua similarity index 100% rename from LED_RGB_WS2812/Alex/PoC/just_test_6x.lua rename to LED_RGB_WS2812/alex effect/PoC/just_test_6x.lua diff --git a/LED_RGB_WS2812/Alex/PoC/rm_files.lua b/LED_RGB_WS2812/alex effect/PoC/rm_files.lua similarity index 100% rename from LED_RGB_WS2812/Alex/PoC/rm_files.lua rename to LED_RGB_WS2812/alex effect/PoC/rm_files.lua diff --git a/LED_RGB_WS2812/Alex/PoC/start_boot.lua b/LED_RGB_WS2812/alex effect/PoC/start_boot.lua similarity index 100% rename from LED_RGB_WS2812/Alex/PoC/start_boot.lua rename to LED_RGB_WS2812/alex effect/PoC/start_boot.lua diff --git a/LED_RGB_WS2812/Alex/PoC/webleds.lua b/LED_RGB_WS2812/alex effect/PoC/webleds.lua similarity index 100% rename from LED_RGB_WS2812/Alex/PoC/webleds.lua rename to LED_RGB_WS2812/alex effect/PoC/webleds.lua diff --git a/LED_RGB_WS2812/Alex/PoC/wifiap.lua b/LED_RGB_WS2812/alex effect/PoC/wifiap.lua similarity index 100% rename from LED_RGB_WS2812/Alex/PoC/wifiap.lua rename to LED_RGB_WS2812/alex effect/PoC/wifiap.lua diff --git a/LED_RGB_WS2812/alex effect/README.md b/LED_RGB_WS2812/alex effect/README.md new file mode 100644 index 0000000..2f36728 --- /dev/null +++ b/LED_RGB_WS2812/alex effect/README.md @@ -0,0 +1,11 @@ +# Test effects + +Tests fait par Alexandre de LemanMake + + + + +zf181201.1153 + + + diff --git a/LED_RGB_WS2812/guirlandes noël/README.md b/LED_RGB_WS2812/guirlandes noël/README.md new file mode 100644 index 0000000..c0db26e --- /dev/null +++ b/LED_RGB_WS2812/guirlandes noël/README.md @@ -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 + + + diff --git a/LED_RGB_WS2812/guirlandes noël/a_test_fill.lua b/LED_RGB_WS2812/guirlandes noël/a_test_fill.lua new file mode 100644 index 0000000..b015d37 --- /dev/null +++ b/LED_RGB_WS2812/guirlandes noël/a_test_fill.lua @@ -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) + + + + diff --git a/LED_RGB_WS2812/guirlandes noël/a_test_train.lua b/LED_RGB_WS2812/guirlandes noël/a_test_train.lua new file mode 100644 index 0000000..826cd62 --- /dev/null +++ b/LED_RGB_WS2812/guirlandes noël/a_test_train.lua @@ -0,0 +1,29 @@ +-- 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_train.lua zf181201.1146 \n") + +znbled=36 + +function RGB_clear() + ws2812.init() + buffer = ws2812.newBuffer(znbled, 3) + buffer:fill(0, 0, 0) + ws2812.write(buffer) +end + +RGB_clear() + +j=1 +local i, buffer = 0, ws2812.newBuffer(znbled, 3); buffer:fill(0, 0, 0); tmr.create():alarm(20, 1, function() + i = i + j + buffer:fade(2) + buffer:set(i % buffer:size() + 1, 255, 255, 255) + ws2812.write(buffer) + if i>=buffer:size()-1 or i<=0 then + j=j*-1 + end +end) + + diff --git a/LED_RGB_WS2812/guirlandes noël/az_init_led.lua b/LED_RGB_WS2812/guirlandes noël/az_init_led.lua new file mode 100644 index 0000000..e9df15c --- /dev/null +++ b/LED_RGB_WS2812/guirlandes noël/az_init_led.lua @@ -0,0 +1,81 @@ +-- 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 az_init_led.lua zf181125.1333 \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.") + + + +--[[ +znbled_tst=60 +zlumino=1 --luminosité 0 <> 1 +zR=255*zlumino +zG=255*zlumino +zB=255*zlumino +buffer = ws2812.newBuffer(znbled_tst, 3) +buffer:fill(zG, zR, zB) -- Green, Red , Blue +ws2812.write(buffer) + + + + + +print("toto") + +ws2812.init() +strip_buffer = ws2812.newBuffer(300, 3) +ws2812_effects.init(strip_buffer) +-- initially all leds off +ws2812_effects.set_speed(255) +ws2812_effects.set_brightness(0) +ws2812_effects.set_color(0,0,0) +ws2812_effects.start() +print("done.") +print() + +ws2812.init() + +local i, buffer = 0, ws2812.newBuffer(300, 3) +buffer:fill(0, 0, 0, 0) + +exit + + +ws2812.init() +j=1 +local i, buffer = 0, ws2812.newBuffer(300, 3); buffer:fill(0, 0, 0, 0); tmr.create():alarm(20, 1, function() + i = i + j + buffer:fade(2) + buffer:set(i % buffer:size() + 1, 255, 255, 255) + ws2812.write(buffer) + if i>=buffer:size()-1 or i<=0 then + j=j*-1 + end +end) + + + + +ws2812.write(string.char(255, 0, 0, 0, 255, 0, 0, 0, 255)) -- RGB positionnement naturel + +ws2812.write(string.char(0, 255, 0, 0, 0, 255, 255, 0, 0, 255, 0, 255, 255, 255, 0, 0, 255, 255)) -- GBR and CMY en GBR WS2813! + +ws2812.write(string.char(0, 255, 0, 0, 0, 255/3, 255, 0, 0, 255, 0, 255, 255, 255, 0, 0, 255, 255)) -- vert compensé GBR and CMY en GBR WS2813! + +ws2812.write(string.char(128, 255, 128, 200, 200, 255, 255, 200, 200, 255, 255, 255, 40, 40, 40, 5, 5, 5)) -- White RGB & White 100/50/10% + +ws2812.write(string.char(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)) -- LED OFF +]] diff --git a/LED_RGB_WS2812/guirlandes noël/blink_led2.lua b/LED_RGB_WS2812/guirlandes noël/blink_led2.lua new file mode 100644 index 0000000..70fa251 --- /dev/null +++ b/LED_RGB_WS2812/guirlandes noël/blink_led2.lua @@ -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) diff --git a/LED_RGB_WS2812/guirlandes noël/boot.lua b/LED_RGB_WS2812/guirlandes noël/boot.lua new file mode 100644 index 0000000..a6fe229 --- /dev/null +++ b/LED_RGB_WS2812/guirlandes noël/boot.lua @@ -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) +]] + diff --git a/LED_RGB_WS2812/guirlandes noël/cat.lua b/LED_RGB_WS2812/guirlandes noël/cat.lua new file mode 100644 index 0000000..7c309b9 --- /dev/null +++ b/LED_RGB_WS2812/guirlandes noël/cat.lua @@ -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 diff --git a/LED_RGB_WS2812/guirlandes noël/dir.lua b/LED_RGB_WS2812/guirlandes noël/dir.lua new file mode 100644 index 0000000..8bf9414 --- /dev/null +++ b/LED_RGB_WS2812/guirlandes noël/dir.lua @@ -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() diff --git a/LED_RGB_WS2812/guirlandes noël/initz - copie.lua b/LED_RGB_WS2812/guirlandes noël/initz - copie.lua new file mode 100644 index 0000000..80d817d --- /dev/null +++ b/LED_RGB_WS2812/guirlandes noël/initz - copie.lua @@ -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 diff --git a/LED_RGB_WS2812/guirlandes noël/initz.lua b/LED_RGB_WS2812/guirlandes noël/initz.lua new file mode 100644 index 0000000..10066de --- /dev/null +++ b/LED_RGB_WS2812/guirlandes noël/initz.lua @@ -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 + diff --git a/LED_RGB_WS2812/guirlandes noël/repair.lua b/LED_RGB_WS2812/guirlandes noël/repair.lua new file mode 100644 index 0000000..626b5e5 --- /dev/null +++ b/LED_RGB_WS2812/guirlandes noël/repair.lua @@ -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) +]] \ No newline at end of file diff --git a/LED_RGB_WS2812/guirlandes noël/rm_files.lua b/LED_RGB_WS2812/guirlandes noël/rm_files.lua new file mode 100644 index 0000000..81241cb --- /dev/null +++ b/LED_RGB_WS2812/guirlandes noël/rm_files.lua @@ -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") diff --git a/LED_RGB_WS2812/tests couleurs/README.md b/LED_RGB_WS2812/tests couleurs/README.md new file mode 100644 index 0000000..928be4d --- /dev/null +++ b/LED_RGB_WS2812/tests couleurs/README.md @@ -0,0 +1,10 @@ +# Tests couleurs + +Test pour tester les différentes couleurs que l'on peut faire avec ces LED RGB + + + +zf181201.1153 + + + diff --git a/LED_RGB_WS2812/tests couleurs/a_test_fill.lua b/LED_RGB_WS2812/tests couleurs/a_test_fill.lua new file mode 100644 index 0000000..b015d37 --- /dev/null +++ b/LED_RGB_WS2812/tests couleurs/a_test_fill.lua @@ -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) + + + + diff --git a/LED_RGB_WS2812/tests couleurs/a_test_train.lua b/LED_RGB_WS2812/tests couleurs/a_test_train.lua new file mode 100644 index 0000000..826cd62 --- /dev/null +++ b/LED_RGB_WS2812/tests couleurs/a_test_train.lua @@ -0,0 +1,29 @@ +-- 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_train.lua zf181201.1146 \n") + +znbled=36 + +function RGB_clear() + ws2812.init() + buffer = ws2812.newBuffer(znbled, 3) + buffer:fill(0, 0, 0) + ws2812.write(buffer) +end + +RGB_clear() + +j=1 +local i, buffer = 0, ws2812.newBuffer(znbled, 3); buffer:fill(0, 0, 0); tmr.create():alarm(20, 1, function() + i = i + j + buffer:fade(2) + buffer:set(i % buffer:size() + 1, 255, 255, 255) + ws2812.write(buffer) + if i>=buffer:size()-1 or i<=0 then + j=j*-1 + end +end) + + diff --git a/LED_RGB_WS2812/tests couleurs/az_init_led.lua b/LED_RGB_WS2812/tests couleurs/az_init_led.lua new file mode 100644 index 0000000..e9df15c --- /dev/null +++ b/LED_RGB_WS2812/tests couleurs/az_init_led.lua @@ -0,0 +1,81 @@ +-- 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 az_init_led.lua zf181125.1333 \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.") + + + +--[[ +znbled_tst=60 +zlumino=1 --luminosité 0 <> 1 +zR=255*zlumino +zG=255*zlumino +zB=255*zlumino +buffer = ws2812.newBuffer(znbled_tst, 3) +buffer:fill(zG, zR, zB) -- Green, Red , Blue +ws2812.write(buffer) + + + + + +print("toto") + +ws2812.init() +strip_buffer = ws2812.newBuffer(300, 3) +ws2812_effects.init(strip_buffer) +-- initially all leds off +ws2812_effects.set_speed(255) +ws2812_effects.set_brightness(0) +ws2812_effects.set_color(0,0,0) +ws2812_effects.start() +print("done.") +print() + +ws2812.init() + +local i, buffer = 0, ws2812.newBuffer(300, 3) +buffer:fill(0, 0, 0, 0) + +exit + + +ws2812.init() +j=1 +local i, buffer = 0, ws2812.newBuffer(300, 3); buffer:fill(0, 0, 0, 0); tmr.create():alarm(20, 1, function() + i = i + j + buffer:fade(2) + buffer:set(i % buffer:size() + 1, 255, 255, 255) + ws2812.write(buffer) + if i>=buffer:size()-1 or i<=0 then + j=j*-1 + end +end) + + + + +ws2812.write(string.char(255, 0, 0, 0, 255, 0, 0, 0, 255)) -- RGB positionnement naturel + +ws2812.write(string.char(0, 255, 0, 0, 0, 255, 255, 0, 0, 255, 0, 255, 255, 255, 0, 0, 255, 255)) -- GBR and CMY en GBR WS2813! + +ws2812.write(string.char(0, 255, 0, 0, 0, 255/3, 255, 0, 0, 255, 0, 255, 255, 255, 0, 0, 255, 255)) -- vert compensé GBR and CMY en GBR WS2813! + +ws2812.write(string.char(128, 255, 128, 200, 200, 255, 255, 200, 200, 255, 255, 255, 40, 40, 40, 5, 5, 5)) -- White RGB & White 100/50/10% + +ws2812.write(string.char(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)) -- LED OFF +]] diff --git a/LED_RGB_WS2812/tests couleurs/blink_led2.lua b/LED_RGB_WS2812/tests couleurs/blink_led2.lua new file mode 100644 index 0000000..70fa251 --- /dev/null +++ b/LED_RGB_WS2812/tests couleurs/blink_led2.lua @@ -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) diff --git a/LED_RGB_WS2812/tests couleurs/boot.lua b/LED_RGB_WS2812/tests couleurs/boot.lua new file mode 100644 index 0000000..a6fe229 --- /dev/null +++ b/LED_RGB_WS2812/tests couleurs/boot.lua @@ -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) +]] + diff --git a/LED_RGB_WS2812/tests couleurs/cat.lua b/LED_RGB_WS2812/tests couleurs/cat.lua new file mode 100644 index 0000000..7c309b9 --- /dev/null +++ b/LED_RGB_WS2812/tests couleurs/cat.lua @@ -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 diff --git a/LED_RGB_WS2812/tests couleurs/dir.lua b/LED_RGB_WS2812/tests couleurs/dir.lua new file mode 100644 index 0000000..8bf9414 --- /dev/null +++ b/LED_RGB_WS2812/tests couleurs/dir.lua @@ -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() diff --git a/LED_RGB_WS2812/tests couleurs/initz - copie.lua b/LED_RGB_WS2812/tests couleurs/initz - copie.lua new file mode 100644 index 0000000..80d817d --- /dev/null +++ b/LED_RGB_WS2812/tests couleurs/initz - copie.lua @@ -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 diff --git a/LED_RGB_WS2812/tests couleurs/initz.lua b/LED_RGB_WS2812/tests couleurs/initz.lua new file mode 100644 index 0000000..10066de --- /dev/null +++ b/LED_RGB_WS2812/tests couleurs/initz.lua @@ -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 + diff --git a/LED_RGB_WS2812/tests couleurs/just_test_3x.lua b/LED_RGB_WS2812/tests couleurs/just_test_3x.lua new file mode 100644 index 0000000..8059019 --- /dev/null +++ b/LED_RGB_WS2812/tests couleurs/just_test_3x.lua @@ -0,0 +1,23 @@ +-- Scripts juste pour tester 3x LED RGB +-- tout sur la couleur: https://www.w3schools.com/colors/default.asp +-- roue des couleurs: https://iro.js.org/?ref=oldsite + +print("\n just_test_3x.lua zf181106.0940 \n") + + +print("Initializing LED strip...") +ws2812.init() +ws2812_effects.stop() +strip_buffer = ws2812.newBuffer(3, 3) +ws2812.write(string.char(255, 0, 0, 0, 255, 0, 0, 0, 255)) -- RGB natural + +ws2812.write(string.char(0, 255, 0, 0, 0, 255, 255, 0, 0)) -- GBR WS2813 +ws2812.write(string.char(0, 255, 0, 255, 0, 0, 0, 0, 255)) -- GRB WS2812 + +ws2812.write(string.char(255, 0, 255, 255, 255, 0, 0, 255, 255)) -- CMY en GBR WS2813! +ws2812.write(string.char(255, 0, 255, 0, 255, 255, 255, 255, 0)) -- CMY en GRB WS2812! + +ws2812.write(string.char(128, 255, 64, 255, 200, 200, 200, 200, 255)) +ws2812.write(string.char(255, 255, 255, 40, 40, 40, 5, 5, 5)) +ws2812.write(string.char(0, 0, 0, 0, 0, 0, 0, 0, 0)) + diff --git a/LED_RGB_WS2812/tests couleurs/just_test_6x.lua b/LED_RGB_WS2812/tests couleurs/just_test_6x.lua new file mode 100644 index 0000000..9c8abe0 --- /dev/null +++ b/LED_RGB_WS2812/tests couleurs/just_test_6x.lua @@ -0,0 +1,21 @@ +-- Scripts juste pour tester 6x LED RGB +-- tout sur la couleur: https://www.w3schools.com/colors/default.asp +-- roue des couleurs: https://iro.js.org/?ref=oldsite + +print("\n just_test_3x.lua zf181106.1458 \n") + + +print("Initializing LED strip...") +ws2812.init() +ws2812_effects.stop() +strip_buffer = ws2812.newBuffer(6, 3) +ws2812.write(string.char(255, 0, 0, 0, 255, 0, 0, 0, 255)) -- RGB positionnement naturel + +ws2812.write(string.char(0, 255, 0, 0, 0, 255, 255, 0, 0, 255, 0, 255, 255, 255, 0, 0, 255, 255)) -- GBR and CMY en GBR WS2813! + +ws2812.write(string.char(0, 255, 0, 0, 0, 255/3, 255, 0, 0, 255, 0, 255, 255, 255, 0, 0, 255, 255)) -- vert compensé GBR and CMY en GBR WS2813! + +ws2812.write(string.char(128, 255, 128, 200, 200, 255, 255, 200, 200, 255, 255, 255, 40, 40, 40, 5, 5, 5)) -- White RGB & White 100/50/10% + +ws2812.write(string.char(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)) -- LED OFF + diff --git a/LED_RGB_WS2812/tests couleurs/repair.lua b/LED_RGB_WS2812/tests couleurs/repair.lua new file mode 100644 index 0000000..626b5e5 --- /dev/null +++ b/LED_RGB_WS2812/tests couleurs/repair.lua @@ -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) +]] \ No newline at end of file diff --git a/LED_RGB_WS2812/tests couleurs/rm_files.lua b/LED_RGB_WS2812/tests couleurs/rm_files.lua new file mode 100644 index 0000000..81241cb --- /dev/null +++ b/LED_RGB_WS2812/tests couleurs/rm_files.lua @@ -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") diff --git a/LED_RGB_WS2812/tests effects/README.md b/LED_RGB_WS2812/tests effects/README.md new file mode 100644 index 0000000..64de8e3 --- /dev/null +++ b/LED_RGB_WS2812/tests effects/README.md @@ -0,0 +1,8 @@ +# Différents tests en cours + + + +zf181201.1153 + + + diff --git a/LED_RGB_WS2812/tests effects/wip/a_test_train.lua b/LED_RGB_WS2812/tests effects/wip/a_test_train.lua index d4f8116..baff554 100644 --- a/LED_RGB_WS2812/tests effects/wip/a_test_train.lua +++ b/LED_RGB_WS2812/tests effects/wip/a_test_train.lua @@ -4,7 +4,7 @@ print("\n a_tst_train.lua zf181125.1640 \n") -znbled=300 +znbled=36 function RGB_clear() ws2812.init() diff --git a/LED_RGB_WS2812/train effect/README.md b/LED_RGB_WS2812/train effect/README.md new file mode 100644 index 0000000..09befb2 --- /dev/null +++ b/LED_RGB_WS2812/train effect/README.md @@ -0,0 +1,19 @@ +# Train effects + +Différents tests de train effect + +## Mon premier que j'ai trouvé dans la docu NodeMCU sous la lib WS2812 +effect1 + +## Celui à Ponsfrilus +effect2 + +## Mon deuxième basé sur celui à Ponsfrilus +effect3 + + + +zf181201.1153 + + + diff --git a/LED_RGB_WS2812/train effect/effect1/a_test_fill.lua b/LED_RGB_WS2812/train effect/effect1/a_test_fill.lua new file mode 100644 index 0000000..b015d37 --- /dev/null +++ b/LED_RGB_WS2812/train effect/effect1/a_test_fill.lua @@ -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) + + + + diff --git a/LED_RGB_WS2812/train effect/effect1/a_test_train.lua b/LED_RGB_WS2812/train effect/effect1/a_test_train.lua new file mode 100644 index 0000000..826cd62 --- /dev/null +++ b/LED_RGB_WS2812/train effect/effect1/a_test_train.lua @@ -0,0 +1,29 @@ +-- 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_train.lua zf181201.1146 \n") + +znbled=36 + +function RGB_clear() + ws2812.init() + buffer = ws2812.newBuffer(znbled, 3) + buffer:fill(0, 0, 0) + ws2812.write(buffer) +end + +RGB_clear() + +j=1 +local i, buffer = 0, ws2812.newBuffer(znbled, 3); buffer:fill(0, 0, 0); tmr.create():alarm(20, 1, function() + i = i + j + buffer:fade(2) + buffer:set(i % buffer:size() + 1, 255, 255, 255) + ws2812.write(buffer) + if i>=buffer:size()-1 or i<=0 then + j=j*-1 + end +end) + + diff --git a/LED_RGB_WS2812/train effect/effect1/az_init_led.lua b/LED_RGB_WS2812/train effect/effect1/az_init_led.lua new file mode 100644 index 0000000..e9df15c --- /dev/null +++ b/LED_RGB_WS2812/train effect/effect1/az_init_led.lua @@ -0,0 +1,81 @@ +-- 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 az_init_led.lua zf181125.1333 \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.") + + + +--[[ +znbled_tst=60 +zlumino=1 --luminosité 0 <> 1 +zR=255*zlumino +zG=255*zlumino +zB=255*zlumino +buffer = ws2812.newBuffer(znbled_tst, 3) +buffer:fill(zG, zR, zB) -- Green, Red , Blue +ws2812.write(buffer) + + + + + +print("toto") + +ws2812.init() +strip_buffer = ws2812.newBuffer(300, 3) +ws2812_effects.init(strip_buffer) +-- initially all leds off +ws2812_effects.set_speed(255) +ws2812_effects.set_brightness(0) +ws2812_effects.set_color(0,0,0) +ws2812_effects.start() +print("done.") +print() + +ws2812.init() + +local i, buffer = 0, ws2812.newBuffer(300, 3) +buffer:fill(0, 0, 0, 0) + +exit + + +ws2812.init() +j=1 +local i, buffer = 0, ws2812.newBuffer(300, 3); buffer:fill(0, 0, 0, 0); tmr.create():alarm(20, 1, function() + i = i + j + buffer:fade(2) + buffer:set(i % buffer:size() + 1, 255, 255, 255) + ws2812.write(buffer) + if i>=buffer:size()-1 or i<=0 then + j=j*-1 + end +end) + + + + +ws2812.write(string.char(255, 0, 0, 0, 255, 0, 0, 0, 255)) -- RGB positionnement naturel + +ws2812.write(string.char(0, 255, 0, 0, 0, 255, 255, 0, 0, 255, 0, 255, 255, 255, 0, 0, 255, 255)) -- GBR and CMY en GBR WS2813! + +ws2812.write(string.char(0, 255, 0, 0, 0, 255/3, 255, 0, 0, 255, 0, 255, 255, 255, 0, 0, 255, 255)) -- vert compensé GBR and CMY en GBR WS2813! + +ws2812.write(string.char(128, 255, 128, 200, 200, 255, 255, 200, 200, 255, 255, 255, 40, 40, 40, 5, 5, 5)) -- White RGB & White 100/50/10% + +ws2812.write(string.char(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)) -- LED OFF +]] diff --git a/LED_RGB_WS2812/train effect/effect1/blink_led2.lua b/LED_RGB_WS2812/train effect/effect1/blink_led2.lua new file mode 100644 index 0000000..70fa251 --- /dev/null +++ b/LED_RGB_WS2812/train effect/effect1/blink_led2.lua @@ -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) diff --git a/LED_RGB_WS2812/train effect/effect1/boot.lua b/LED_RGB_WS2812/train effect/effect1/boot.lua new file mode 100644 index 0000000..a6fe229 --- /dev/null +++ b/LED_RGB_WS2812/train effect/effect1/boot.lua @@ -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) +]] + diff --git a/LED_RGB_WS2812/train effect/effect1/cat.lua b/LED_RGB_WS2812/train effect/effect1/cat.lua new file mode 100644 index 0000000..7c309b9 --- /dev/null +++ b/LED_RGB_WS2812/train effect/effect1/cat.lua @@ -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 diff --git a/LED_RGB_WS2812/train effect/effect1/dir.lua b/LED_RGB_WS2812/train effect/effect1/dir.lua new file mode 100644 index 0000000..8bf9414 --- /dev/null +++ b/LED_RGB_WS2812/train effect/effect1/dir.lua @@ -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() diff --git a/LED_RGB_WS2812/train effect/effect1/initz - copie.lua b/LED_RGB_WS2812/train effect/effect1/initz - copie.lua new file mode 100644 index 0000000..80d817d --- /dev/null +++ b/LED_RGB_WS2812/train effect/effect1/initz - copie.lua @@ -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 diff --git a/LED_RGB_WS2812/train effect/effect1/initz.lua b/LED_RGB_WS2812/train effect/effect1/initz.lua new file mode 100644 index 0000000..10066de --- /dev/null +++ b/LED_RGB_WS2812/train effect/effect1/initz.lua @@ -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 + diff --git a/LED_RGB_WS2812/train effect/effect1/repair.lua b/LED_RGB_WS2812/train effect/effect1/repair.lua new file mode 100644 index 0000000..626b5e5 --- /dev/null +++ b/LED_RGB_WS2812/train effect/effect1/repair.lua @@ -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) +]] \ No newline at end of file diff --git a/LED_RGB_WS2812/train effect/effect1/rm_files.lua b/LED_RGB_WS2812/train effect/effect1/rm_files.lua new file mode 100644 index 0000000..81241cb --- /dev/null +++ b/LED_RGB_WS2812/train effect/effect1/rm_files.lua @@ -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") diff --git a/LED_RGB_WS2812/train effect/effect2/nicolas_train.lua b/LED_RGB_WS2812/train effect/effect2/nicolas_train.lua new file mode 100644 index 0000000..0c5f325 --- /dev/null +++ b/LED_RGB_WS2812/train effect/effect2/nicolas_train.lua @@ -0,0 +1,132 @@ +--[[ + + This file is a test for a led strip WS2813 + Intelligent control LED integrated light source + + This use the module ws2812: + https://nodemcu.readthedocs.io/en/master/en/modules/ws2812/ + +]] + +-- define the led strip total length +stripLength=24 + + +-- Test 1 +-- This turn off the led strip for 1 second +ws2812.init() +myLedStrip = ws2812.newBuffer(stripLength, 3) -- 6 leds with 3 colors +myLedStrip:fill(0,0,0) +ws2812.write(myLedStrip) +tmr.delay(1 * 1000000) -- wait for 1 s + + +-- Test 2 +-- This is the minimal test: it will initialize and turn on the first +-- 3 leds to: +-- 1. 255, 0, 0 +-- 2. 0, 255, 0 +-- 3. 0, 0, 255 +-- Note: The leds strip are not necessarily in RGB, this test aim to +-- find out what the type of led you have. In my case, it's BRG. +ws2812.init() +ws2812.write(string.char(255, 0, 0, --[[ ]] 0, 255, 0, --[[ ]] 0, 0, 255)) +tmr.delay(1 * 1000000) -- wait for 1 s +-- Now you can see that the luminosity is very different according to the main color. +-- In fact, you need to correct the luminosity for the humain eye, something as +ws2812.write(string.char(180, 0, 0, --[[ ]] 0, 255, 0, --[[ ]] 0, 0, 60)) +tmr.delay(3 * 1000000) -- wait for 3 s + + +-- Test 3 +-- Traffic lights +ws2812.init() +ws2812.write(string.char(0, 255, 0, --[[]] 0, 0, 0, --[[]] 0, 0, 0)) -- RED +tmr.delay(2 * 1000000) -- wait for 2 s +ws2812.write(string.char(0, 0, 0, --[[]] 0, 255, 44, --[[]] 0, 0, 0)) -- ORANGE B0 R255 G88 +tmr.delay(1 * 1000000) -- wait for 1 s +ws2812.write(string.char(0, 0, 0, --[[]] 0, 0, 0, --[[]] 0, 0, 255)) -- GREEN +tmr.delay(3 * 1000000) -- wait for 3 s + + +-- Test 4 +-- This show the luminosity gradient +-- The first arg: led position, then: color +myLedStrip = ws2812.newBuffer(stripLength, 3) -- 6 leds with 3 colors +myLedStrip:fill(0,0,0) +ws2812.write(myLedStrip) +-- RED +myLedStrip:set( 1, 0, 10, 0) +myLedStrip:set( 2, 0, 20, 0) +myLedStrip:set( 3, 0, 40, 0) +myLedStrip:set( 4, 0, 80, 0) +myLedStrip:set( 5, 0, 160, 0) +myLedStrip:set( 6, 0, 255, 0) +-- GREEN +myLedStrip:set( 7, 0, 0, 10) +myLedStrip:set( 8, 0, 0, 20) +myLedStrip:set( 9, 0, 0, 40) +myLedStrip:set(10, 0, 0, 80) +myLedStrip:set(11, 0, 0, 160) +myLedStrip:set(12, 0, 0, 255) +-- BLUE +myLedStrip:set(13, 10, 0, 0) +myLedStrip:set(14, 20, 0, 0) +myLedStrip:set(15, 40, 0, 0) +myLedStrip:set(16, 80, 0, 0) +myLedStrip:set(17, 160, 0, 0) +myLedStrip:set(18, 255, 0, 0) + +ws2812.write(myLedStrip) +tmr.delay(3 * 1000000) -- wait for 3 s + + +-- Test 5 +-- k2000 fx (Brace yourself, David Hasselhoff!) +ws2812.init() +fadeLevel=3 +timerSpeed=20 -- timer speed in milliseconds +mode = ws2812.SHIFT_CIRCULAR -- ws2812.SHIFT_LOGICAL / ws2812.SHIFT_CIRCULAR + +-- Buffer Train 1 +myLedStrip1 = ws2812.newBuffer(stripLength, 3) -- 6 leds with 3 colors +myLedStrip1:fill(0,0,0) +myLedStrip1:set(1, 100,100,100) +myLedStrip1:fade(fadeLevel) +myLedStrip1:set(2, 100,100,100) +myLedStrip1:fade(fadeLevel) +myLedStrip1:set(3, 100,100,100) +myLedStrip1:fade(fadeLevel) +myLedStrip1:set(4, 100,100,100) +-- debug: ws2812.write(myLedStrip1) + +-- Buffer Train 2 +myLedStrip2 = ws2812.newBuffer(stripLength, 3) -- 6 leds with 3 colors +myLedStrip2:fill(0,0,0) +myLedStrip2:set(stripLength, 0,0,120) +myLedStrip2:fade(fadeLevel) +myLedStrip2:set(stripLength-1, 0,0,120) +myLedStrip2:fade(fadeLevel) +myLedStrip2:set(stripLength-2, 0,0,120) +myLedStrip2:fade(fadeLevel) +myLedStrip2:set(stripLength-3, 0,0,120) +myLedStrip2:fade(fadeLevel) +-- debug: ws2812.write(myLedStrip2) + +-- Buffer Train Total +myLedStrip = ws2812.newBuffer(stripLength, 3) -- 6 leds with 3 colors +myLedStrip:mix(255, myLedStrip1, 255, myLedStrip2) +-- debug: ws2812.write(myLedStrip) + +tmr.create():alarm(timerSpeed, 1, function() + + myLedStrip1:shift(1, mode) -- direction → + myLedStrip2:shift(-1, mode) -- direction ← + + myLedStrip:mix(255, myLedStrip1, 255, myLedStrip2) -- mix both train + ws2812.write(myLedStrip) + +end) + + +-- end of file \ No newline at end of file diff --git a/LED_RGB_WS2812/train effect/effect3/a_test_fill.lua b/LED_RGB_WS2812/train effect/effect3/a_test_fill.lua new file mode 100644 index 0000000..b015d37 --- /dev/null +++ b/LED_RGB_WS2812/train effect/effect3/a_test_fill.lua @@ -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) + + + + diff --git a/LED_RGB_WS2812/train effect/effect3/a_test_train.lua b/LED_RGB_WS2812/train effect/effect3/a_test_train.lua new file mode 100644 index 0000000..826cd62 --- /dev/null +++ b/LED_RGB_WS2812/train effect/effect3/a_test_train.lua @@ -0,0 +1,29 @@ +-- 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_train.lua zf181201.1146 \n") + +znbled=36 + +function RGB_clear() + ws2812.init() + buffer = ws2812.newBuffer(znbled, 3) + buffer:fill(0, 0, 0) + ws2812.write(buffer) +end + +RGB_clear() + +j=1 +local i, buffer = 0, ws2812.newBuffer(znbled, 3); buffer:fill(0, 0, 0); tmr.create():alarm(20, 1, function() + i = i + j + buffer:fade(2) + buffer:set(i % buffer:size() + 1, 255, 255, 255) + ws2812.write(buffer) + if i>=buffer:size()-1 or i<=0 then + j=j*-1 + end +end) + + diff --git a/LED_RGB_WS2812/train effect/effect3/az_init_led.lua b/LED_RGB_WS2812/train effect/effect3/az_init_led.lua new file mode 100644 index 0000000..e9df15c --- /dev/null +++ b/LED_RGB_WS2812/train effect/effect3/az_init_led.lua @@ -0,0 +1,81 @@ +-- 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 az_init_led.lua zf181125.1333 \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.") + + + +--[[ +znbled_tst=60 +zlumino=1 --luminosité 0 <> 1 +zR=255*zlumino +zG=255*zlumino +zB=255*zlumino +buffer = ws2812.newBuffer(znbled_tst, 3) +buffer:fill(zG, zR, zB) -- Green, Red , Blue +ws2812.write(buffer) + + + + + +print("toto") + +ws2812.init() +strip_buffer = ws2812.newBuffer(300, 3) +ws2812_effects.init(strip_buffer) +-- initially all leds off +ws2812_effects.set_speed(255) +ws2812_effects.set_brightness(0) +ws2812_effects.set_color(0,0,0) +ws2812_effects.start() +print("done.") +print() + +ws2812.init() + +local i, buffer = 0, ws2812.newBuffer(300, 3) +buffer:fill(0, 0, 0, 0) + +exit + + +ws2812.init() +j=1 +local i, buffer = 0, ws2812.newBuffer(300, 3); buffer:fill(0, 0, 0, 0); tmr.create():alarm(20, 1, function() + i = i + j + buffer:fade(2) + buffer:set(i % buffer:size() + 1, 255, 255, 255) + ws2812.write(buffer) + if i>=buffer:size()-1 or i<=0 then + j=j*-1 + end +end) + + + + +ws2812.write(string.char(255, 0, 0, 0, 255, 0, 0, 0, 255)) -- RGB positionnement naturel + +ws2812.write(string.char(0, 255, 0, 0, 0, 255, 255, 0, 0, 255, 0, 255, 255, 255, 0, 0, 255, 255)) -- GBR and CMY en GBR WS2813! + +ws2812.write(string.char(0, 255, 0, 0, 0, 255/3, 255, 0, 0, 255, 0, 255, 255, 255, 0, 0, 255, 255)) -- vert compensé GBR and CMY en GBR WS2813! + +ws2812.write(string.char(128, 255, 128, 200, 200, 255, 255, 200, 200, 255, 255, 255, 40, 40, 40, 5, 5, 5)) -- White RGB & White 100/50/10% + +ws2812.write(string.char(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)) -- LED OFF +]] diff --git a/LED_RGB_WS2812/train effect/effect3/blink_led2.lua b/LED_RGB_WS2812/train effect/effect3/blink_led2.lua new file mode 100644 index 0000000..70fa251 --- /dev/null +++ b/LED_RGB_WS2812/train effect/effect3/blink_led2.lua @@ -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) diff --git a/LED_RGB_WS2812/train effect/effect3/boot.lua b/LED_RGB_WS2812/train effect/effect3/boot.lua new file mode 100644 index 0000000..a6fe229 --- /dev/null +++ b/LED_RGB_WS2812/train effect/effect3/boot.lua @@ -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) +]] + diff --git a/LED_RGB_WS2812/train effect/effect3/cat.lua b/LED_RGB_WS2812/train effect/effect3/cat.lua new file mode 100644 index 0000000..7c309b9 --- /dev/null +++ b/LED_RGB_WS2812/train effect/effect3/cat.lua @@ -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 diff --git a/LED_RGB_WS2812/train effect/effect3/dir.lua b/LED_RGB_WS2812/train effect/effect3/dir.lua new file mode 100644 index 0000000..8bf9414 --- /dev/null +++ b/LED_RGB_WS2812/train effect/effect3/dir.lua @@ -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() diff --git a/LED_RGB_WS2812/train effect/effect3/initz - copie.lua b/LED_RGB_WS2812/train effect/effect3/initz - copie.lua new file mode 100644 index 0000000..80d817d --- /dev/null +++ b/LED_RGB_WS2812/train effect/effect3/initz - copie.lua @@ -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 diff --git a/LED_RGB_WS2812/train effect/effect3/initz.lua b/LED_RGB_WS2812/train effect/effect3/initz.lua new file mode 100644 index 0000000..10066de --- /dev/null +++ b/LED_RGB_WS2812/train effect/effect3/initz.lua @@ -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 + diff --git a/LED_RGB_WS2812/train effect/effect3/repair.lua b/LED_RGB_WS2812/train effect/effect3/repair.lua new file mode 100644 index 0000000..626b5e5 --- /dev/null +++ b/LED_RGB_WS2812/train effect/effect3/repair.lua @@ -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) +]] \ No newline at end of file diff --git a/LED_RGB_WS2812/train effect/effect3/rm_files.lua b/LED_RGB_WS2812/train effect/effect3/rm_files.lua new file mode 100644 index 0000000..81241cb --- /dev/null +++ b/LED_RGB_WS2812/train effect/effect3/rm_files.lua @@ -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")