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

◆ computeOneTwinkle()

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

Definition at line 231 of file TwinkleFox.ino.

232{
233 uint16_t ticks = ms >> (8-TWINKLE_SPEED);
234 uint8_t fastcycle8 = ticks;
235 uint16_t slowcycle16 = (ticks >> 8) + salt;
236 slowcycle16 += sin8( slowcycle16);
237 slowcycle16 = (slowcycle16 * 2053) + 1384;
238 uint8_t slowcycle8 = (slowcycle16 & 0xFF) + (slowcycle16 >> 8);
239
240 uint8_t bright = 0;
241 if( ((slowcycle8 & 0x0E)/2) < TWINKLE_DENSITY) {
242 bright = attackDecayWave8( fastcycle8);
243 }
244
245 uint8_t hue = slowcycle8 - salt;
246 CRGB c;
247 if( bright > 0) {
248 c = ColorFromPalette( gCurrentPalette, hue, bright, NOBLEND);
249 if( COOL_LIKE_INCANDESCENT == 1 ) {
250 coolLikeIncandescent( c, fastcycle8);
251 }
252 } else {
253 c = CRGB::Black;
254 }
255 return c;
256}
uint8_t hue
void coolLikeIncandescent(CRGB &c, uint8_t phase)
uint8_t attackDecayWave8(uint8_t i)
CRGBPalette16 gCurrentPalette
#define sin8
Platform-independent alias of the fast sin implementation.
Definition trig8.h:230
CRGB ColorFromPalette(const CRGBPalette16 &pal, fl::u8 index, fl::u8 brightness, TBlendType blendType)
@ Black
<div style='background:#000000;width:4em;height:4em;'></div>
Definition crgb.h:567
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:86
#define TWINKLE_SPEED
Definition twinklefox.h:87
#define TWINKLE_DENSITY
Definition twinklefox.h:92
#define COOL_LIKE_INCANDESCENT
Definition twinklefox.h:106

References attackDecayWave8(), CRGB::Black, fl::ColorFromPalette(), COOL_LIKE_INCANDESCENT, coolLikeIncandescent(), gCurrentPalette, hue, 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: