1#ifndef RAINBOW_SWIRL_MODE_HPP
2#define RAINBOW_SWIRL_MODE_HPP
24 static void on_enter_mode(
auto& ctx)
27 static constexpr uint32_t animationPeriod_ms = 5000;
28 ctx.state.increment = (UINT16_MAX / (animationPeriod_ms / ctx.lamp.frameDurationMs));
29 ctx.state.firstPixelHue = 0;
32 static void loop(
auto& ctx)
34 const uint16_t firstPixelColor = ctx.state.firstPixelHue;
35 const float multiplier = UINT16_MAX /
static_cast<float>(ctx.lamp.ledCount);
36 for (
size_t i = 0; i < ctx.lamp.ledCount; i++)
38 const uint16_t pixelHue = firstPixelColor + i * multiplier;
40 ctx.lamp.setPixelColor(i, color);
44 ctx.state.firstPixelHue += ctx.state.increment;
static constexpr LMBD_INLINE uint32_t fromAngleHue(uint16_t angleDegrees)
Given a 360 degrees angle, return a corresponding color as an integer.
Definition: utils.hpp:71
Basic "default" modes included with the hardware.
Definition: aurora.hpp:12
Define some useful color palettes, and tools to use them.
Parent object for all custom user modes.
Definition: mode_type.hpp:53
Definition: rainbow_swirl_mode.hpp:17
uint16_t firstPixelHue
hue of the first pixel of the strip
Definition: rainbow_swirl_mode.hpp:21
uint32_t increment
per loop increment
Definition: rainbow_swirl_mode.hpp:19
Display a rainbow that moves.
Definition: rainbow_swirl_mode.hpp:15