|
|
@ -56,6 +56,23 @@ struct ColourCode |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
enum State |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
COLOUR_DISPLAYED, |
|
|
|
|
|
|
|
SPLIT_DISPLAYED, |
|
|
|
|
|
|
|
FADE_DISPLAYED, |
|
|
|
|
|
|
|
FAN_DISPLAYED, |
|
|
|
|
|
|
|
RUNNING_FAN_DISPLAYED, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
STROBE_SELECT_SPEED, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FADE_SELECT_COLOUR, |
|
|
|
|
|
|
|
SPLIT_SELECT_COLOUR, |
|
|
|
|
|
|
|
FAN_SELECT_COLOUR, |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
State state = State.COLOUR_DISPLAYED; |
|
|
|
|
|
|
|
|
|
|
|
const ColourCode colourCodes[] = |
|
|
|
const ColourCode colourCodes[] = |
|
|
|
{ |
|
|
|
{ |
|
|
|
{0xE619FF00, 0xFB04EF00, COL_RED}, |
|
|
|
{0xE619FF00, 0xFB04EF00, COL_RED}, |
|
|
@ -90,9 +107,16 @@ const int NUM_COLOURCODES = sizeof(colourCodes) / sizeof(ColourCode); |
|
|
|
CRGBW leds[NUM_LEDS]; |
|
|
|
CRGBW leds[NUM_LEDS]; |
|
|
|
CRGB *ledsRGB = (CRGB *) &leds[0]; |
|
|
|
CRGB *ledsRGB = (CRGB *) &leds[0]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CRGBW selectedColours[16]; |
|
|
|
|
|
|
|
uint8_t selectedColourCount = 0; |
|
|
|
|
|
|
|
|
|
|
|
//IRrecv irrecv(IR_RECEIVE_PIN);/
|
|
|
|
//IRrecv irrecv(IR_RECEIVE_PIN);/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const int BRIGHTNESS_FADE_SPEED = 8; |
|
|
|
|
|
|
|
|
|
|
|
uint8_t brightness = 128; |
|
|
|
uint8_t brightness = 128; |
|
|
|
|
|
|
|
uint8_t brightnessTarget = 128; |
|
|
|
|
|
|
|
uint8_t brightnessFade = 0; |
|
|
|
uint32_t lastCode = 0; |
|
|
|
uint32_t lastCode = 0; |
|
|
|
|
|
|
|
|
|
|
|
decode_results results; |
|
|
|
decode_results results; |
|
|
@ -185,24 +209,20 @@ void loop() |
|
|
|
{ |
|
|
|
{ |
|
|
|
case CODE_BRIGHTER: |
|
|
|
case CODE_BRIGHTER: |
|
|
|
brightness += 32; |
|
|
|
brightness += 32; |
|
|
|
FastLED.setBrightness(brightness); |
|
|
|
brightnessTarget = brightness; |
|
|
|
FastLED.show(); |
|
|
|
|
|
|
|
Serial.println(F("Brighter")); |
|
|
|
Serial.println(F("Brighter")); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case CODE_DIMMER: |
|
|
|
case CODE_DIMMER: |
|
|
|
brightness -= 32; |
|
|
|
brightness -= 32; |
|
|
|
FastLED.setBrightness(brightness); |
|
|
|
brightnessTarget = brightness; |
|
|
|
FastLED.show(); |
|
|
|
|
|
|
|
Serial.println(F("Dimmer")); |
|
|
|
Serial.println(F("Dimmer")); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case CODE_OFF: |
|
|
|
case CODE_OFF: |
|
|
|
FastLED.setBrightness(0); |
|
|
|
brightnessTarget = 0; |
|
|
|
FastLED.show(); |
|
|
|
|
|
|
|
Serial.println(F("Off")); |
|
|
|
Serial.println(F("Off")); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case CODE_ON: |
|
|
|
case CODE_ON: |
|
|
|
FastLED.setBrightness(brightness); |
|
|
|
brightnessTarget = brightness; |
|
|
|
FastLED.show(); |
|
|
|
|
|
|
|
Serial.println(F("On")); |
|
|
|
Serial.println(F("On")); |
|
|
|
break; |
|
|
|
break; |
|
|
|
default: |
|
|
|
default: |
|
|
@ -213,5 +233,15 @@ void loop() |
|
|
|
if (brightness <= 0) |
|
|
|
if (brightness <= 0) |
|
|
|
brightness = 255; |
|
|
|
brightness = 255; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (brightnessFade != brightnessTarget) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (brightnessFade < brightnessTarget) |
|
|
|
|
|
|
|
brightnessFade += min(BRIGHTNESS_FADE_SPEED, brightnessTarget - brightnessFade); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
brightnessFade -= min(BRIGHTNESS_FADE_SPEED, brightnessFade - brightnessTarget); |
|
|
|
|
|
|
|
//brightnessFade = brightnessTarget;
|
|
|
|
|
|
|
|
FastLED.setBrightness(brightnessFade); |
|
|
|
|
|
|
|
FastLED.show(); |
|
|
|
|
|
|
|
} |
|
|
|
delay(100); |
|
|
|
delay(100); |
|
|
|
} |
|
|
|
} |
|
|
|