/* * ---------------------------------------------------------------------------- * "THE BEER-WARE LICENSE" (Revision 42): * wrote this file. As long as you retain this notice you * can do whatever you want with this stuff. If we meet some day, and you think * this stuff is worth it, you can buy me a beer in return. * (c) 2014 Stefan Rupp * ---------------------------------------------------------------------------- */ #include "ledcontroller.h" #include #define NUM_LED1642GW_ICs (3) #define NUM_LED1642GW_CHANNELS (16) #define NUM_CHANNELS (NUM_LED1642GW_CHANNELS*NUM_LED1642GW_ICs) static uint16_t ledbuffer[NUM_CHANNELS]; static int8_t get_channel_from_lednum(uint8_t lednum, uint8_t *channel_r, uint8_t *channel_g, uint8_t *channel_b) { uint8_t ret; if (lednum < 15) { *channel_r = 3*lednum; *channel_g = 3*lednum+1; *channel_b = 3*lednum+2; if ( lednum >= 10 ) { *channel_r += 2; *channel_g += 2; *channel_b += 2; } else if ( lednum >= 5 ) { *channel_r += 1; *channel_g += 1; *channel_b += 1; } ret = 1; } else { ret = 0; } return ret; } static void write_data(uint16_t data, uint8_t le_clocks) { PORTC &= ~(1<=le_clocks; bit--) { if(data&mask) { PORTC |= (1<>= 1; } PORTC |= (1<=0; bit--) { if(data&mask) { PORTC |= (1<>= 1; } } static void write_data_latch(uint16_t data) { write_data(data, 4); } static void write_global_latch(uint16_t data) { write_data(data, 6); } void ledcontroller_init(void) { DDRC |= (1< 0 ) { ledbuffer[c_r] = red; ledbuffer[c_g] = green; ledbuffer[c_b] = blue; } } void led_flush(void) { for (uint8_t i=0; i