Created
December 9, 2023 22:05
-
-
Save connornishijima/4b3b5daa6f733ddbb1ebff9d41f04fb2 to your computer and use it in GitHub Desktop.
Christmas Light Fixer (Incandescent LUT)
This file contains hidden or 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
// This function reduces harsh blue tones in RGB LED lights, bringing | |
// them closer to the look of retro tinted incandescent bulbs. | |
// | |
// All input colors to the christmas_light_fixer() function are multiplied | |
// by a LUT of a warm white, reducing the power of the blue spectrum while | |
// preserving the brightness of the yellow spectrum. | |
CRGB christmas_light_fixer( CRGB input_color ){ | |
CRGB incandescent_lookup = CRGB( 255, 113, 40 ); | |
CRGB out_color = input_color; | |
out_color.r = uint16_t(out_color.r * incandescent_lookup.r) >> 8; | |
out_color.g = uint16_t(out_color.g * incandescent_lookup.g) >> 8; | |
out_color.b = uint16_t(out_color.b * incandescent_lookup.b) >> 8; | |
return out_color; | |
} | |
// -------------------------------------------------------------- | |
// Try this function out like this: | |
// Shows the full color spectrum on your LED strip, and toggles the incandescent LUT on and off every 2 seconds. | |
void loop(){ | |
static bool fixer_enabled = true; // Used for toggling | |
for(uint16_t i = 0; i < NUM_LEDS; i++){ | |
float progress = i / float(NUM_LEDS); // gives each LED a value between 0.0 and 1.0 | |
CRGB raw_color = CHSV(255*progress, 255, 255); // Whole color wheel at full saturation | |
// -------------------------------------------------------------------------------- | |
CRGB pretty_color = christmas_light_fixer( raw_color ); // Apply the color fixer | |
// -------------------------------------------------------------------------------- | |
if(fixer_enabled){ | |
leds[i] = pretty_color; | |
} | |
else{ | |
leds[i] = raw_color; | |
} | |
} | |
FastLED.show(); | |
delay(2000); | |
fixer_enabled = !fixer_enabled; // toggle on and off | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment