1#ifndef COLOR_WIPE_MODE_HPP
2#define COLOR_WIPE_MODE_HPP
30 static void on_enter_mode(
auto& ctx)
32 ctx.state.step =
true;
33 ctx.state.progress = 0.0;
37 static void loop(
auto& ctx)
39 static constexpr float iteration = ctx.lamp.frameDurationMs /
static_cast<float>(
animationTiming);
41 ctx.state.progress += iteration;
42 const float prog = std::min<float>(ctx.state.progress, 1.0);
47 const size_t endIndex = prog * ctx.lamp.ledCount;
48 ctx.lamp.fill(ctx.state.color, 0, endIndex);
53 const size_t startIndex = (1.0f - prog) * ctx.lamp.ledCount;
54 ctx.lamp.fill(ctx.state.color, startIndex, ctx.lamp.ledCount);
57 if (ctx.state.progress >= 1.0)
59 ctx.state.progress = 0.0;
60 ctx.state.step = not ctx.state.step;
Basic "default" modes included with the hardware.
Definition: aurora.hpp:12
uint32_t get_random_complementary_color(const uint32_t color, const float tolerance)
Compute the complementary color of the given color, with a random variation.
Definition: utils.cpp:47
Parent object for all custom user modes.
Definition: mode_type.hpp:53
Definition: color_wipe_mode.hpp:21
bool step
true wipe up, false wipe down
Definition: color_wipe_mode.hpp:25
uint32_t color
actual color to display
Definition: color_wipe_mode.hpp:27
float progress
Between 0 and 1, progress.
Definition: color_wipe_mode.hpp:23
Wipe a color from one side to the other, with random color variations.
Definition: color_wipe_mode.hpp:14
static constexpr uint32_t animationTiming
Lenght of the animation, in milliseconds.
Definition: color_wipe_mode.hpp:18
static constexpr float randomVariation
Random variation of the color between animation loops.
Definition: color_wipe_mode.hpp:16