diff options
-rw-r--r-- | pwm.c | 8 | ||||
-rw-r--r-- | shiftbrite.c | 10 |
2 files changed, 4 insertions, 14 deletions
@@ -28,15 +28,15 @@ volatile uint16_t value_blue = 1024; void pwm_set_rgb(uint8_t r, uint8_t g, uint8_t b) { - value_red = r << 4; - value_green = g << 4; - value_blue = b << 4; + value_red = (uint16_t)r * r >> 4; + value_green = (uint16_t)g * g >> 4; + value_blue = (uint16_t)b * b >> 4; } void pwm_tick(void) { for (uint16_t i = 0; i < 4096; i++) { - // this should take about the same time for each iteration, regardless of pulse width + /* this should take about the same time for each iteration, regardless of pulse width */ PORTA= (PORTA & ~((1<<PA0)|(1<<PA1)|(1<<PA2))) | (value_red > i? (1<<PA0): 0) | (value_green > i? (1<<PA1): 0) | diff --git a/shiftbrite.c b/shiftbrite.c index 331a7b1..7d6c17e 100644 --- a/shiftbrite.c +++ b/shiftbrite.c @@ -78,16 +78,6 @@ static void sb_shiftout(uint32_t val) } } -#if 0 -/* shift out all color values to connected shiftbrites */ -static void sb_update_all_colors(void) -{ - for(int i = sb_num_shiftbrites-1; i>=0; i--) - sb_shiftout( (uint32_t)sb_colors[i].g | ((uint32_t)sb_colors[i].r<<10) | ((uint32_t)sb_colors[i].b<<20) ); - sb_toggle_latch(); -} -#endif - /* set the color of a shiftbrite. */ void sb_setcolor(uint8_t lamp_index, uint8_t r, uint8_t g, uint8_t b) { |