From: Rachael Date: Mon, 1 May 2017 05:19:44 +0000 (-0700) Subject: kinda works, sorta X-Git-Url: https://hydra-www.ietfng.org/gitweb/?a=commitdiff_plain;h=6d656d2bba321ec9c6a395ac487b50f5340c97b5;p=acmetensortoys-esp-lua_lamp kinda works, sorta --- diff --git a/init2.lua b/init2.lua index 2228b18..26ad993 100644 --- 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 diff --git a/lamp-touch.lua b/lamp-touch.lua index 7d17c31..89f3a2a 100644 --- a/lamp-touch.lua +++ b/lamp-touch.lua @@ -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() diff --git a/pushall.sh b/pushall.sh index 8223b95..c747827 100755 --- a/pushall.sh +++ b/pushall.sh @@ -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"