diff options
Diffstat (limited to 'pwm.c')
-rw-r--r-- | pwm.c | 19 |
1 files changed, 9 insertions, 10 deletions
@@ -20,6 +20,7 @@ #include <avr/io.h> #include <stdint.h> #include <string.h> +#include "shiftbrite.h" volatile uint16_t value_red = 3072; volatile uint16_t value_green = 2048; @@ -32,17 +33,15 @@ void pwm_set_rgb(uint8_t r, uint8_t g, uint8_t b) value_blue = b << 4; } -void pwm_worker_loop(void) +void pwm_tick(void) { - for (;;) { - for (uint16_t i = 0; i < 4096; i++) { - // 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) | - (value_blue > i? (1<<PA2): 0); - } - } + for (uint16_t i = 0; i < 4096; i++) { + // 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) | + (value_blue > i? (1<<PA2): 0); + } } void pwm_init(void) |