esp32-sk6812/include/Animation/FireAnimation.h

50 lines
1.2 KiB
C++

#pragma once
#include <random>
#include <vector>
#include "Animation.h"
class FireAnimation : public Animation
{
public:
FireAnimation(Fader *fader, bool cold);
void loop(uint64_t frame) override;
void stop(void) override
{
m_stopping = true;
}
void reset(void) override
{
m_stopping = false;
m_running = true;
}
private:
static const constexpr unsigned MAX_NEW_ENERGY = 160;
static const constexpr unsigned RM_ENERGY = 7;
static const constexpr unsigned MAX_PULL_ENERGY_PCT = 100;
std::vector<uint32_t> m_energy;
std::vector<uint32_t> m_energySmooth;
std::vector<int> m_colorMapIndices;
std::vector<Fader::Color> m_colorMapColors;
std::default_random_engine m_gen;
bool m_stopping;
uint32_t m_intensity;
uint8_t interpolate(uint32_t energy, std::size_t start_x, std::size_t end_x, uint8_t start_c, uint8_t end_c);
void colormap(uint32_t energy, Fader::Color *color);
uint32_t idx(uint32_t strip, uint32_t module)
{
return strip * m_fader->modules_per_strip() + module;
}
};