diff --git a/arduino/mqttfastledmenu/mqttfastledmenu.cpp b/arduino/mqttfastledmenu/mqttfastledmenu.cpp index 0f5d381..73dbcd9 100644 --- a/arduino/mqttfastledmenu/mqttfastledmenu.cpp +++ b/arduino/mqttfastledmenu/mqttfastledmenu.cpp @@ -312,6 +312,36 @@ void SetupPurpleAndGreenPalette() ////////////////////////////////////////////////////////////////////////////// + + +//////////////////////////////////////////////// ColorTemperature +void colorTemp() +{ + // draw a generic, no-name rainbow + static uint8_t starthue = 0; + fill_rainbow( leds + 5, LED_NUM - 5, --starthue, 20); + + // Choose which 'color temperature' profile to enable. + uint8_t secs = (millis() / 1000) % (DISPLAYTIME * 2); + if( secs < DISPLAYTIME) { + FastLED.setTemperature( TEMPERATURE_1 ); // first temperature + leds[0] = TEMPERATURE_1; // show indicator pixel + } else { + FastLED.setTemperature( TEMPERATURE_2 ); // second temperature + leds[0] = TEMPERATURE_2; // show indicator pixel + } + + // Black out the LEDs for a few secnds between color changes + // to let the eyes and brains adjust + if( (secs % DISPLAYTIME) < BLACKTIME) { + memset8( leds, 0, LED_NUM * sizeof(CRGB)); + } + + FastLED.show(); + FastLED.delay(8); +} + +//////////////////////////////////////////////////////////////////// void loop() { // MQTT testConnectMQTT(); @@ -325,8 +355,10 @@ void loop() { ledCylon(); } else if (ledEffect == LED_EFFECT_FULLRED) { ledFullColor(); - } else if (ledEffect == LED_EFFET_COLORPATTERN) { + } else if (ledEffect == LED_EFFECT_COLORPATTERN) { ledColorPattern(); + } else if (ledEffect == LED_EFFECT_COLORTEMP) { + colorTemp(); } else { ledError(); }