Created
January 17, 2019 03:08
-
-
Save andre-geldenhuis/a8636079df4e6e7ba29edf17f11e80cf to your computer and use it in GitHub Desktop.
FastLed ColorTemperature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "FastLED.h" | |
FASTLED_USING_NAMESPACE | |
#if defined(FASTLED_VERSION) && (FASTLED_VERSION < 3001000) | |
#warning "Requires FastLED 3.1 or later; check github for latest code." | |
#endif | |
#define NUM_STRIPS 1 | |
#define NUM_LEDS_PER_STRIP 60 | |
#define NUM_LEDS NUM_LEDS_PER_STRIP * NUM_STRIPS | |
CRGB leds[NUM_STRIPS * NUM_LEDS_PER_STRIP]; | |
CRGB leds_virt1[20]; | |
//#define BRIGHTNESS 30 | |
#define BRIGHTNESS 25 | |
#define FRAMES_PER_SECOND 120 | |
uint8_t gHue = 0; // rotating "base color" used by many of the patterns | |
#define TEMPERATURE_1 Tungsten100W | |
#define TEMPERATURE_2 OvercastSky | |
// How many seconds to show each temperature before switching | |
#define DISPLAYTIME 20 | |
// How many seconds to show black between switches | |
#define BLACKTIME 3 | |
void setup() { | |
delay(200); // 3 second delay for recovery | |
// tell FastLED there's 60 NEOPIXEL leds on pin 3, starting at index 0 in the led array | |
FastLED.addLeds<NEOPIXEL, 13>(leds, 0, NUM_LEDS_PER_STRIP).setCorrection(TypicalLEDStrip); | |
// set master brightness control | |
FastLED.setBrightness(BRIGHTNESS); | |
} | |
void loop() { | |
// draw a generic, no-name rainbow | |
static uint8_t starthue = 0; | |
// fill_rainbow( leds + 5, NUM_LEDS - 5, --starthue, 20); | |
fill_solid(leds,NUM_LEDS,CRGB::White); | |
// 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, NUM_LEDS * sizeof(CRGB)); | |
} | |
FastLED.show(); | |
FastLED.delay(8); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment