From 9ca977a029b910039e8e06d5f8a2f809a7216a75 Mon Sep 17 00:00:00 2001 From: Christian Zufferey Date: Sun, 25 Nov 2018 16:42:49 +0100 Subject: [PATCH] =?UTF-8?q?-=20bien=20avanc=C3=A9=20sur=20mes=20tests=20de?= =?UTF-8?q?=20fill=20et=20de=20train.=20Le=20fill=20a=20manifestement=20de?= =?UTF-8?q?s=20probl=C3=A8mes=20d'alimentation=20vers=202A=20le=20train=20?= =?UTF-8?q?par=20contre=20marche=20bien=20vers=20300mA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tests conso LED RGB WS8213.gsheet | 1 + .../tests effects/wip/a_test_fill.lua | 71 +++---------------- .../tests effects/wip/a_test_train.lua | 29 ++++++++ .../{a_test_train.lua => wip/az_init_led.lua} | 29 ++++++-- LED_RGB_WS2812/tests effects/wip/boot.lua | 5 +- .../tests effects/wip/initz - copie.lua | 19 +++++ LED_RGB_WS2812/tests effects/wip/initz.lua | 28 +++++--- LED_RGB_WS2812/tests effects/wip/repair.lua | 9 ++- 8 files changed, 113 insertions(+), 78 deletions(-) create mode 100644 LED_RGB_WS2812/tests conso LED RGB WS8213.gsheet create mode 100644 LED_RGB_WS2812/tests effects/wip/a_test_train.lua rename LED_RGB_WS2812/tests effects/{a_test_train.lua => wip/az_init_led.lua} (78%) create mode 100644 LED_RGB_WS2812/tests effects/wip/initz - copie.lua diff --git a/LED_RGB_WS2812/tests conso LED RGB WS8213.gsheet b/LED_RGB_WS2812/tests conso LED RGB WS8213.gsheet new file mode 100644 index 0000000..91458bf --- /dev/null +++ b/LED_RGB_WS2812/tests conso LED RGB WS8213.gsheet @@ -0,0 +1 @@ +{"url": "https://docs.google.com/open?id=1wSbJJpykOFMVkic9zGyHNumQzK0q_ZCkiNWY4IJ7j28", "doc_id": "1wSbJJpykOFMVkic9zGyHNumQzK0q_ZCkiNWY4IJ7j28", "email": "christian.zufferey@gmail.com"} \ No newline at end of file diff --git a/LED_RGB_WS2812/tests effects/wip/a_test_fill.lua b/LED_RGB_WS2812/tests effects/wip/a_test_fill.lua index f9c1804..b015d37 100644 --- a/LED_RGB_WS2812/tests effects/wip/a_test_fill.lua +++ b/LED_RGB_WS2812/tests effects/wip/a_test_fill.lua @@ -2,7 +2,7 @@ -- 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 zf181125.1258 \n") +print("\n a_tst_fill.lua zf181125.1632 \n") znbled=300 @@ -13,67 +13,18 @@ function RGB_clear() ws2812.write(buffer) end -print("Initializing LED strip...") +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() -print("done.") - - -znbled_tst=10 -zlumino=1 --luminosité 0 <> 1 -zR=255*zlumino -zG=255*zlumino -zB=255*zlumino -buffer = ws2812.newBuffer(znbled_tst, 3) -buffer:fill(0, 0, 255) -- 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) +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) -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 effects/wip/a_test_train.lua b/LED_RGB_WS2812/tests effects/wip/a_test_train.lua new file mode 100644 index 0000000..d4f8116 --- /dev/null +++ b/LED_RGB_WS2812/tests effects/wip/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 zf181125.1640 \n") + +znbled=300 + +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, 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 effects/a_test_train.lua b/LED_RGB_WS2812/tests effects/wip/az_init_led.lua similarity index 78% rename from LED_RGB_WS2812/tests effects/a_test_train.lua rename to LED_RGB_WS2812/tests effects/wip/az_init_led.lua index 6d56445..e9df15c 100644 --- a/LED_RGB_WS2812/tests effects/a_test_train.lua +++ b/LED_RGB_WS2812/tests effects/wip/az_init_led.lua @@ -2,19 +2,36 @@ -- 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 zf181125.1258 \n") +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...") -ws2812.init() -buffer = ws2812.newBuffer(30, 3) -buffer:fill(0, 0, 0) -ws2812.write(buffer) +RGB_clear() print("done.") -print() --[[ +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") diff --git a/LED_RGB_WS2812/tests effects/wip/boot.lua b/LED_RGB_WS2812/tests effects/wip/boot.lua index 6aeec7b..a6fe229 100644 --- a/LED_RGB_WS2812/tests effects/wip/boot.lua +++ b/LED_RGB_WS2812/tests effects/wip/boot.lua @@ -1,6 +1,6 @@ -- Scripts à charger après le boot pour démarrer son appli -print("\n boot.lua zf181125.1234 \n") +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 @@ -9,7 +9,8 @@ print("\n boot.lua zf181125.1234 \n") --f= "web_ide2.lua" if file.exists(f) then dofile(f) end --f= "dsleep.lua" if file.exists(f) then dofile(f) end ---f= "test_train.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 diff --git a/LED_RGB_WS2812/tests effects/wip/initz - copie.lua b/LED_RGB_WS2812/tests effects/wip/initz - copie.lua new file mode 100644 index 0000000..80d817d --- /dev/null +++ b/LED_RGB_WS2812/tests effects/wip/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 effects/wip/initz.lua b/LED_RGB_WS2812/tests effects/wip/initz.lua index a9171d9..10066de 100644 --- a/LED_RGB_WS2812/tests effects/wip/initz.lua +++ b/LED_RGB_WS2812/tests effects/wip/initz.lua @@ -1,19 +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 30 secondes avant de continuer +-- 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 zf181120.0002 \n") +print("\n init.lua zf181125.1428 \n") -_, reset_reason = node.bootreason() -print("reset_reason:",reset_reason) -if reset_reason == 6 or reset_reason == 6 then +function second_chance() print("seconde chance...") f= "repair.lua" if file.exists(f) then dofile(f) end initalarme=tmr.create() - tmr.alarm(initalarme, 30*1000, tmr.ALARM_SINGLE, function() + 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 + +_, 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 effects/wip/repair.lua b/LED_RGB_WS2812/tests effects/wip/repair.lua index 400e952..626b5e5 100644 --- a/LED_RGB_WS2812/tests effects/wip/repair.lua +++ b/LED_RGB_WS2812/tests effects/wip/repair.lua @@ -2,10 +2,15 @@ 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= "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