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 Ondřej Hruška

Committer:
MightyPork
Date:
Tue Mar 21 21:17:08 2017 +0000
Revision:
0:a81364d9a67b
initial

Who changed what in which revision?

UserRevisionLine numberNew contents of line
MightyPork 0:a81364d9a67b 1 #ifndef HSL_H
MightyPork 0:a81364d9a67b 2 #define HSL_H
MightyPork 0:a81364d9a67b 3
MightyPork 0:a81364d9a67b 4 //
MightyPork 0:a81364d9a67b 5 // Utilities for working with colors in different color spaces
MightyPork 0:a81364d9a67b 6 //
MightyPork 0:a81364d9a67b 7
MightyPork 0:a81364d9a67b 8 #include "mbed.h"
MightyPork 0:a81364d9a67b 9
MightyPork 0:a81364d9a67b 10 // all values 0 to 1
MightyPork 0:a81364d9a67b 11
MightyPork 0:a81364d9a67b 12 // adapted from: https://github.com/ratkins/RGBConverter
MightyPork 0:a81364d9a67b 13
MightyPork 0:a81364d9a67b 14 struct FloatRGB {
MightyPork 0:a81364d9a67b 15 float r;
MightyPork 0:a81364d9a67b 16 float g;
MightyPork 0:a81364d9a67b 17 float b;
MightyPork 0:a81364d9a67b 18 };
MightyPork 0:a81364d9a67b 19
MightyPork 0:a81364d9a67b 20
MightyPork 0:a81364d9a67b 21 struct FloatHSL {
MightyPork 0:a81364d9a67b 22 float h;
MightyPork 0:a81364d9a67b 23 float s;
MightyPork 0:a81364d9a67b 24 float l;
MightyPork 0:a81364d9a67b 25 };
MightyPork 0:a81364d9a67b 26
MightyPork 0:a81364d9a67b 27
MightyPork 0:a81364d9a67b 28 struct FloatHSV {
MightyPork 0:a81364d9a67b 29 float h;
MightyPork 0:a81364d9a67b 30 float s;
MightyPork 0:a81364d9a67b 31 float v;
MightyPork 0:a81364d9a67b 32 };
MightyPork 0:a81364d9a67b 33
MightyPork 0:a81364d9a67b 34
MightyPork 0:a81364d9a67b 35 // --- Converting to RGB hex ---
MightyPork 0:a81364d9a67b 36
MightyPork 0:a81364d9a67b 37 /** Convert HSL to RGB hex */
MightyPork 0:a81364d9a67b 38 uint32_t hsl2hex(const FloatHSL *hsl);
MightyPork 0:a81364d9a67b 39
MightyPork 0:a81364d9a67b 40 /** Convert HSV to RGB hex */
MightyPork 0:a81364d9a67b 41 uint32_t hsv2hex(const FloatHSV *hsv);
MightyPork 0:a81364d9a67b 42
MightyPork 0:a81364d9a67b 43 /** Convert RGB to RGB hex */
MightyPork 0:a81364d9a67b 44 uint32_t rgb2hex(FloatRGB *rgb);
MightyPork 0:a81364d9a67b 45
MightyPork 0:a81364d9a67b 46
MightyPork 0:a81364d9a67b 47 // --- Itner-space conversion functions ---
MightyPork 0:a81364d9a67b 48
MightyPork 0:a81364d9a67b 49 /** Convert HSL to RGB */
MightyPork 0:a81364d9a67b 50 void hsl2rgb(const FloatHSL *hsl, FloatRGB *rgb);
MightyPork 0:a81364d9a67b 51
MightyPork 0:a81364d9a67b 52 /** Convert RGB to HSL */
MightyPork 0:a81364d9a67b 53 void rgb2hsl(const FloatRGB *rgb, FloatHSL *hsl);
MightyPork 0:a81364d9a67b 54
MightyPork 0:a81364d9a67b 55 /** Convert from HSV to HSL */
MightyPork 0:a81364d9a67b 56 void hsv2hsl(const FloatHSV *hsv, FloatHSL *hsl);
MightyPork 0:a81364d9a67b 57
MightyPork 0:a81364d9a67b 58 /** Convert from HSL to HSV */
MightyPork 0:a81364d9a67b 59 void hsl2hsv(const FloatHSL *hsl, FloatHSV *hsv);
MightyPork 0:a81364d9a67b 60
MightyPork 0:a81364d9a67b 61 /** Convert HSV to RGB ("handy" algo) */
MightyPork 0:a81364d9a67b 62 void hsv2rgb(const FloatHSV *hsv, FloatRGB *rgb);
MightyPork 0:a81364d9a67b 63
MightyPork 0:a81364d9a67b 64 #endif /* HSL_H */