I have a WS2812 8x32 matrix and I would like to:
Animate an arrow from the left and an arrow from the right towards the middle (simultaneously) and then apart again.
Does anyone have a tip for me how I could best solve this?
Each arrow is defined as an 8x8 dot matrix (a LEFT arrow and a RIGHT arrow)
00 make a function which translate your physical pixel order to a coordinate system
01 make a function which prints an arrow at a defined position
02 define a start position of the arrow to print
03 print the arrow at this position
04 increase position
05 delete display
06 goto 03
noiasca:
03 print the arrow at this position
04 increase position
05 delete display
06 goto 03
So this is a "sprite" sort of implementation. You have defined two 8 by 8 sprites.
Albeit a pretty trivial form. OK, you need to consider a couple of things to start with and complete the specification.
Do the arrows collide or just touch or not touch? Clearly impaction would present a further problem. Is there to be any background, any other pattern present?
Otherwise it is fairly simple. To move a sprite with no background, you can re-draw it in the new position, noting that you must draw both the positive (lit) and negative (dark) parts. There is a subtle difference here between coding for the MAX7219 where you write eight bits (pixels) at a time, light or dark and the WS2812 where you write each individual pixel - and three bytes at that. It would usually be wasteful to erase the whole area before re-drawing the sprite.
You then blank out the edge(s) of its previous position. Also note that you only update the WS2812s after you have "drawn" the new display fully to the buffer.