MCPcopy Create free account
hub / github.com/FastLED/FastLED / getFirePaletteIndex

Function getFirePaletteIndex

examples/FestivalStick/curr.h:580–606  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

578}
579
580uint8_t getFirePaletteIndex(uint32_t millis32, int width, int max_width, int height, int max_height,
581 uint32_t y_speed) {
582 uint16_t scale = fireScaleXY.as<uint16_t>();
583
584 float xf = (float)width / (float)max_width;
585 uint8_t x = (uint8_t)(xf * 255);
586
587 uint32_t cosx = cos8(x);
588 uint32_t sinx = sin8(x);
589
590 float trig_scale = scale * fireScaleX.value();
591 cosx *= trig_scale;
592 sinx *= trig_scale;
593
594 uint32_t y = height * scale + y_speed;
595
596 uint16_t z = millis32 / fireInvSpeedZ.as<uint16_t>();
597
598 uint16_t noise16 = inoise16(cosx << 8, sinx << 8, y << 8, z << 8);
599
600 uint8_t noise_val = noise16 >> 8;
601
602 int8_t subtraction_factor = abs8(height - (max_height - 1)) * 255 /
603 (max_height - 1);
604
605 return qsub8(noise_val, subtraction_factor);
606}
607
608void fillFrameBufferFire(uint32_t now) {
609 fl::CRGBPalette16 myPal = getFirePalette();

Callers 1

fillFrameBufferFireFunction · 0.85

Calls 4

inoise16Function · 0.85
cos8Function · 0.50
sin8Function · 0.50
valueMethod · 0.45

Tested by

no test coverage detected