|
@@ -314,7 +314,6 @@ static void IN15_FadeOut(void) {
|
|
* @return none. RGB value output direct to LED.
|
|
* @return none. RGB value output direct to LED.
|
|
*/
|
|
*/
|
|
static void HSV2LED(const uint8_t hue, const uint8_t sat, const uint8_t val) {
|
|
static void HSV2LED(const uint8_t hue, const uint8_t sat, const uint8_t val) {
|
|
-#ifdef TEST_TEST_TEST
|
|
|
|
int base;
|
|
int base;
|
|
uint32_t r=0, g=0, b=0;
|
|
uint32_t r=0, g=0, b=0;
|
|
|
|
|
|
@@ -364,72 +363,6 @@ static void HSV2LED(const uint8_t hue, const uint8_t sat, const uint8_t val) {
|
|
COLOR_G((uint8_t)g);
|
|
COLOR_G((uint8_t)g);
|
|
COLOR_B((uint8_t)b);
|
|
COLOR_B((uint8_t)b);
|
|
}
|
|
}
|
|
-#endif
|
|
|
|
-
|
|
|
|
- uint8_t r, g, b;
|
|
|
|
-
|
|
|
|
- if (sat == 0) {
|
|
|
|
- r = val;
|
|
|
|
- g = val;
|
|
|
|
- b = val;
|
|
|
|
- } else {
|
|
|
|
-
|
|
|
|
- uint8_t sextant = hue >> 8;
|
|
|
|
- uint8_t tmp;
|
|
|
|
-
|
|
|
|
- // Swap pointers depending which sextant we are in
|
|
|
|
- if((sextant) & 2) {
|
|
|
|
- tmp = r; r = b; b = tmp;
|
|
|
|
- }
|
|
|
|
- if((sextant) & 4) {
|
|
|
|
- tmp = g; g = b; b = tmp;
|
|
|
|
- }
|
|
|
|
- if(!((sextant) & 6)) {
|
|
|
|
- if(!((sextant) & 1)) {
|
|
|
|
- tmp = r; r = g; g = tmp;
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- if((sextant) & 1) {
|
|
|
|
- tmp = r; r = g; g = tmp;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- g = val; // Top level
|
|
|
|
-
|
|
|
|
- // Perform actual calculations
|
|
|
|
-
|
|
|
|
- /*
|
|
|
|
- * Bottom level: v * (1.0 - s)
|
|
|
|
- * --> (v * (255 - s) + error_corr + 1) / 256
|
|
|
|
- */
|
|
|
|
- uint16_t ww; // Intermediate result
|
|
|
|
- ww = val * (255 - sat); // We don't use ~s to prevent size-promotion side effects
|
|
|
|
- ww += 1; // Error correction
|
|
|
|
- ww += ww >> 8; // Error correction
|
|
|
|
- b = ww >> 8;
|
|
|
|
-
|
|
|
|
- uint8_t h_fraction = hue & 0xff; // 0...255
|
|
|
|
- uint32_t d; // Intermediate result
|
|
|
|
-
|
|
|
|
- if (!(sextant & 1))
|
|
|
|
- {
|
|
|
|
- // r = ...slope_up...;
|
|
|
|
- d = val * (uint32_t)((255 << 8) - (uint16_t)(sat * (256 - h_fraction)));
|
|
|
|
- d += d >> 8; // Error correction
|
|
|
|
- d += val; // Error correction
|
|
|
|
- r = d >> 16;
|
|
|
|
- } else {
|
|
|
|
- // r = ...slope_down...;
|
|
|
|
- d = val * (uint32_t)((255 << 8) - (uint16_t)(sat * h_fraction));
|
|
|
|
- d += d >> 8; // Error correction
|
|
|
|
- d += val; // Error correction
|
|
|
|
- r = d >> 16;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- COLOR_R(r);
|
|
|
|
- COLOR_G(g);
|
|
|
|
- COLOR_B(b);
|
|
|
|
-}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* Show info on tubes.
|
|
* Show info on tubes.
|
|
@@ -440,7 +373,8 @@ void showTime(void) {
|
|
|
|
|
|
if (Flag.Now_Day != 0) {
|
|
if (Flag.Now_Day != 0) {
|
|
// new hsv2led
|
|
// new hsv2led
|
|
- uint16_t hue = bcd2bin(Clock.Sec) * 256 / 10;
|
|
|
|
|
|
+ //uint16_t hue = (uint16_t)(bcd2bin(Clock.Sec) * 256) / 10;
|
|
|
|
+ uint8_t hue = bcd2bin(Clock.Sec);
|
|
HSV2LED(hue, 255, BrightLevel);
|
|
HSV2LED(hue, 255, BrightLevel);
|
|
} else {
|
|
} else {
|
|
HSV2LED(COLOUR_NIXIE, 255, BrightLevel);
|
|
HSV2LED(COLOUR_NIXIE, 255, BrightLevel);
|