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

◆ computeOneTwinkle()

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

Definition at line 229 of file TwinkleFox.ino.

230{
231 uint16_t ticks = ms >> (8-TWINKLE_SPEED);
232 uint8_t fastcycle8 = ticks;
233 uint16_t slowcycle16 = (ticks >> 8) + salt;
234 slowcycle16 += sin8( slowcycle16);
235 slowcycle16 = (slowcycle16 * 2053) + 1384;
236 uint8_t slowcycle8 = (slowcycle16 & 0xFF) + (slowcycle16 >> 8);
237
238 uint8_t bright = 0;
239 if( ((slowcycle8 & 0x0E)/2) < TWINKLE_DENSITY) {
240 bright = attackDecayWave8( fastcycle8);
241 }
242
243 uint8_t hue = slowcycle8 - salt;
244 CRGB c;
245 if( bright > 0) {
246 c = ColorFromPalette( gCurrentPalette, hue, bright, NOBLEND);
247 if( COOL_LIKE_INCANDESCENT == 1 ) {
248 coolLikeIncandescent( c, fastcycle8);
249 }
250 } else {
251 c = CRGB::Black;
252 }
253 return c;
254}
void coolLikeIncandescent(CRGB &c, uint8_t phase)
uint8_t attackDecayWave8(uint8_t i)
CRGBPalette16 gCurrentPalette
uint8_t hue
Definition advanced.h:94
CRGB ColorFromPalette(const CRGBPalette16 &pal, fl::u8 index, fl::u8 brightness, TBlendType blendType)
fl::CRGB CRGB
Definition crgb.h:25
fl::u16 uint16_t
Definition s16x16x4.h:214
unsigned char uint8_t
Definition s16x16x4.h:209
@ Black
<div style='background:#000000;width:4em;height:4em;'></div>
Definition crgb.h:510
#define TWINKLE_SPEED
Definition twinklefox.h:85
#define TWINKLE_DENSITY
Definition twinklefox.h:90
#define COOL_LIKE_INCANDESCENT
Definition twinklefox.h:104

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

Referenced by drawTwinkles().

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