Simple neopixel (WS2812) library, tuned for stm32 (L432) at 80 MHz Should be compatible with any stm32, different clock speed may require timing adjustments in neopixel.c
Dependents: Nucleo_neopixel_ovgu Nucleo_neopixel_ovgu1 Nucleo_neopixel_ovgu3
Fork of NeoPixel by
Diff: colorspace.h
- Revision:
- 0:a81364d9a67b
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/colorspace.h Tue Mar 21 21:17:08 2017 +0000 @@ -0,0 +1,64 @@ +#ifndef HSL_H +#define HSL_H + +// +// Utilities for working with colors in different color spaces +// + +#include "mbed.h" + +// all values 0 to 1 + +// adapted from: https://github.com/ratkins/RGBConverter + +struct FloatRGB { + float r; + float g; + float b; +}; + + +struct FloatHSL { + float h; + float s; + float l; +}; + + +struct FloatHSV { + float h; + float s; + float v; +}; + + +// --- Converting to RGB hex --- + +/** Convert HSL to RGB hex */ +uint32_t hsl2hex(const FloatHSL *hsl); + +/** Convert HSV to RGB hex */ +uint32_t hsv2hex(const FloatHSV *hsv); + +/** Convert RGB to RGB hex */ +uint32_t rgb2hex(FloatRGB *rgb); + + +// --- Itner-space conversion functions --- + +/** Convert HSL to RGB */ +void hsl2rgb(const FloatHSL *hsl, FloatRGB *rgb); + +/** Convert RGB to HSL */ +void rgb2hsl(const FloatRGB *rgb, FloatHSL *hsl); + +/** Convert from HSV to HSL */ +void hsv2hsl(const FloatHSV *hsv, FloatHSL *hsl); + +/** Convert from HSL to HSV */ +void hsl2hsv(const FloatHSL *hsl, FloatHSV *hsv); + +/** Convert HSV to RGB ("handy" algo) */ +void hsv2rgb(const FloatHSV *hsv, FloatRGB *rgb); + +#endif /* HSL_H */ \ No newline at end of file