]> hydra-www.ietfng.org Git - acmetensortoys-esp-lua_lamp/commitdiff
Turn off on-module LED betwen frames
authorNathaniel Wesley Filardo <nwfilardo@gmail.com>
Fri, 31 Jul 2020 21:13:48 +0000 (22:13 +0100)
committerNathaniel Wesley Filardo <nwfilardo@gmail.com>
Fri, 31 Jul 2020 21:13:48 +0000 (22:13 +0100)
This isn't great, since the light blinks once per frame, but it's better
than nothing.  When the display is static (including off), the LED stays
off, at least.

init-early.lua
init2.lua

index 56b8ebda7f1644a601eb132d75ad0e61e306c417..ccac86f0ed22f901ddc7e6cee0cb994168b466c5 100644 (file)
@@ -9,6 +9,8 @@ ws2812.write(fb)
 tmr.delay(350)
 gpio.write(3,gpio.LOW)
 
+gpio.mode(4, gpio.INPUT) -- de-initialize ws2812 to turn off on-module blue LED
+
 -- Do we have a new LFS blob?  If so, install it.
 file.remove("luac.out.stage")
 if file.exists("luac.out") then
index 0dc4a44d6bb88db5f82ba0b3c3bdedf2117d5dfb..edb0010dabe19d2dcc72443536a2c87b0a6ccfc0 100644 (file)
--- a/init2.lua
+++ b/init2.lua
@@ -46,6 +46,7 @@ baselinefb:fill(1,1,1)
 local doublefb = ws2812.newBuffer(32,3)
 function dodraw()
   if not isblackout then
+    local b = ledfb
     if dimfactor > 0 then
       -- dimming, so mix the baseline "all channels on minimum" as 127/256ths
       -- to control rounding (see below).  The image in "ledfb" will be mixed
@@ -56,26 +57,28 @@ function dodraw()
       -- bits after summation, so adding 127 more means that we now round up
       -- (i.e., by ceil), so an active channel will remain active.
       doublefb:mix(127,baselinefb,256/(dimfactor+1),ledfb)
-      gpio.write(3,gpio.HIGH)
-      ws2812.write(doublefb)
-    else
-      gpio.write(3,gpio.HIGH)
-      ws2812.write(ledfb)
+      b = doublefb
     end
+    gpio.write(3,gpio.HIGH)
+    ws2812.init(ws2812.MODE_SINGLE)
+    ws2812.write(b)
     -- Wait for the UART to drain and for the LED strip to latch (nominally
     -- 350 usec).  This isn't really OK, but we're probably not pushing the
     -- 15 mSec or so that the SDK says we have?
     tmr.delay(350)
     gpio.write(3,gpio.LOW)
+    gpio.mode(4,gpio.INPUT) -- LED off
   end
 end
 -- Not ideal, but at least this keeps all the gpio wibbling to this one file
 function doblackout()
   isblackout = true
   gpio.write(3,gpio.HIGH)
+  ws2812.init(ws2812.MODE_SINGLE)
     ws2812.write(string.char(0):rep(32*3))
     tmr.delay(350)
   gpio.write(3,gpio.LOW)
+  gpio.mode(4,gpio.INPUT) -- LED off
 end
 
 function removeremote()