diff --git a/Makefile b/Makefile index 73f84ba..e7a1c0a 100644 --- a/Makefile +++ b/Makefile @@ -26,7 +26,7 @@ $(PRG).elf: $(OBJ) # dependency: rgbyteclock.o: timer.o lcd.o rgbyteclock.h rtc.o spi.o ledcontroller.o -main.o: rgbyteclock.o lcd.o spi.o ledcontroller.o +main.o: rgbyteclock.o lcd.o spi.o ledcontroller.o rtc.o timer.o timer.o: timer.h lcd.o: lcd.h timer.o rtc.o: rtc.h diff --git a/ledcontroller.c b/ledcontroller.c index d1a005c..98d98fb 100644 --- a/ledcontroller.c +++ b/ledcontroller.c @@ -10,6 +10,12 @@ */ +/* + * This module tries to control 15 RGB-LEDs + * connected to three daisy-chained + * LED1642GW-ICs from STM. + */ + #include "ledcontroller.h" #include @@ -20,7 +26,7 @@ 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) +static int8_t map_lednum_to_channels(uint8_t lednum, uint8_t *channel_r, uint8_t *channel_g, uint8_t *channel_b) { uint8_t ret; @@ -84,12 +90,12 @@ static void write_global_latch(uint16_t data) void ledcontroller_init(void) { + PORTC &= ~(1< 0 ) { + if ( map_lednum_to_channels(lednum, &c_r, &c_g, &c_b) > 0 ) { ledbuffer[c_r] = red; ledbuffer[c_g] = green; ledbuffer[c_b] = blue; diff --git a/main.c b/main.c index 5f63140..1e65c69 100644 --- a/main.c +++ b/main.c @@ -10,18 +10,22 @@ */ #include +#include #include "timer.h" #include "lcd.h" #include "rgbyteclock.h" #include "spi.h" #include "ledcontroller.h" +#include "rtc.h" int main(void) { timer_init(); + rtc_init(0); spi_slave_init(); ledcontroller_init(); + sei(); lcd_init(); rgbyteclock(); diff --git a/rgbyteclock.c b/rgbyteclock.c index 20667e3..868ef84 100644 --- a/rgbyteclock.c +++ b/rgbyteclock.c @@ -12,14 +12,47 @@ #include "rgbyteclock.h" - +#include "timer.h" +#include "lcd.h" +#include "ledcontroller.h" void rgbyteclock(void) { - while(1) { + for (int i=0; i<15; i++) { + led_set(i, 0x7ff, 0x00, 0x00); + led_flush(); + timer_wait(200); + } + for (int i=0; i<15; i++) { + led_set(i, 0x00, 0x00, 0x00); + } + led_flush(); + timer_wait(100); + + for (int i=0; i<15; i++) { + led_set(i, 0x00, 0x7ff, 0x00); + led_flush(); + timer_wait(200); + } + for (int i=0; i<15; i++) { + led_set(i, 0x00, 0x00, 0x00); + } + led_flush(); + timer_wait(100); + + for (int i=0; i<15; i++) { + led_set(i, 0x00, 0x00, 0x7ff); + led_flush(); + timer_wait(200); + } + for (int i=0; i<15; i++) { + led_set(i, 0x00, 0x00, 0x00); + } + led_flush(); + timer_wait(100); } diff --git a/rgbyteclock.h b/rgbyteclock.h index c31d9e9..9d1c6f4 100644 --- a/rgbyteclock.h +++ b/rgbyteclock.h @@ -14,8 +14,6 @@ #define RGBYTECLOCK_H #include -#include "timer.h" -#include "lcd.h" void rgbyteclock(void); diff --git a/rtc.c b/rtc.c index 4f97b94..589e1d4 100644 --- a/rtc.c +++ b/rtc.c @@ -37,8 +37,6 @@ void rtc_init(uint32_t rtc_time) TCCR2B = (1<