From 3914df55902fd661761a2da773046612b32373e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?King=20K=C3=A9vin?= Date: Mon, 28 Mar 2016 16:39:11 +0200 Subject: [PATCH] add gamma correction --- main.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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