#include #include #include "util.h" static volatile uint16_t s_lfsr=0xACE1u; void init_random( uint16_t lfsr ) { s_lfsr = lfsr; } uint16_t random( void ) { uint8_t bit; bit = ((s_lfsr >> 0) ^ (s_lfsr >> 2) ^ (s_lfsr >> 3) ^ (s_lfsr >> 5) ) & 1; s_lfsr = (s_lfsr >> 1) | (bit << 15); return s_lfsr; } void get_color( uint16_t *r, uint16_t *g, uint16_t *b, uint8_t colorIndex ) { switch( colorIndex ) { case COLOR_RED: *r = MAX_BRIGHTNESS; *g = 0x00; *b = 0x00; break; case COLOR_GREEN: *r = 0x00; *g = MAX_BRIGHTNESS; *b = 0x00; break; case COLOR_YELLOW: *r = MAX_BRIGHTNESS; *g = MAX_BRIGHTNESS; *b = 0x00; break; case COLOR_BLUE: *r = 0x00; *g = 0x00; *b = MAX_BRIGHTNESS; break; case COLOR_MAGENTA: *r = MAX_BRIGHTNESS; *g = 0x00; *b = MAX_BRIGHTNESS; break; case COLOR_CYAN: *r = 0x00; *g = MAX_BRIGHTNESS; *b = MAX_BRIGHTNESS; break; case COLOR_WHITE: *r = MAX_BRIGHTNESS; *g = MAX_BRIGHTNESS; *b = MAX_BRIGHTNESS; break; default: // black *r = 0x00; *g = 0x00; *b = 0x00; break; } } uint8_t get_button( void ) { static uint8_t last_button = BUTTON_NONE; uint8_t button = BUTTON_NONE; if( !(PIND&(1<