daisy chaining basically works now. gotta sort leds now.

This commit is contained in:
Stefan Rupp 2014-03-13 01:33:13 +01:00
parent a1aa846050
commit a98b779412
3 changed files with 59 additions and 8 deletions

View File

@ -123,6 +123,11 @@ static void write_global_latch(uint16_t data)
write_data(data, 6); write_data(data, 6);
} }
static void write_no_command(uint16_t data)
{
write_data(data, 0);
}
void ledcontroller_turn_all_on(void) void ledcontroller_turn_all_on(void)
{ {
@ -174,6 +179,7 @@ void led_set(uint8_t lednum, uint16_t red, uint16_t green, uint16_t blue)
} }
#if 0
void led_flush(void) void led_flush(void)
{ {
for (uint8_t i=0; i<NUM_LED_CHANNELS-1; i++) { for (uint8_t i=0; i<NUM_LED_CHANNELS-1; i++) {
@ -182,4 +188,29 @@ void led_flush(void)
} }
write_global_latch(ledbuffer[NUM_LED_CHANNELS-1]); write_global_latch(ledbuffer[NUM_LED_CHANNELS-1]);
} }
#endif
void led_flush(void)
{
uint8_t channel;
for (channel=0; channel<NUM_LED1642GW_CHANNELS-1; channel++) {
write_no_command(ledbuffer[3*channel+0]);
write_no_command(ledbuffer[3*channel+1]);
write_data_latch(ledbuffer[3*channel+2]);
}
write_no_command(ledbuffer[3*channel+0]);
write_no_command(ledbuffer[3*channel+1]);
write_global_latch(ledbuffer[3*channel+2]);
}
void ledcontroller_set_channel(uint8_t channel, uint16_t value)
{
if (channel < NUM_LED_CHANNELS) {
ledbuffer[channel] = value;
}
}

View File

@ -22,7 +22,9 @@ void ledcontroller_init(void);
void led_set(uint8_t lednum, uint16_t red, uint16_t green, uint16_t blue); void led_set(uint8_t lednum, uint16_t red, uint16_t green, uint16_t blue);
void led_flush(void); void led_flush(void);
void ledcontroller_turn_all_on(void); void ledcontroller_turn_all_on(void);
void ledcontroller_turn_all_off(void); void ledcontroller_turn_all(void);
void ledcontroller_set_channel(uint8_t channel, uint16_t value);
#endif // LEDCONTROLLER_H #endif // LEDCONTROLLER_H

View File

@ -22,40 +22,58 @@ void rgbyteclock(void)
ledcontroller_turn_all_on(); ledcontroller_turn_all_on();
while (1) {
//led_set(11, 0x7ff, 0x00, 0x00);
for (int c=0; c<48; c++) {
//PORTC ^= (1<<PC5);
ledcontroller_set_channel(c, 0x7ff);
led_flush();
timer_wait(1000);
}
for (int i=0; i<16; i++) {
led_set(i, 0x00, 0x00, 0x00);
}
led_flush();
timer_wait(100);
}
while (1) { while (1) {
PORTC ^= (1<<PC5); PORTC ^= (1<<PC5);
for (int i=0; i<15; i++) { for (int i=0; i<15; i++) {
led_set(i, 0x7ff, 0x00, 0x00); led_set(i, 0x7ff, 0x00, 0x00);
led_flush(); led_flush();
timer_wait(2000); timer_wait(500);
} }
for (int i=0; i<15; i++) { for (int i=0; i<15; i++) {
led_set(i, 0x00, 0x00, 0x00); led_set(i, 0x00, 0x00, 0x00);
} }
led_flush(); led_flush();
timer_wait(1000); timer_wait(100);
for (int i=0; i<15; i++) { for (int i=0; i<15; i++) {
led_set(i, 0x00, 0x7ff, 0x00); led_set(i, 0x00, 0x7ff, 0x00);
led_flush(); led_flush();
timer_wait(2000); timer_wait(500);
} }
for (int i=0; i<15; i++) { for (int i=0; i<15; i++) {
led_set(i, 0x00, 0x00, 0x00); led_set(i, 0x00, 0x00, 0x00);
} }
led_flush(); led_flush();
timer_wait(1000); timer_wait(100);
for (int i=0; i<15; i++) { for (int i=0; i<15; i++) {
led_set(i, 0x00, 0x00, 0x7ff); led_set(i, 0x00, 0x00, 0x7ff);
led_flush(); led_flush();
timer_wait(2000); timer_wait(500);
} }
for (int i=0; i<15; i++) { for (int i=0; i<15; i++) {
led_set(i, 0x00, 0x00, 0x00); led_set(i, 0x00, 0x00, 0x00);
} }
led_flush(); led_flush();
timer_wait(1000); timer_wait(100);
} }