2 #include <util/delay.h>
16 DDRB |= _BV(PB1) | _BV(PB2) | _BV(PB4);
18 // PWM setup, use T/C 1
19 TCCR1 = _BV(CS10) // clock at CLK/1
20 | _BV(PWM1A) // OCR1A in PWM mode
21 | _BV(COM1A1); // clear on compare match
22 GTCCR = _BV(PWM1B) // OCR1B in PWM mode
23 | _BV(COM1B1); // clear on compare match)
31 static unsigned char levels[] = {
32 0, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 255
34 #define N_LEVELS (sizeof(levels)/sizeof(levels[0]))
36 static void led_set(unsigned char led, unsigned char val)
40 OCR1A = val < N_LEVELS ? levels[val] : levels[N_LEVELS-1];
50 OCR1B = val < N_LEVELS ? levels[val] : levels[N_LEVELS-1];
55 static unsigned char rand[] = {
56 193, 33, 133, 97, 139, 225, 40, 105, 110, 238, 57, 250, 26, 221, 166, 247, 138, 23, 107, 122, 154, 33, 201, 66, 154, 78, 137, 198, 86, 232, 38, 182, 16, 198, 73, 231, 58, 114, 58, 105,
58 #define N_RAND (sizeof(rand)/sizeof(rand[0]))
62 static unsigned char r, l, exp;
70 if (exp >= N_LEVELS-4)
85 static unsigned char r;
96 led_set(1, ((exp >> 3) & 1) ^ ((exp >> 5) & 1));
102 static unsigned char r, l, exp;
116 } else if (l > exp) {