#include #include #include #include "rgbstring.h" unsigned char jiffies; typedef struct { unsigned char type : 4; unsigned char order : 4; } pixel_t; pixel_t pixels[STRIP_SIZE]; int main(void) { unsigned char i, start, rgb, jiffies; init_log(); init_serial(); _delay_ms(3000/8); CLKPR = _BV(CLKPCE); CLKPR = 0; for (i = 0; i < STRIP_SIZE; i+= 23) pixels[i].type = 2; while (1) { jiffies++; if ((jiffies & 7) == 0) { pixels[start].type = 1; pixels[start].order = 14; } if ((jiffies & 7) == 3) { pixels[start].type = 2; pixels[start].order = 0; start += 19; } start += 63; if (start >= STRIP_SIZE) start -= STRIP_SIZE; for (i = 0; i < STRIP_SIZE; i++) { unsigned char type = pixels[i].type; unsigned char order = pixels[i].order; switch (type) { case 0: send_rgb(0, 0, 4); break; case 1: case 3: send_rgb( 6+(1 << (order/2)), 6+(1 << (order/2)), 6+(1 << (order/2)) ); pixels[i].type = type == 3 ? 2 : 0;; if (order > 1 && i) { pixels[i-1].type = pixels[i-1].type == 2 ? 3 : 1; pixels[i-1].order = order-1; } break; case 2: if (order >= 8) { send_rgb(1 << ((15-order) / 2), 0, 0); } else { send_rgb(1 << (order/2), 0, 0); } if (++order >= 15) pixels[i].type = 0; pixels[i].order = order; break; } } end_frame(); _delay_ms(50); #if 0 log_byte(0xFa); log_flush(); #endif } }