1#ifndef DOUBLE_SIDE_FILL_MODE_HPP
2#define DOUBLE_SIDE_FILL_MODE_HPP
28 static void on_enter_mode(
auto& ctx)
30 ctx.state.progress = 1.0;
34 static void loop(
auto& ctx)
36 static constexpr float iteration = ctx.lamp.frameDurationMs /
static_cast<float>(
animationTiming);
37 ctx.state.progress += iteration;
39 const float prog = std::min<float>(ctx.state.progress, 1.0);
41 const size_t endIndex = prog * (ctx.lamp.ledCount / 2.0);
42 ctx.lamp.fill(ctx.state.color, 0, endIndex);
44 const size_t startIndex = ctx.lamp.ledCount / 2.0 + (1.0 - prog) * ctx.lamp.ledCount / 2.0;
45 ctx.lamp.fill(ctx.state.color, startIndex, ctx.lamp.ledCount);
47 if (ctx.state.progress >= 1.0)
49 ctx.state.progress = 0.0;
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: double_side_fill_mode.hpp:21
float progress
animation progress, between 0 and 1
Definition: double_side_fill_mode.hpp:23
uint32_t color
actual display color
Definition: double_side_fill_mode.hpp:25
Flll the lamp from both sides at the same time, with random colors.
Definition: double_side_fill_mode.hpp:14
static constexpr uint32_t animationTiming
Lenght of the animation.
Definition: double_side_fill_mode.hpp:18
static constexpr float randomVariation
random color variation between fills
Definition: double_side_fill_mode.hpp:16