Lamp-Da 0.1
A compact lantern project
Loading...
Searching...
No Matches
fixed_modes.hpp
Go to the documentation of this file.
1#ifndef FIXED_MODES_H
2#define FIXED_MODES_H
3
5
7
9
10namespace lampda {
11
12namespace modes {
13
14namespace fixed {
15
21template<bool isStep = false, uint32_t rampUpdateLenght_ms = 55, bool shouldSaturateRamp = false> struct PaletteMode :
22 public modes::BasicMode
23{
24 static constexpr uint8_t dissolveBufferId = 0;
25 inline static anims::fadeout::GravityDissolve<dissolveBufferId> sunsetAnimation =
27
28 static void on_enter_mode(auto& ctx)
29 {
30 // saturate the ramp
31 ctx.template set_config_bool<ConfigKeys::rampSaturates>(shouldSaturateRamp);
32 //
33 ctx.template set_config_bool<ConfigKeys::customRampAnimEffect>(false);
34 // this ramps should be slow
35 ctx.template set_config_u32<ConfigKeys::customRampStepSpeedMs>(rampUpdateLenght_ms);
36
37 sunsetAnimation.reset(ctx);
38
39 // display a ramp
40 ctx.overlay_animate_ramp(255, ctx.state.palette, 1000);
41 }
42
43 static void loop(auto& ctx)
44 {
45 // clear previous animation
46 ctx.lamp.clear();
47
48 const uint8_t customRamp = ctx.get_active_custom_ramp();
49 uint32_t color = modes::colors::from_palette<not shouldSaturateRamp>(
50 // if palette is stepped, remove all intermediate colors
51 static_cast<uint8_t>(isStep ? (customRamp >> 4) << 4 : customRamp),
52 // not stepped, allow interpolation
53 ctx.state.palette);
54
55 // fill, with mask
56 ctx.lamp.fill(color, ctx.lamp.template getTempBuffer<dissolveBufferId>());
57
58 // update animation
59 sunsetAnimation.loop(ctx, color);
60 }
61
63 static void sunset_update(auto& ctx, float progress) { sunsetAnimation.update_depop_rate(ctx, progress); }
64
66 static constexpr bool hasCustomRamp = true;
68 static constexpr bool hasSunsetAnimation = true;
69};
70
74struct PaletteRainbowMode : public PaletteMode<false>
75{
76 struct StateTy
77 {
80 };
81};
82
86struct PaletteBlackBodyMode : public PaletteMode<false, 30, true>
87{
88 struct StateTy
89 {
92 };
93};
94
98struct PalettePartyMode : public PaletteMode<false>
99{
100 struct StateTy
101 {
104 };
105};
106
110struct PaletteForestMode : public PaletteMode<false>
111{
112 struct StateTy
113 {
116 };
117};
118
122struct PaletteOceanMode : public PaletteMode<false>
123{
124 struct StateTy
125 {
128 };
129};
130
134struct PalettePapiMode : public PaletteMode<true>
135{
136 struct StateTy
137 {
140 };
141};
142
143} // namespace fixed
144
149
150} // namespace modes
151} // namespace lampda
152
153#endif
Define some animations to fade out modes.
static constexpr PaletteTy PaletteBlackBodyColors
Black body radiation, with the high end changed to be nicer.
Definition: palettes.hpp:396
static constexpr PaletteTy PalettePartyColors
basically, HSV with no green. looks better when lighing people
Definition: palettes.hpp:378
static constexpr PaletteTy PaletteOceanColors
Ocean colors, blues and whites.
Definition: palettes.hpp:306
std::array< uint32_t, 16 > PaletteTy
Palette types.
Definition: palettes.hpp:18
static constexpr PaletteTy PaletteForestColors
Forest colors, greens.
Definition: palettes.hpp:342
static constexpr PaletteTy PaletteRainbowColors
HSV Rainbow.
Definition: palettes.hpp:360
static constexpr PaletteTy PalettePapiColors
Palette of nice handpicked colors.
Definition: palettes.hpp:450
modes::GroupFor< fixed::PalettePartyMode, fixed::PaletteForestMode, fixed::PaletteOceanMode > MiscFixedModes
Fixed palette colors modes.
Definition: fixed_modes.hpp:148
modes::GroupFor< fixed::PaletteBlackBodyMode, fixed::PaletteRainbowMode, fixed::PalettePapiMode > FixedModes
Fixed modes groups.
Definition: fixed_modes.hpp:146
GroupTy< std::tuple< Modes... > > GroupFor
Group together many different modes::BasicMode.
Definition: group_type.hpp:335
Program scope.
Definition: control_fixed_modes.hpp:12
Define some useful color palettes, and tools to use them.
Parent object for all custom user modes.
Definition: mode_type.hpp:53
Make an animation disapear with gravity.
Definition: fadeout.hpp:20
void update_depop_rate(auto &ctx, const float progress)
Update the drop rate.
Definition: fadeout.hpp:72
static constexpr modes::colors::PaletteTy palette
Color palette to use.
Definition: fixed_modes.hpp:91
BlackBody temperature fixed colors ramp mode.
Definition: fixed_modes.hpp:87
static constexpr modes::colors::PaletteTy palette
Color palette to use.
Definition: fixed_modes.hpp:115
Forest fixed colors ramp mode.
Definition: fixed_modes.hpp:111
Single-color mode for indexable strips with palette ramp.
Definition: fixed_modes.hpp:23
static void sunset_update(auto &ctx, float progress)
Sunset timer will drop pixels downward, and never display them again.
Definition: fixed_modes.hpp:63
static constexpr bool hasSunsetAnimation
sunset animation on the fixed modes
Definition: fixed_modes.hpp:68
static constexpr bool hasCustomRamp
hint manager to save our custom ramp
Definition: fixed_modes.hpp:66
static constexpr modes::colors::PaletteTy palette
Color palette to use.
Definition: fixed_modes.hpp:127
Ocean fixed colors ramp mode.
Definition: fixed_modes.hpp:123
Definition: fixed_modes.hpp:137
static constexpr modes::colors::PaletteTy palette
Color palette to use.
Definition: fixed_modes.hpp:139
Special colored palette step mode. Ideal to set a target prefered color.
Definition: fixed_modes.hpp:135
static constexpr modes::colors::PaletteTy palette
Color palette to use.
Definition: fixed_modes.hpp:103
Party fixed colors ramp mode.
Definition: fixed_modes.hpp:99
static constexpr modes::colors::PaletteTy palette
Color palette to use.
Definition: fixed_modes.hpp:79
Rainbow fixed colors ramp mode.
Definition: fixed_modes.hpp:75