FastLED 3.9.15
Loading...
Searching...
No Matches

◆ showColor() [2/2]

void CFastLED::showColor ( const struct CRGB & color,
uint8_t scale )

Set all leds on all controllers to the given color/scale.

Parameters
colorwhat color to set the leds to
scalewhat brightness scale to show at

Definition at line 177 of file FastLED.cpp.

177 {
178 while(m_nMinMicros && ((micros()-lastshow) < m_nMinMicros));
179 lastshow = micros();
180
181 // If we have a function for computing power, use it!
182 if(m_pPowerFunc) {
183 scale = (*m_pPowerFunc)(scale, m_nPowerData);
184 }
185
186 int length = 0;
187 CLEDController *pCur = CLEDController::head();
188 while(pCur && length < MAX_CLED_CONTROLLERS) {
189 if (pCur->getEnabled()) {
190 gControllersData[length] = pCur->beginShowLeds(pCur->size());
191 } else {
192 gControllersData[length] = nullptr;
193 }
194 length++;
195 pCur = pCur->next();
196 }
197
198 pCur = CLEDController::head();
199 while(pCur && length < MAX_CLED_CONTROLLERS) {
200 if(m_nFPS < 100) { pCur->setDither(0); }
201 if (pCur->getEnabled()) {
202 pCur->showColorInternal(color, scale);
203 }
204 pCur = pCur->next();
205 }
206
207 pCur = CLEDController::head();
208 length = 0; // Reset length to 0 and iterate again.
209 while(pCur && length < MAX_CLED_CONTROLLERS) {
210 if (pCur->getEnabled()) {
211 pCur->endShowLeds(gControllersData[length]);
212 }
213 length++;
214 pCur = pCur->next();
215 }
216 countFPS();
217}
#define MAX_CLED_CONTROLLERS
Definition FastLED.cpp:18
static void * gControllersData[MAX_CLED_CONTROLLERS]
Definition FastLED.cpp:105
static uint32_t lastshow
Definition FastLED.cpp:62
UISlider scale("Scale", 4,.1, 4,.1)
uint32_t m_nMinMicros
minimum µs between frames, used for capping frame rates
Definition FastLED.h:357
uint16_t m_nFPS
tracking for current frames per second (FPS) value
Definition FastLED.h:356
power_func m_pPowerFunc
function for overriding brightness when using FastLED.show();
Definition FastLED.h:359
void countFPS(int nFrames=25)
For debugging, this will keep track of time between calls to countFPS().
Definition FastLED.cpp:323
uint32_t m_nPowerData
max power use parameter
Definition FastLED.h:358
CLEDController * next()
Get the next controller in the linked list after this one.
CLEDController & setDither(uint8_t ditherMode=BINARY_DITHER)
Set the dithering mode for this controller to use.
virtual void endShowLeds(void *data)
virtual int size()
How many LEDs does this controller manage?
static CLEDController * head()
Get the first LED controller in the linked list of controllers.
void showColorInternal(const struct CRGB &data, int nLeds, uint8_t brightness)
virtual void * beginShowLeds(int size)

References CLEDController::beginShowLeds(), countFPS(), CLEDController::endShowLeds(), gControllersData, CLEDController::getEnabled(), CLEDController::head(), lastshow, m_nFPS, m_nMinMicros, m_nPowerData, m_pPowerFunc, MAX_CLED_CONTROLLERS, CLEDController::next(), scale, CLEDController::setDither(), CLEDController::showColorInternal(), and CLEDController::size().

Referenced by clear().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: