3 #include <util/delay.h>
5 //The DDRs of the led matrix outputs are set in the mux loop.
10 void swapBuffers(void){
11 uint8_t* tmp
= frameBuffer
;
12 frameBuffer
= secondFrameBuffer
;
13 secondFrameBuffer
= tmp
;
16 void setLED(int num
, int val
){
18 frameBuffer
[num
>>3] &= ~(1<<(num
&7));
20 frameBuffer
[num
>>3] |= 1<<(num
&7);
25 for(int i
=0; i
<8; i
++){
26 uint8_t Q
= 0x80>>i
; //select the currently active "row" of the matrix. On the protoboards I make, this actually corresponds to physical traces.
27 //uint8_t DDRQ = 0xFF>>i; //This is supposed to be an optimization. It is untested and will probably not work.
28 uint8_t DDRQ
= 0xFF; //Just for testing: reactivating the old behavioor
29 //unpacking of frame data: data is packed like this: [11111117][22222266][33333555][4444----]
31 Q
|= frameBuffer
[i
&3] >> (i
+1);
33 Q
|= frameBuffer
[i
&3] & (0xFF << ((i
&3)+1));
34 //FIXME this whole mapping shit should be done in h/w!!1!
35 //FIXME this whole mapping is not even correct!!1!
36 //FIXME IT DOES NOT WORK!!1!
61 /* second channel skeleton
64 Q |= frameBuffer[4+(i&3)] >> i;
66 Q |= frameBuffer[4+(i&3)] & (0xFF << (i&3));
78 //this scary construct is in place to make the compiler happy. if you know a better way, feel free to improve.
79 uint8_t _frameBuffer
[] = {0,0,0,0};
80 uint8_t _secondFrameBuffer
[] = {0,0,0,0};
81 uint8_t* frameBuffer
= _frameBuffer
;
82 uint8_t* secondFrameBuffer
= _secondFrameBuffer
;
84 #endif//HAS_LED_SUPPORT