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 static uint8_t get_custom_ramp_default_value(auto& ctx)
77 {
78 // start with pink
79 return 218;
80 }
81
82 struct StateTy
83 {
86 };
87};
88
92struct PaletteBlackBodyMode : public PaletteMode<false, 30, true>
93{
94 struct StateTy
95 {
98 };
99};
100
104struct PalettePartyMode : public PaletteMode<false>
105{
106 struct StateTy
107 {
110 };
111};
112
116struct PaletteForestMode : public PaletteMode<false>
117{
118 struct StateTy
119 {
122 };
123};
124
128struct PaletteOceanMode : public PaletteMode<false>
129{
130 struct StateTy
131 {
134 };
135};
136
140struct PalettePapiMode : public PaletteMode<true>
141{
142 static uint8_t get_custom_ramp_default_value(auto& ctx)
143 {
144 // start with cyan
145 return 35;
146 }
147
148 struct StateTy
149 {
152 };
153};
154
155} // namespace fixed
156
161
162} // namespace modes
163} // namespace lampda
164
165#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:160
modes::GroupFor< fixed::PaletteBlackBodyMode, fixed::PaletteRainbowMode, fixed::PalettePapiMode > FixedModes
Fixed modes groups.
Definition: fixed_modes.hpp:158
GroupTy< std::tuple< Modes... > > GroupFor
Group together many different modes::BasicMode.
Definition: group_type.hpp:369
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:76
static constexpr modes::colors::PaletteTy palette
Color palette to use.
Definition: fixed_modes.hpp:97
BlackBody temperature fixed colors ramp mode.
Definition: fixed_modes.hpp:93
static constexpr modes::colors::PaletteTy palette
Color palette to use.
Definition: fixed_modes.hpp:121
Forest fixed colors ramp mode.
Definition: fixed_modes.hpp:117
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:133
Ocean fixed colors ramp mode.
Definition: fixed_modes.hpp:129
Definition: fixed_modes.hpp:149
static constexpr modes::colors::PaletteTy palette
Color palette to use.
Definition: fixed_modes.hpp:151
Special colored palette step mode. Ideal to set a target prefered color.
Definition: fixed_modes.hpp:141
static constexpr modes::colors::PaletteTy palette
Color palette to use.
Definition: fixed_modes.hpp:109
Party fixed colors ramp mode.
Definition: fixed_modes.hpp:105
static constexpr modes::colors::PaletteTy palette
Color palette to use.
Definition: fixed_modes.hpp:85
Rainbow fixed colors ramp mode.
Definition: fixed_modes.hpp:75