esp32-sk6812/include/Animation/RgbwPsychedelicAnimation.h
Thomas Kolb 25abc446b0 Increased sin LUT precision: 16-bit x 2048 entries
This massively improves glitches in functions like sin(t + sin(t)), as
used in the RgbwPsychedelicAnimation. That animation is now almost
flicker-free.
2021-08-23 23:57:19 +02:00

47 lines
1.3 KiB
C++

#pragma once
#include <array>
#include "Animation.h"
#include "fasttrigon.h"
class RgbwPsychedelicAnimation : public Animation
{
public:
typedef std::array<int32_t, 4> rgbw_val_array;
RgbwPsychedelicAnimation(Fader *fader,
const rgbw_val_array &move_speeds = {2273, 2281, 2287, 2293},
const rgbw_val_array &tilt_speeds = {2297, 2309, 2311, 2333},
int32_t tilt_maxperiods = 3,
uint32_t move_speed_divider = 1024,
uint32_t tilt_speed_divider = 8192,
uint16_t brightness_scale = fasttrigon::SCALE/4); // max: fasttrigon::SCALE
void loop(uint64_t frame) override;
void stop(void) override
{
m_stopping = true;
}
void reset(void) override;
private:
bool m_stopping;
rgbw_val_array m_move_speeds;
rgbw_val_array m_tilt_speeds;
uint32_t m_moveSpeedDivider;
uint32_t m_tiltSpeedDivider;
uint16_t m_brightnessScale;
int32_t m_tilt_maxperiods;
rgbw_val_array m_move_phi;
rgbw_val_array m_tilt_phi;
int32_t m_moveOverflowInterval;
int32_t m_tiltOverflowInterval;
};