From 363a2945156cef39d11612ae5e58280733c9b82b Mon Sep 17 00:00:00 2001 From: Stefan Rupp Date: Wed, 28 May 2014 23:02:09 +0200 Subject: [PATCH 1/2] more sensible default behaviour in default branch --- rgbyteclock.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/rgbyteclock.c b/rgbyteclock.c index 25e6ceb..c8d9c59 100644 --- a/rgbyteclock.c +++ b/rgbyteclock.c @@ -4,7 +4,8 @@ void rgbyteclock(void) { - uint8_t gain = 0; + uint8_t gain = 0x2f; + led_set_gain(gain); while (1) { led_set(0, 4000, 0, 0); @@ -14,13 +15,17 @@ void rgbyteclock(void) led_set(1, 0, 10000, 0); led_flush(); timer_wait(500); - led_set_gain(gain); - gain += 5; - if (gain > 0x3f) { - gain = 0; - } + + led_set(0, 0, 0, 0); + led_flush(); + timer_wait(500); + + led_set(1, 0, 0, 0); + led_flush(); + timer_wait(500); + PORTC ^= (1< Date: Mon, 23 Jun 2014 03:39:43 +0200 Subject: [PATCH 2/2] only a few changes to led1642gw code --- led1642gw.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/led1642gw.c b/led1642gw.c index 7a96c69..22b475b 100644 --- a/led1642gw.c +++ b/led1642gw.c @@ -16,6 +16,7 @@ #include "led1642gw_config.h" + #define NUM_LED1642GW_CHANNELS (16) // number of LED channels per IC //total numer of channels. needed to calculate the buffer size. @@ -40,26 +41,28 @@ static void write_data(uint16_t data, uint8_t le_clocks) { uint16_t mask = 0x8000; int8_t bit; + + SET_CLK_L(); SET_LE_L(); for (bit=15; bit>=le_clocks; bit--) { - SET_CLK_L(); if(data&mask) { SET_SDI_H(); } else { SET_SDI_L(); } SET_CLK_H(); mask >>= 1; + SET_CLK_L(); } SET_LE_H(); for (/*noting to initialize*/; bit>=0; bit--) { - SET_CLK_L(); if(data&mask) { SET_SDI_H(); } else { SET_SDI_L(); } SET_CLK_H(); mask >>= 1; + SET_CLK_L(); } // set all pins to low after transmission - SET_CLK_L(); + //SET_CLK_L(); SET_LE_L(); SET_SDI_L(); @@ -148,9 +151,11 @@ void led1642gw_set_gain(uint8_t gain) gain = 0x3f; } - for (uint8_t ic=0; ic<(NUM_LED1642GW_ICs-1); ic++) { + uint16_t g = gain; + + for (uint8_t ic=0; ic<(NUM_LED1642GW_ICs); ic++) { config_reg[ic] &= ~(0x003f); - config_reg[ic] |= gain; + config_reg[ic] |= g; } } @@ -158,9 +163,11 @@ void led1642gw_set_gain(uint8_t gain) void led1642gw_set_current_mode(uint8_t mode) { - for (uint8_t ic=0; ic<(NUM_LED1642GW_ICs-1); ic++) { - if (mode) { config_reg[ic] |= (1<<6); } - else { config_reg[ic] &= ~(1<<6); } + uint16_t mask = (1<<6); + + for (uint8_t ic=0; ic<(NUM_LED1642GW_ICs); ic++) { + if (mode) { config_reg[ic] |= mask; } + else { config_reg[ic] &= ~mask; } } } @@ -209,7 +216,7 @@ void led1642gw_flush(void) // then, when the brightness data has propagated through the // shift registers, write all data into the DATA LATCH of // all of the ICs. - write_data_latch(ledbuffer[channel+(ic*NUM_LED1642GW_CHANNELS)]); + write_data_latch(ledbuffer[channel+(NUM_LED1642GW_CHANNELS*ic)]); } // for the 16th channel, we don't write to the DATA LATCH, but // to the CLOBAL data latch.