esp32-sk6812/src/Animation/ConnectingAnimation.cpp

32 lines
841 B
C++
Raw Normal View History

2019-12-02 22:42:31 +01:00
#include "fasttrigon.h"
#include "Animation/ConnectingAnimation.h"
ConnectingAnimation::ConnectingAnimation(Fader *fader)
2019-12-03 22:09:55 +01:00
: Animation(fader), m_stopping(false)
2019-12-02 22:42:31 +01:00
{}
void ConnectingAnimation::loop(uint64_t frame)
{
std::size_t nstrip = m_fader->strips();
2019-12-03 22:09:55 +01:00
uint8_t intensity = 0;
2019-12-02 22:42:31 +01:00
if(frame == 0) {
m_fader->fade_color(Fader::Color{0, 0, 0, 0});
}
for(std::size_t strip = 0; strip < nstrip; strip++) {
intensity = (FASTTRIGON_8BIT(fasttrigon::fastsin(1 * frame * fasttrigon::LUT_SIZE / 60 + fasttrigon::LUT_SIZE*3/4)) + 127) / 4;
2019-12-02 22:42:31 +01:00
Fader::Color c;
c.b = intensity;
m_fader->set_color(strip, 0, c);
}
2019-12-03 22:09:55 +01:00
// stop the animation at maximum level for smooth transition to ConnectionEstablishedAnimation
if(m_stopping && intensity == 63) {
2019-12-03 22:09:55 +01:00
m_running = false;
}
2019-12-02 22:42:31 +01:00
}