headers, or do away with the Doubler entirely and hook the male pins on the
ESP8266, etc.
+ESP IO
+######
+
+The various boards are interfaced as follows:
+
++--------------+----------------------------------------------------------+
+| ESP GPIO Pin | Function |
++--------------+----------------------------------------------------------+
+| 2 | WS2812 serial shift out (to LED array input) |
++--------------+----------------------------------------------------------+
+| 4 | I2C SDA pin (to CAP1188, optional expansion) |
++--------------+----------------------------------------------------------+
+| 5 | I2C SCL pin (to CAP1188, optional expansion) |
++--------------+----------------------------------------------------------+
+| 12 | CAP1188 IRQ (from CAP1188) |
++--------------+----------------------------------------------------------+
+| 14 | CAP1188 RESET (to CAP1188) |
++--------------+----------------------------------------------------------+
+
+If GPIO becomes precious, the CAP1188 IRQ and RESET pins could be moved
+behind an I2C IO expander as they are low bandwidth. (The expander itself
+would presumably merit an IRQ pin and the CAP1188 IRQ could be demuxed.)
+
Theory of Operation
###################
--- /dev/null
+-- a votive-style candle?
+--
+-- 1 2 3 4 5 6 7 8
+-- 00 o o o f f o o o
+-- 08 o w o f f o w o
+-- 16 o W w w w w W o
+-- 24 o W W W W W W o
+--
+
+return function(t,fb,g,r,b)
+ fb:fill(0,0,0)
+ -- static base
+ local i,v
+ for i,v in ipairs({18,23,26,27,28,29,30,31}) do fb:set(v,2,2,2) end -- white (W)
+ for i,v in ipairs({10,15,19,20,21,22}) do fb:set(v,1,1,1) end -- dim white (w)
+
+ local cmax = math.max(r,g,b)
+
+ -- off channels stay off, on channels stay on, just minimally dim
+ local function adjust(val,bias) if val == 0 then return 0 elseif val <= bias then return 1 else return val - bias end end
+ -- update many pixels together with the same bias
+ local function drawbiased(...)
+ local i,v
+ local bias = math.random(cmax)
+ local ag = adjust(g,bias)
+ local ar = adjust(r,bias)
+ local ab = adjust(b,bias)
+ for i,v in ipairs(arg) do fb:set(v,ag,ar,ab) end
+ end
+
+ -- flame (f) behaviors: equal intensity, dimmer top, dimmer left, and dimmer right
+ local function draweq() for i,v in ipairs({4,5,12,13}) do fb:set(v,g,r,b) end end
+ local function drawbb() drawbiased(4,5) end
+ local function drawlb() drawbiased(4,12) end
+ local function drawrb() drawbiased(5,13) end
+
+ local ft = { [0] = draweq, draweq, draweq, drawbb, drawlb, drawrb }
+ t:register(250,tmr.ALARM_AUTO,function() ft[math.random(#ft)]() dodraw() end)
+ draweq()
+end
+-- o x o o x o o x
+-- x o o x o o x o
+-- x o o o o x x o
+-- o x o o x o o x
return function(t,fb,g,r,b)
- t:unregister()
fb:fill(0,0,0)
local c = string.char(g,r,b)
- fb:set( 2,c) fb:set( 5,c) fb:set( 8,c) fb:set( 9,c)
- fb:set( 9,c) fb:set(12,c) fb:set(15,c) fb:set(17,c)
- fb:set(17,c) fb:set(22,c) fb:set(23,c) fb:set(26,c)
- fb:set(29,c) fb:set(32,c)
-end
\ No newline at end of file
+ fb:set( 2,c) fb:set( 5,c) fb:set( 8,c)
+ fb:set( 9,c) fb:set(12,c) fb:set(15,c)
+ fb:set(17,c) fb:set(22,c) fb:set(23,c)
+ fb:set(26,c) fb:set(29,c) fb:set(32,c)
+end
+-- 1 0 1 - - - - -
+-- 0 x 0 - - x - -
+-- 1 0 1 x x - - -
+-- - - - - - x - -
return function(t,fb,g,r,b)
- t:unregister()
fb:fill(0,0,0)
local ix = 0
local c = string.char(g,r,b)
return function(t,fb,g,r,b)
- t:unregister()
fb:fill(0,0,0)
local c = string.char(g,r,b)
fb:set( 2,c) fb:set( 3,c) fb:set( 6,c) fb:set( 7,c)
fb:set( 9,c) fb:set(12,c) fb:set(13,c) fb:set(16,c)
fb:set(17,c) fb:set(20,c) fb:set(21,c) fb:set(24,c)
fb:set(26,c) fb:set(27,c) fb:set(30,c) fb:set(31,c)
- end
\ No newline at end of file
+ end
return function(t,fb,g,r,b)
- t:unregister()
fb:fill(0,0,0)
local ix = 0
local c = string.char(g,r,b)
ix = 1 - ix
dodraw()
end)
-end
\ No newline at end of file
+end
-return function(t,fb,g,r,b)
- t:unregister()
+return function(t,fb,g,r,b)
fb:fill(0,0,0)
local ix = 0
local c = string.char(g,r,b)
ix = 1 - ix
dodraw()
end)
- end
\ No newline at end of file
+ end
-- 1 2 3 4 5 6 7 8
-- 00 o o o o o h x h
-- 08 o o o o o e x o
--- 16 o o w w o o x o
--- 24 x x w w x x x o
+-- 16 w w w w o o x o
+-- 24 w w w w x x x o
--
return function(t,fb,g,r,b)
local ix = 2 -- since we start effectively in state 1...
, [5] = function() fb:set(20,c) fb:set(28,0,0,0) end
-- slither 2
, [6] = function() fb:set(19,c) fb:set(20,0,0,0) fb:set(27,0,0,0) fb:set(28,c) end
- -- slither 1, heart off
+ -- slither 3, heart off
, [7] = function() fb:set(18,c) fb:set(19,0,0,0) fb:set(20,c) fb:set(26,0,0,0) fb:set(27,c) fb:set(28,0,0,0) fb:set(14,0,0,0) end
- -- slither 2
+ -- slither 4
, [8] = function() fb:set(17,c) fb:set(18,0,0,0) fb:set(19,c) fb:set(20,0,0,0) fb:set(25,0,0,0) fb:set(26,c) fb:set(27,0,0,0) fb:set(28,c) end
}
fb:fill(0,0,0)