Last active
October 22, 2018 21:45
-
-
Save atuline/fc67e4f5087fdeecae9484c9a908434a to your computer and use it in GitHub Desktop.
A fill color along with single colours
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
// https://plus.google.com/u/0/107012178390358476390/posts/DYRrA1iH5j5?cfem=1 | |
#include <FastLED.h> | |
#define LED_PIN 12 | |
#define CLK_PIN 11 | |
#define NUM_LEDS 60 | |
#define BRIGHTNESS 150 | |
#define LED_TYPE APA102 | |
#define COLOR_ORDER BGR | |
CRGB leds[NUM_LEDS]; | |
CRGBPalette16 currentPalette; | |
TBlendType currentBlending; | |
extern CRGBPalette16 myRedWhiteBluePalette; | |
extern const TProgmemPalette16 myRedWhiteBluePalette_p PROGMEM; | |
void setup() { | |
Serial.begin(57600); | |
// delay( 3000 ); // power-up safety delay | |
// FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS+1).setCorrection( TypicalLEDStrip ); | |
FastLED.addLeds<LED_TYPE, LED_PIN, CLK_PIN, COLOR_ORDER>(leds, NUM_LEDS+1).setCorrection( TypicalLEDStrip ); | |
FastLED.setBrightness( BRIGHTNESS ); | |
currentPalette = myRedWhiteBluePalette_p; | |
currentBlending = NOBLEND; | |
} | |
void loop() | |
{ | |
EVERY_N_MILLIS(50) // Use this instead of delays. In this case, we really don't need it. | |
{ | |
singlepal(); | |
} | |
FastLED.show(); | |
} | |
void singlepal() | |
{ | |
for (int i = 0; i<NUM_LEDS; i++) { | |
leds[i] = ColorFromPalette(currentPalette, (i*16)%(16*5)); | |
} | |
} | |
void myfiller() | |
{ | |
for (int i = 0; i<6;i++) { | |
CRGB color = ColorFromPalette(currentPalette, i*16); | |
fill_solid(leds+i*5, 5, color); | |
} | |
} // myfiller() | |
const TProgmemPalette16 myRedWhiteBluePalette_p PROGMEM = | |
{ | |
CRGB::White, | |
CRGB::Red, // 'white' is too bright compared to red and blue | |
CRGB::Green, | |
CRGB::Yellow, | |
CRGB::Blue, | |
CRGB::Orange | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment