#ifndef PLASMA_YELLOW_H__ #define PLASMA_YELLOW_H__ #include #include "ILI9488_t3.h" #include "MathUtil.h" #include "BaseAnimation.h" const float PLASMA_YELLOW_SPEED = 0.02; const uint_fast8_t PLASMA_YELLOW_DITHER = 8; const uint_fast16_t PLASMA_YELLOW_MARGIN = 25; class PlasmaYellow : public BaseAnimation { public: PlasmaYellow() : BaseAnimation() {}; void init( ILI9488_t3 tft ); uint_fast16_t bgColor( void ); String title(); void perFrame( ILI9488_t3 tft, FrameParams frameParams ); private: float _phase = 0; uint_fast8_t _ditherY = 0; uint_fast16_t _bgColor; }; void PlasmaYellow::init( ILI9488_t3 tft ) { _bgColor = tft.color565( 0xff, 0xff, 0 ); } uint_fast16_t PlasmaYellow::bgColor(){ return _bgColor; } String PlasmaYellow::title() { return "PlasmaYellow"; } void PlasmaYellow::perFrame( ILI9488_t3 tft, FrameParams frameParams ) { int_fast16_t w = (int_fast16_t)tft.width(); int_fast16_t h = (int_fast16_t)tft.height(); _phase += frameParams.timeMult * PLASMA_YELLOW_SPEED; _ditherY = (_ditherY + 1) % PLASMA_YELLOW_DITHER; Point16 p0 = (Point16){ (int_fast16_t)(w/2 + (sin(_phase*0.57f)*(w/2-PLASMA_YELLOW_MARGIN) )), (int_fast16_t)(h/2 + (sin(_phase*0.23f)*(h/2-PLASMA_YELLOW_MARGIN) )) }; Point16 p1 = (Point16){ (int_fast16_t)(w/2 + (cos(_phase*0.78f)*(w/2-PLASMA_YELLOW_MARGIN) )), (int_fast16_t)(h/2 + (cos(_phase*0.42f)*(h/2-PLASMA_YELLOW_MARGIN) )) }; float audioPower = frameParams.audioMean; for( int_fast16_t x=0; x> 5) & 0xff, 0xff, audioPower ); if( bright > 0x7f ) bright = 0xff - bright; bright <<= 2; uint_fast16_t color = tft.color565( bright, bright, 0 ); tft.drawFastHLine( x, y, PLASMA_YELLOW_DITHER, color ); } } } #endif