From 6b55403334543492e691f84759f36f2698848764 Mon Sep 17 00:00:00 2001 From: fruchti Date: Sun, 4 Oct 2020 22:43:42 +0200 Subject: [PATCH] Add animation LUT generation script --- animation_lut.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 animation_lut.py diff --git a/animation_lut.py b/animation_lut.py new file mode 100755 index 0000000..0ad7c04 --- /dev/null +++ b/animation_lut.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python + +from colorsys import hsv_to_rgb + +LUT_SIZE = 256 +SATURATION = 0.8 +VALUE = 1 +RESOLUTION = 12 # in bits + +print('const LED_Colour_t Animation_ColourLUT[] =') +print('{') +for i in range(LUT_SIZE): + h = i / LUT_SIZE + rgb = hsv_to_rgb(h, SATURATION, VALUE) + # Gamma-correct + rgb = tuple(pow(x, 2.2) for x in rgb) + # Scale to BCM resolution + (r, g, b) = tuple(round(2 ** RESOLUTION * x) for x in rgb) + print(' {{ .r = {}, .g = {}, .b = {} }},'.format(r, g, b)) +print('};')