2 #include <util/delay.h>
8 uint8_t *red
, *green
, *blue
;
10 void init_timer(void);
11 void demo_matrix(uint8_t*, uint8_t*, uint8_t*);
12 void display_matrix(void);
17 red
=malloc(32 * sizeof(uint8_t));
18 green
=malloc(32 * sizeof(uint8_t));
19 blue
=malloc(32 * sizeof(uint8_t));
22 demo_matrix(red
, green
, blue
);
27 DDRB
= (1 << DDB1
) | (1 << DDB2
) | (1 << DDB3
) | (1 << DDB4
) | (1 << DDB5
);
28 PORTB
= (1 << PB3
);//pwm
29 //pb3 - pwm; pb1 - SR out clk;pb2 - SR input;pb4 - SR reset;pb5 - SR shift clk
31 DDRC
= (1 << DDC0
) | (1 << DDC1
) | (1 << DDC2
) | (1 << DDC3
);
34 DDRD
= (1 << DDD0
) | (1 << DDD5
) | (1 << DDD6
) | (1 << DDD7
) ;
37 PORTB
|= (1 << PB4
); //reset
55 //---TCCR0A = (1 << COM0A1) | (1 << COM0B1) | (1 << WGM01) | (1 << WGM00); // FAST PWM ON OC0A OC0B
56 //---TCCR0B = (1 << CS00); // NO PRESCALER
57 //TIMSK0 = (1 << OCIE0A);//interupt enable
63 //Timer2 -- helligkeit
64 TCCR2A
= (1 << COM2A1
) | (1 << WGM21
) | (1 << WGM20
);
65 TCCR2B
= (1 << CS20
); // NO PRESCALER
66 //TIMSK0 = (1 << OCIE0A);//interupt enable
70 void demo_matrix(uint8_t* red
, uint8_t* green
, uint8_t* blue
)
75 green
[y
]=255/(255-(y
*8));
76 blue
[y
]=255/(255-(y
*8));
81 void demo_matrix(uint8_t* red, uint8_t* green, uint8_t* blue)
92 void display_matrix(void)
94 uint8_t i
,j
,x
,y
,portc
,color
;
105 PORTD
&= ~((1<<PD5
)|(1<<PD6
)|(1<<PD7
));
108 if(red
[j
]&&!(i
%red
[j
]))
111 if(green
[j
]&&!(i
%green
[j
]))
114 if(blue
[j
]&&!(i
%blue
[j
]))
119 PORTB
&= ~ (1 << PB5
);
124 PORTB
&= ~(1 << PB1
);
138 - shift reg pwm!!!overkill 4x more lightness