diff --git a/main.c b/main.c index 9398c91..12c046d 100644 --- a/main.c +++ b/main.c @@ -28,6 +28,7 @@ #include // standard streams #include // error number utilities #include // string utilities +#include // mathematical utilities /* STM32 (including CM3) libraries */ #include // real-time control clock library @@ -92,6 +93,8 @@ volatile uint32_t current_time = 0; char command[32] = {0}; /** user input command index */ uint8_t command_i = 0; +/** gamma correction lookup table (common for all colors) */ +uint8_t gamma_correction_lut[256] = {0}; int _write(int file, char *ptr, int len) { @@ -248,7 +251,7 @@ static void clock_leds_set(void) clock_leds_old[i*3+0] = clock_leds[i*3+0]; // memorise change clock_leds_old[i*3+1] = clock_leds[i*3+1]; // memorise change clock_leds_old[i*3+2] = clock_leds[i*3+2]; // memorise change - ws2812b_set_rgb(i,clock_leds[i*3+0],clock_leds[i*3+1],clock_leds[i*3+2]); // set new value (this costs time) + ws2812b_set_rgb(i,gamma_correction_lut[clock_leds[i*3+0]],gamma_correction_lut[clock_leds[i*3+1]],gamma_correction_lut[clock_leds[i*3+2]]); // set new value (this costs time) } } } @@ -378,6 +381,11 @@ int main(void) nvic_enable_irq(BUTTON_IRQ); // enable interrupt #endif + // generate gamma correction table (with fixed gamma value) + for (uint16_t i=0; i