From 6f0f580c0c82fb78f728d04a2a9129eb2a6ebc36 Mon Sep 17 00:00:00 2001 From: Rachael Date: Sat, 8 Jul 2017 15:44:51 -0700 Subject: [PATCH] removes a useless loop that made the dimming code much slower. This also moves the dimming code form the left most button on the front to the back most button on the left side so as to limit accidental triggering. --- init2.lua | 7 ++----- lamp-touch.lua | 8 ++++---- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/init2.lua b/init2.lua index 2b8633a..187871e 100644 --- a/init2.lua +++ b/init2.lua @@ -51,14 +51,11 @@ local doublefb = ws2812.newBuffer(32,3) function dodraw() if not isblackout then if dimfactor > 0 then - for i=1, ledfb:size() do - local g,r,b = ledfb:get(i) - -- dimming, so mix the baseline "all channels on minimum" as 128/256ths + -- dimming, so mix the baseline "all channels on minimum" as 255/256ths -- to act as a rounding factor. The image in "ledfb" will be mixed in -- as 256/(dimfactor+1) 256ths - doublefb:mix(256,baselinefb,256/(dimfactor+1),ledfb) + doublefb:mix(255,baselinefb,256/(dimfactor+1),ledfb) ws2812.write(doublefb) - end else ws2812.write(ledfb) end diff --git a/lamp-touch.lua b/lamp-touch.lua index eca101a..684c968 100644 --- a/lamp-touch.lua +++ b/lamp-touch.lua @@ -125,8 +125,8 @@ local function ontouch() touch_db_blackout = tq:queue(300,onblackdebounce) end - -- XXX front left: dim the display - if bit.isset(down,4) then + -- XXX left side back button: dim the display. + if bit.isset(down,7) then dimdisplay() -- Don't claim the image, just dim whatever is currently on the screen. dodraw() @@ -171,8 +171,8 @@ local function ontouch() if bit.isset(down, 6) then end - -- XXX left side back button - if bit.isset(down, 7) then + -- XXX front left + if bit.isset(down, 4) then end -- draw if we've claimed it! -- 2.50.1