#include "effect_fire.h" #include "my_color_palettes.h" #include "config.h" #include "my_fastled.h" #include "functions.h" void FireEffect::start() { this->data = new uint8_t[LED_COUNT]; for (int i=0; idata[i]=0; for (int i=0; idata[i]=this->spark_temp(); } void FireEffect::stop() { delete [] this->data; } void FireEffect::loop() { cooldown(); spark(); propagate(); draw(); } void FireEffect::cooldown() { for(int i=0; idata[i] = scale8(this->data[i], EFFECT_FIRE_COOLDOWN); // 240 or something } void FireEffect::spark() { for(int x=0; xdata[x] = this->spark_temp(); } inline uint8_t FireEffect::spark_temp() { return random8(180, 255); } void FireEffect::propagate() { for (int y=1; ydata[index] = scale8(this->data[below_index], 128) + scale8(this->data[below_index+1], 64); } else if (x==LED_WIDTH-1) { this->data[index] = scale8(this->data[below_index], 128) + scale8(this->data[below_index-1], 64); } else { this->data[index] = scale8(this->data[below_index], 128) + scale8(this->data[below_index-1], 32) + scale8(this->data[below_index+1], 32); } } } void FireEffect::draw() { for (int y=1; ydata[y*LED_WIDTH + x])); } }