]> hydra-www.ietfng.org Git - acmetensortoys-esp-lua_lamp/commitdiff
kinda works, sorta
authorRachael <srbennett@gmail.com>
Mon, 1 May 2017 05:19:44 +0000 (22:19 -0700)
committerRachael <srbennett@gmail.com>
Mon, 1 May 2017 05:19:44 +0000 (22:19 -0700)
init2.lua
lamp-touch.lua
pushall.sh

index 2228b18b0a3351d880d56eefc64fd2ffe74725a1..26ad9935b7dd390894c8dfe929b0e450f2d12955 100644 (file)
--- a/init2.lua
+++ b/init2.lua
@@ -43,7 +43,25 @@ ledfb_claimed = 0 -- 0 : unclaimed, set remote immediately
                   -- 2 : claimed locally but remote has changed
 
 isblackout = false
-function dodraw() if not isblackout then ws2812.write(ledfb) end end
+dimfactor = 0
+function dodraw()
+  if not isblackout then
+    if dimfactor > 0 then
+      for i=1, ledfb:size() do
+        local g,r,b = ledfb:get(i)
+        -- need to allocate two buffers, reading from one and writing to the other to allow for some pixels only being set once then dimmed into infinity and others being redrawn each frame.
+        for dimindex = 0, dimfactor do
+          g = math.floor((g+1)/2)
+          b = math.floor((b+1)/2)
+          r = math.floor((r+1)/2)
+        end
+        ledfb:set(i, g, r, b)
+      end
+    end
+    --print(ledfb)
+    ws2812.write(ledfb)
+  end
+end
 function doremotedraw()
   if ledfb_claimed > 1
    then ledfb_claimed = 2
index 7d17c316d67e5b0353a9478a0e49e0a5cd51de1c..89f3a2a86b6ff6fc6b30a698baa29236641e057b 100644 (file)
@@ -1,4 +1,4 @@
--- globals referenced: isblackout, dodraw, ledfb, ledfb_claimed, remotefb, remotetmr, lamp_announce, tq, loaddrawfn
+-- globals referenced: isblackout, dimfactor, dodraw, ledfb, ledfb_claimed, remotefb, remotetmr, lamp_announce, tq, loaddrawfn
 --
 -- globals asserted: touchcolor, touchlastfn
 --
@@ -10,7 +10,6 @@ local touch_db_blackout = nil
 local touch_db_fn = nil
 local touchfns    = { }
 local touchfnix = 1
-local dimfactor = 0
 
 if touchcolor == nil then touchcolor = 40 end
 if touchlastfn == nil then touchlastfn = "fill" end
@@ -63,18 +62,6 @@ local function touchcolorvec(c)
   elseif c < 32 then r = 0; g = 15 - cm; b = cm
   else               r = cm; g = 0; b = 15 - cm
   end
-  if (dimfactor > 0) then
-    print("before green is ", g)
-    print("before blue is ", b)
-
-    for i = 0, dimfactor do
-      g = math.floor((g+1)/2)
-      b = math.floor((b+1)/2)
-      r = math.floor((r+1)/2)
-    end
-    print("green is ", g)
-    print("blue is ", b)
-  end
   return g,r,b
 end
 
@@ -154,7 +141,7 @@ local function ontouch()
     end
   end
 
-  -- XXX front left: no function assigned, maybe device select or something?
+  -- XXX front left: dim the display
   if bit.isset(down,4) then
     dimdisplay()
     claimfb()
index 8223b95bf6603d1cf20bf1c16f28ca2a8819fd4a..c747827c8884af71523613bb70166b5b46ffd6a9 100755 (executable)
@@ -5,17 +5,17 @@ set -e -u
 . ./host/pushcommon.sh
 
 dopushcompile net/nwfmqtt.lua
-dopushcompile cap1188/cap1188.lua
-dopushcompile cap1188/cap1188-init.lua
+#dopushcompile cap1188/cap1188.lua
+#dopushcompile cap1188/cap1188-init.lua
 dopushcompile examples/lamp/lamp-touch.lua
-dopushcompile examples/lamp/lamp-remote.lua
-dopushcompile examples/lamp/telnetd-cap.lua
+#dopushcompile examples/lamp/lamp-remote.lua
+#dopushcompile examples/lamp/telnetd-cap.lua
 #dopush        examples/lamp/conf/nwfmqtt.conf
 #dopush        examples/lamp/conf/nwfmqtt.subs
 dopushcompile examples/lamp/init2.lua
 
-for i in examples/lamp/draw-*.lua; do
-  dopushcompile ${i}
-done
+#for i in examples/lamp/draw-*.lua; do
+#  dopushcompile ${i}
+#done
 
 echo "SUCCESS"