From d5d9cd7923106496987fc11314a72ca079e27793 Mon Sep 17 00:00:00 2001 From: Johannes Kroll Date: Sat, 10 Mar 2012 18:56:07 +0100 Subject: pow color scaling, remove sb_update_all_colors --- pwm.c | 8 ++++---- shiftbrite.c | 10 ---------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/pwm.c b/pwm.c index 3436e9f..0641a80 100644 --- a/pwm.c +++ b/pwm.c @@ -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< i? (1< i? (1<=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) { -- cgit v1.2.1