]> hydra-www.ietfng.org Git - acmetensortoys-esp-lua_lamp/commitdiff
adds the un-dimming feature to the dimming feature
authorRachael <srbennett@gmail.com>
Sun, 14 May 2017 00:22:56 +0000 (17:22 -0700)
committerRachael <srbennett@gmail.com>
Sun, 14 May 2017 00:22:56 +0000 (17:22 -0700)
init2.lua
lamp-touch.lua

index 11c0815a02394606eb1c245abd0b1ef6c3411edd..2b8633aac84db5593b6d15e33aa8968db9f79267 100644 (file)
--- a/init2.lua
+++ b/init2.lua
@@ -43,6 +43,7 @@ ledfb_claimed = 0 -- 0 : unclaimed, set remote immediately
                   -- 2 : claimed locally but remote has changed
 
 isblackout = false
+isDim = true
 dimfactor = 0
 local baselinefb = ws2812.newBuffer(32,3)
 baselinefb:fill(1,1,1)
@@ -55,7 +56,7 @@ function dodraw()
         -- dimming, so mix the baseline "all channels on minimum" as 128/256ths
         -- to act as a rounding factor.  The image in "ledfb" will be mixed in
         -- as 256/(dimfactor+1) 256ths
-        doublefb:mix(128,baselinefb,256/(dimfactor+1),ledfb)
+        doublefb:mix(256,baselinefb,256/(dimfactor+1),ledfb)
         ws2812.write(doublefb)
       end
     else
index b66294b04c3cbdb2772547edafaec68c907ba7a7..79354cd95fc27bc2eb2cf43f78f3bb0965c41c13 100644 (file)
@@ -1,4 +1,4 @@
--- globals referenced: isblackout, dimfactor, dodraw, ledfb, ledfb_claimed, remotefb, remotetmr, lamp_announce, tq, loaddrawfn
+-- globals referenced: isblackout, dimfactor, isDim, dodraw, ledfb, ledfb_claimed, remotefb, remotetmr, lamp_announce, tq, loaddrawfn
 --
 -- globals asserted: touchcolor, touchlastfn
 --
@@ -52,7 +52,16 @@ end
 local function toggleblackout() setblackout(not isblackout) end
 
 local function dimdisplay()
-  dimfactor= dimfactor + 1 % 16
+  if isDim then
+    dimfactor = dimfactor + 1
+  else
+    dimfactor = dimfactor - 1
+  end
+  if dimfactor == 7 then
+    isDim = false
+  elseif dimfactor == 0 then
+    isDim = true
+  end
 end
 
 local function touchcolorvec(c)
@@ -106,7 +115,13 @@ local function ontouch()
 
   -- back right button: display toggle once per touch of button
   if bit.isset(down,0) then
-    if touch_db_blackout == nil then toggleblackout() else tq:dequeue(touch_db_blackout) end
+    if touch_db_blackout == nil then
+      toggleblackout()
+    else
+      print("dequeueing blackout call")
+      tq:dequeue(touch_db_blackout)
+    end
+    print("queueing blackout call")
     touch_db_blackout = tq:queue(300,onblackdebounce)
   end