-- 2 : claimed locally but remote has changed
isblackout = false
+isDim = true
dimfactor = 0
local baselinefb = ws2812.newBuffer(32,3)
baselinefb:fill(1,1,1)
-- 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
--- 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
--
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)
-- 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