JBWOPR
JBWoprSongEffect Class Reference

Base class for song effects. More...

#include <jbwopreffects.h>

Inheritance diagram for JBWoprSongEffect:
JBWoprEffectBase JBWoprNokiaTuneEffect JBWoprTheRickEffect

Classes

struct  Note
 Note struct. More...

Public Member Functions

 JBWoprSongEffect (JBWoprDevice *woprBoard, const std::vector< Note > *song, uint32_t tempo=114, uint32_t duration=-1, const std::string &name=JBWOPR_EFFECT_NAME_SONG)
 Constructor.
void start () override
 Start effect.
void loop () override
 Run loop.
virtual void setSong (const std::vector< Note > *song)
 Set melody.
virtual void setTempo (uint32_t tempo)
 Set tempo.
Public Member Functions inherited from JBWoprEffectBase
 JBWoprEffectBase (JBWoprDevice *woprDevice, uint32_t duration=-1, std::string name=JBWOPR_EFFECT_NAME_BASE)
 Constructor.
virtual std::string getName ()
 Get name of effect.
virtual void stop ()
 Stop effect.
bool isRunning () const
 Check if effect is running.
uint32_t getDuration () const
 Set duration of effect.

Protected Attributes

const std::vector< Note > * _song = nullptr
 Melody.
uint32_t _step = 0
 Current step.
uint32_t _tempo = 114
 Tempo.
uint32_t _wholeNote = (60000 * 4) / _tempo
 Whole note duration.
bool _done = false
 True if done.
Protected Attributes inherited from JBWoprEffectBase
JBWoprDevice_woprDevice
 JBWoprDevice instance.
std::string _name
 Name of effect.
bool _isRunning = false
 True if effect is running.
bool _done = true
 True if effect is done, waiting for duration to end.
uint32_t _duration = -1
 Duration of effect in milliseconds.
uint32_t _startTime = 0
 Start time of effect in milliseconds.
uint32_t _nextTick = 0
 Next tick time in milliseconds.

Additional Inherited Members

Protected Member Functions inherited from JBWoprEffectBase
void _displayText (const std::string &text, JBTextAlignment alignment=JBTextAlignment::LEFT)
 Display text on raw display.

Detailed Description

Base class for song effects.

Constructor & Destructor Documentation

◆ JBWoprSongEffect()

JBWoprSongEffect::JBWoprSongEffect ( JBWoprDevice * woprBoard,
const std::vector< Note > * song,
uint32_t tempo = 114,
uint32_t duration = -1,
const std::string & name = JBWOPR_EFFECT_NAME_SONG )
explicit

Constructor.

Parameters
woprBoardJBWoprDevice instance
melodyMelody
tempoTempo
durationDuration of effect (after it is done) in milliseconds, default is -1 (infinite)
nameName of effect, default is JBWOPR_EFFECT_NAME_SONG

Member Function Documentation

◆ loop()

void JBWoprSongEffect::loop ( )
overridevirtual

Run loop.

Reimplemented from JBWoprEffectBase.

◆ setSong()

void JBWoprSongEffect::setSong ( const std::vector< Note > * song)
virtual

Set melody.

Parameters
melodyMelody

◆ setTempo()

void JBWoprSongEffect::setTempo ( uint32_t tempo)
virtual

Set tempo.

Parameters
tempoTempo

Reimplemented in JBWoprNokiaTuneEffect, and JBWoprTheRickEffect.

◆ start()

void JBWoprSongEffect::start ( )
overridevirtual

Start effect.

Reimplemented from JBWoprEffectBase.


The documentation for this class was generated from the following files: