From: Nathaniel Wesley Filardo Date: Fri, 31 Jul 2020 21:13:48 +0000 (+0100) Subject: Turn off on-module LED betwen frames X-Git-Url: https://hydra-www.ietfng.org/gitweb/?a=commitdiff_plain;h=c952fb99e0e7e3b962f52f205e5295115c06d117;p=acmetensortoys-esp-lua_lamp Turn off on-module LED betwen frames 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. --- diff --git a/init-early.lua b/init-early.lua index 56b8ebd..ccac86f 100644 --- a/init-early.lua +++ b/init-early.lua @@ -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 diff --git a/init2.lua b/init2.lua index 0dc4a44..edb0010 100644 --- 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()