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:   NEOPIXEL_SAMPLE ppd

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers colorspace.h Source File

colorspace.h

00001 #ifndef HSL_H
00002 #define HSL_H
00003 
00004 //
00005 // Utilities for working with colors in different color spaces
00006 //
00007 
00008 #include "mbed.h"
00009 
00010 // all values 0 to 1
00011 
00012 // adapted from: https://github.com/ratkins/RGBConverter
00013 
00014 struct FloatRGB {
00015     float r;
00016     float g;
00017     float b;
00018 };
00019 
00020 
00021 struct FloatHSL {
00022     float h;
00023     float s;
00024     float l;
00025 };
00026 
00027 
00028 struct FloatHSV {
00029     float h;
00030     float s;
00031     float v;
00032 };
00033 
00034 
00035 // --- Converting to RGB hex ---
00036 
00037 /** Convert HSL to RGB hex */
00038 uint32_t hsl2hex(const FloatHSL *hsl);
00039 
00040 /** Convert HSV to RGB hex */
00041 uint32_t hsv2hex(const FloatHSV *hsv);
00042 
00043 /** Convert RGB to RGB hex */
00044 uint32_t rgb2hex(FloatRGB *rgb);
00045 
00046 
00047 // --- Itner-space conversion functions ---
00048 
00049 /** Convert HSL to RGB */
00050 void hsl2rgb(const FloatHSL *hsl, FloatRGB *rgb);
00051 
00052 /** Convert RGB to HSL */
00053 void rgb2hsl(const FloatRGB *rgb, FloatHSL *hsl);
00054 
00055 /** Convert from HSV to HSL */
00056 void hsv2hsl(const FloatHSV *hsv, FloatHSL *hsl);
00057 
00058 /** Convert from HSL to HSV */
00059 void hsl2hsv(const FloatHSL *hsl, FloatHSV *hsv);
00060 
00061 /** Convert HSV to RGB ("handy" algo) */
00062 void hsv2rgb(const FloatHSV *hsv, FloatRGB *rgb);
00063 
00064 #endif /* HSL_H */