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
8namespace lampda {
9
10namespace modes {
11
12namespace fixed {
13
19template<bool isStep = false, uint32_t rampUpdateLenght_ms = 55, bool shouldSaturateRamp = false> struct PaletteMode :
20 public modes::BasicMode
21{
22 static void on_enter_mode(auto& ctx)
23 {
24 // saturate the ramp
25 ctx.template set_config_bool<ConfigKeys::rampSaturates>(shouldSaturateRamp);
26 //
27 ctx.template set_config_bool<ConfigKeys::customRampAnimEffect>(false);
28 // this ramps should be slow
29 ctx.template set_config_u32<ConfigKeys::customRampStepSpeedMs>(rampUpdateLenght_ms);
30
31 // display a ramp
32 ctx.overlay_animate_ramp(255, ctx.state.palette, 1000);
33 }
34
35 static void loop(auto& ctx)
36 {
37 // clear previous animation
38 ctx.lamp.clear();
39
40 const uint8_t customRamp = ctx.get_active_custom_ramp();
41 uint32_t color = modes::colors::from_palette<not shouldSaturateRamp>(
42 // if palette is stepped, remove all intermediate colors
43 static_cast<uint8_t>(isStep ? (customRamp >> 4) << 4 : customRamp),
44 // not stepped, allow interpolation
45 ctx.state.palette);
46
47 // fill, with mask
48 ctx.lamp.fill(color);
49 }
50
52 static constexpr bool hasCustomRamp = true;
54 static constexpr bool hasSunsetAnimation = true;
55 static constexpr bool hasSunriseAnimation = true;
56 // Use the two internal gravity modes, so no need to define the callbacks
57 static constexpr bool usesSunsetGravityDissolveMode = true;
58 static constexpr bool usesSunriseGravityAppearMode = true;
59};
60
64struct PaletteRainbowMode : public PaletteMode<false>
65{
66 static uint8_t get_custom_ramp_default_value(auto& ctx)
67 {
68 // start with pink
69 return 218;
70 }
71
72 struct StateTy
73 {
76 };
77};
78
82struct PaletteBlackBodyMode : public PaletteMode<false, 30, true>
83{
84 struct StateTy
85 {
88 };
89};
90
94struct PalettePartyMode : public PaletteMode<false>
95{
96 struct StateTy
97 {
100 };
101};
102
106struct PaletteForestMode : public PaletteMode<false>
107{
108 struct StateTy
109 {
112 };
113};
114
118struct PaletteOceanMode : public PaletteMode<false>
119{
120 struct StateTy
121 {
124 };
125};
126
130struct PalettePapiMode : public PaletteMode<true>
131{
132 static uint8_t get_custom_ramp_default_value(auto& ctx)
133 {
134 // start with cyan
135 return 35;
136 }
137
138 struct StateTy
139 {
142 };
143};
144
145} // namespace fixed
146
151
152} // namespace modes
153} // namespace lampda
154
155#endif
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:150
modes::GroupFor< fixed::PaletteBlackBodyMode, fixed::PaletteRainbowMode, fixed::PalettePapiMode > FixedModes
Fixed modes groups.
Definition: fixed_modes.hpp:148
GroupTy< std::tuple< Modes... > > GroupFor
Group together many different modes::BasicMode.
Definition: group_type.hpp:386
Program scope.
Definition: control_fixed_modes.hpp:14
Define some useful color palettes, and tools to use them.
Parent object for all custom user modes.
Definition: mode_type.hpp:53
static constexpr modes::colors::PaletteTy palette
Color palette to use.
Definition: fixed_modes.hpp:87
BlackBody temperature fixed colors ramp mode.
Definition: fixed_modes.hpp:83
static constexpr modes::colors::PaletteTy palette
Color palette to use.
Definition: fixed_modes.hpp:111
Forest fixed colors ramp mode.
Definition: fixed_modes.hpp:107
Single-color mode for indexable strips with palette ramp.
Definition: fixed_modes.hpp:21
static constexpr bool hasSunsetAnimation
sunset & sunrise animation on the fixed modes
Definition: fixed_modes.hpp:54
static constexpr bool hasCustomRamp
hint manager to save our custom ramp
Definition: fixed_modes.hpp:52
static constexpr modes::colors::PaletteTy palette
Color palette to use.
Definition: fixed_modes.hpp:123
Ocean fixed colors ramp mode.
Definition: fixed_modes.hpp:119
Definition: fixed_modes.hpp:139
static constexpr modes::colors::PaletteTy palette
Color palette to use.
Definition: fixed_modes.hpp:141
Special colored palette step mode. Ideal to set a target prefered color.
Definition: fixed_modes.hpp:131
static constexpr modes::colors::PaletteTy palette
Color palette to use.
Definition: fixed_modes.hpp:99
Party fixed colors ramp mode.
Definition: fixed_modes.hpp:95
static constexpr modes::colors::PaletteTy palette
Color palette to use.
Definition: fixed_modes.hpp:75
Rainbow fixed colors ramp mode.
Definition: fixed_modes.hpp:65