|
@@ -35,7 +35,7 @@ static void IN15_FadeIn(void);
|
|
|
static void IN15_FadeOut(void);
|
|
|
static void valIncrease(uint8_t * val, uint8_t max);
|
|
|
static void valDecrease(uint8_t * val, uint8_t max);
|
|
|
-static void HSV2LED(const uint8_t hue, const uint8_t sat, const uint8_t val);
|
|
|
+static void HSV2LED(const int hue, const uint8_t sat, const uint8_t val);
|
|
|
|
|
|
/* funcions */
|
|
|
void Clock_Init(void) {
|
|
@@ -305,10 +305,70 @@ static void IN15_FadeOut(void) {
|
|
|
|
|
|
/**
|
|
|
* @brief HSV to RGB convertion
|
|
|
- * @param hue: 0-(6*256)-1 /59/, sat: 0-255, val (lightness): 0-255
|
|
|
+ * @param hue: 0-59, sat: 0-255, val (lightness): 0-255
|
|
|
* @return none. RGB value output direct to LED.
|
|
|
*/
|
|
|
-static void HSV2LED(const uint8_t hue, const uint8_t sat, const uint8_t val) {
|
|
|
+#define HUE_DEGREE 60
|
|
|
+static void HSV2LED(const int hue, const uint8_t sat, const uint8_t val) {
|
|
|
+ uint8_t r, g, b;
|
|
|
+
|
|
|
+ int h = hue;
|
|
|
+ int s = sat;
|
|
|
+ int v = val;
|
|
|
+ int i = h / (60 * HUE_DEGREE);
|
|
|
+ int p = (256 * v - s * v) / 256;
|
|
|
+
|
|
|
+ if (i & 1)
|
|
|
+ {
|
|
|
+ int q = (256 * 60 * HUE_DEGREE * v - h * s * v + 60 * HUE_DEGREE * s * v * i) / (256 * 60 * HUE_DEGREE);
|
|
|
+ switch (i)
|
|
|
+ {
|
|
|
+ case 1:
|
|
|
+ r = q;
|
|
|
+ g = v;
|
|
|
+ b = p;
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ r = p;
|
|
|
+ g = q;
|
|
|
+ b = v;
|
|
|
+ break;
|
|
|
+ case 5:
|
|
|
+ r = v;
|
|
|
+ g = p;
|
|
|
+ b = q;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ int t = (256 * 60 * HUE_DEGREE * v + h * s * v - 60 * HUE_DEGREE * s * v * (i + 1)) / (256 * 60 * HUE_DEGREE);
|
|
|
+ switch (i)
|
|
|
+ {
|
|
|
+ case 0:
|
|
|
+ r = v;
|
|
|
+ g = t;
|
|
|
+ b = p;
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ r = p;
|
|
|
+ g = v;
|
|
|
+ b = t;
|
|
|
+ break;
|
|
|
+ case 4:
|
|
|
+ r = t;
|
|
|
+ g = p;
|
|
|
+ b = v;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ COLOR_R(r);
|
|
|
+ COLOR_G(g);
|
|
|
+ COLOR_B(b);
|
|
|
+}
|
|
|
+
|
|
|
+static void old_HSV2LED(const uint8_t hue, const uint8_t sat, const uint8_t val) {
|
|
|
int base;
|
|
|
uint32_t r=0, g=0, b=0;
|
|
|
|