6#include "src/system/ext/math8.h"
7#include "src/system/ext/noise.h"
34 static void on_enter_mode(
auto& ctx)
36 static const uint16_t adjScale = lmpd_map<uint16_t>(ctx.lamp.maxWidth + 1, 8, 64, 310, 63);
38 static constexpr uint8_t scale = 255;
39 static constexpr uint8_t speed = 128;
41 ctx.state.scale = lmpd_map<uint16_t>(scale, 0, 255, 30, adjScale);
42 ctx.state.speed = lmpd_map<byte>(speed, 0, 255, 128, 16);
47 static void loop(
auto& ctx)
49 static const float adjustHeight = lmpd_map<float>(ctx.lamp.maxHeight, 8, 32, 28, 12);
50 static constexpr float halfHeight = (float)ctx.lamp.maxHeight / 2.0f;
52 const float _speedDivider = 1.0f /
static_cast<float>(ctx.state.speed);
53 const auto& palette = ctx.state.palette;
55 uint32_t step = ctx.state.step;
56 for (
int x = 0; x <= ctx.lamp.maxWidth; x++)
58 const int scaledX = x * ctx.state.scale;
59 for (
int y = 0; y <= ctx.lamp.maxHeight; y++, step++)
62 qsub8(noise8::inoise((step % 2) + scaledX, y * 16 + step % 16, step * _speedDivider),
63 fabsf(halfHeight - (
float)y) * adjustHeight),
65 ctx.lamp.setPixelColorXY(x, y, color);
70 ctx.state.step = step;
static constexpr uint32_t from_palette(UIntTy index, const PaletteTy &palette, uint8_t brightness=255)
Return a color from a palette.
Definition: palettes.hpp:504
std::array< uint32_t, 16 > PaletteTy
Palette types.
Definition: palettes.hpp:18
static constexpr PaletteTy PaletteAuroraColors
Palette of green yellow colors.
Definition: palettes.hpp:432
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: aurora.hpp:23
uint32_t step
step of the animation
Definition: aurora.hpp:29
uint8_t speed
speed of change
Definition: aurora.hpp:27
colors::PaletteTy palette
color palette used
Definition: aurora.hpp:31
uint8_t scale
sclae of the aurora
Definition: aurora.hpp:25
Aurora borealis effect. By: Kostyantyn Matviyevskyy. https://editor.soulmatelights....
Definition: aurora.hpp:21