/** * @file Macro.h * @author Gustice * @brief Predefined effect macros * * @copyright Copyright (c) 2024 */ #pragma once #include "Color.hpp" #include "Waveform.hpp" #include #include namespace Effect { /// Collection of process values to maintain processing state machine struct StepProcessVars { /// @brief Reference of current color const Color &pCurentColor; /// @brief Number of color entries uint8_t ColorLen; /// @brief Idle value for intensity uint8_t IdleIntensity; /// @brief Full value for intensity uint8_t FullIntensity; /// @brief Dynamic range for effects uint8_t DynamicRange; /// @brief Index in current waveform uint16_t waveIdx; /// @brief Reference to processed waveform const WaveForm_t *const pWave; }; /** * @brief Effect implementation for State-Machine * @details State-Machine invokes referred effect-implementation during processing */ typedef Color (*EffectImplementation)(StepProcessVars &pcsParam); /** * @brief Definition of Effect-Macro */ struct Macro_t { /// @brief Effect type const EffectImplementation pImplementation; /// @brief Effect duration waveforms will be compressed / stretched to fit the duration const uint8_t Duration; /// @brief Next SubEffect const int8_t Next; /// @brief waveform reference const WaveForm_t *pWave = emptyWave; /// @brief Full-Scale-intensity const uint8_t FsIntensity; /// @brief Num of Repeats const int8_t Repeats; Macro_t(uint8_t duration, int8_t next, EffectImplementation state, uint8_t intensity, int8_t repeats = 0) : pImplementation(state), Duration(duration), Next(next), FsIntensity(intensity), Repeats(repeats) {} Macro_t(uint8_t duration, int8_t next, WaveForm_t const *wave, EffectImplementation state, uint8_t intensity, int8_t repeats = 0) : pImplementation(state), Duration(duration), Next(next), pWave(wave), FsIntensity(intensity), Repeats(repeats) {} private: /// @brief Null-pointer to represent no change in color static constexpr Color *pOldColor = nullptr; /// @brief Null-pointer to represent no actual waveform-representation static constexpr WaveForm_t *pNoWave = nullptr; /// @brief Default implemented Waveform with no profile static const constexpr WaveForm_t *emptyWave = &EmptyWave; }; using Macro = std::vector; /// @brief Dark - Nothing to see here extern const Macro macDark; /// @brief Continuous idle extern const Macro macIdle; /// @brief Continuous flicker extern const Macro macStartFlicker; /// @brief Smooth turn on and then remaining idle extern const Macro macStartIdle; /// @brief Smooth turn on to full color extern const Macro macStartFull; /// @brief Slow pulse starting from idle intensity. Appears like breathing extern const Macro macStdPulse; /// @brief Short pulses starting from idle intensity. Appears nervously. extern const Macro macNervousPulse; } // namespace Effect