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

◆ computeOneTwinkle()

CRGB computeOneTwinkle ( uint32_t ms,
uint8_t salt )
Examples
TwinkleFox.ino.

Definition at line 221 of file TwinkleFox.ino.

222{
223 uint16_t ticks = ms >> (8-TWINKLE_SPEED);
224 uint8_t fastcycle8 = ticks;
225 uint16_t slowcycle16 = (ticks >> 8) + salt;
226 slowcycle16 += sin8( slowcycle16);
227 slowcycle16 = (slowcycle16 * 2053) + 1384;
228 uint8_t slowcycle8 = (slowcycle16 & 0xFF) + (slowcycle16 >> 8);
229
230 uint8_t bright = 0;
231 if( ((slowcycle8 & 0x0E)/2) < TWINKLE_DENSITY) {
232 bright = attackDecayWave8( fastcycle8);
233 }
234
235 uint8_t hue = slowcycle8 - salt;
236 CRGB c;
237 if( bright > 0) {
238 c = ColorFromPalette( gCurrentPalette, hue, bright, NOBLEND);
239 if( COOL_LIKE_INCANDESCENT == 1 ) {
240 coolLikeIncandescent( c, fastcycle8);
241 }
242 } else {
243 c = CRGB::Black;
244 }
245 return c;
246}
void coolLikeIncandescent(CRGB &c, uint8_t phase)
uint8_t attackDecayWave8(uint8_t i)
CRGBPalette16 gCurrentPalette
@ NOBLEND
No interpolation between palette entries.
CRGB ColorFromPalette(const CRGBPalette16 &pal, uint8_t index, uint8_t brightness, TBlendType blendType)
Get a color from a palette.
#define sin8
Platform-independent alias of the fast sin implementation.
Definition trig8.h:216
@ Black
<div style='background:#000000;width:4em;height:4em;'></div>
Definition crgb.h:499
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:54
#define TWINKLE_SPEED
Definition twinklefox.h:89
#define TWINKLE_DENSITY
Definition twinklefox.h:94
#define COOL_LIKE_INCANDESCENT
Definition twinklefox.h:108

References attackDecayWave8(), CRGB::Black, ColorFromPalette(), COOL_LIKE_INCANDESCENT, coolLikeIncandescent(), gCurrentPalette, NOBLEND, sin8, TWINKLE_DENSITY, and TWINKLE_SPEED.

Referenced by drawTwinkles().

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