]> hydra-www.ietfng.org Git - acmetensortoys-esp-lua_lamp/commitdiff
removes a useless loop that made the dimming code much slower. This also moves the...
authorRachael <srbennett@gmail.com>
Sat, 8 Jul 2017 22:44:51 +0000 (15:44 -0700)
committerRachael <srbennett@gmail.com>
Sat, 8 Jul 2017 22:44:51 +0000 (15:44 -0700)
init2.lua
lamp-touch.lua

index 2b8633aac84db5593b6d15e33aa8968db9f79267..187871e42e3959457da4f9138c1ffd6b0a4df84b 100644 (file)
--- 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
index eca101aa15abbc5cce394ab8dcd702c15551d9fc..684c968b8d32756401e519d4c134d7e7be2051fe 100644 (file)
@@ -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!