1#ifndef AUTOMATON_MODE_HPP
2#define AUTOMATON_MODE_HPP
6#include "src/modes/include/draw/grid_rule.hpp"
8#include "src/system/ext/random8.h"
63 ctx.state.grid.reset(ctx.lamp, first);
66 ctx.state.algeaStart = 0;
69 ctx.template set_config_bool<ConfigKeys::rampSaturates>(
true);
72 static void loop(
auto& ctx)
75 uint8_t mini = ctx.get_active_custom_ramp() / 4;
77 auto rng = [&](
auto p) LMBD_INLINE {
78 return random8(mini, maxi) < p;
83 auto& lamp = ctx.lamp;
86 auto cb = [&](
const auto& before,
auto& after) {
98 for (
int I = 0; I < after.size(); ++I)
121 after[random8(0, after.size())] =
starColor;
124 if (st.algeaStart == 0 && rng(
algeaFreq))
126 st.algeaPos = random8(2, after.size() - 2);
127 st.algeaStart = lamp.
now;
133 if (st.algeaStart && st.algeaStart + st.algeaLifetime > lamp.
now)
145 ctx.state.grid.template loop<false>(ctx, cb);
172 static void on_enter_mode(
auto& ctx)
185 ctx.state.grid.reset(ctx.lamp, first);
186 ctx.template set_config_bool<ConfigKeys::rampSaturates>(
true);
189 static void loop(
auto& ctx)
192 auto cb = [&](
const auto& before,
auto& after) {
193 draw::grid::wolframRule<90>(before, after);
197 ctx.state.grid.template loop<hasCustomRamp>(ctx, cb);
Modes implementing cellular automaton using "grid" tools.
Definition: automaton.hpp:11
modes::GroupFor< BubbleMode, SierpinskiMode > AutomatonModes
Storage for the Automaton modes.
Definition: automaton.hpp:205
static constexpr LMBD_INLINE uint32_t fromGrey(uint32_t w)
Return color (w, w, w) as a single uint32_t integer.
Definition: utils.hpp:48
static constexpr LMBD_INLINE uint32_t fromRGB(uint8_t r, uint8_t g, uint8_t b)
Return color (r, g, b) as a single uint32_t integer.
Definition: utils.hpp:24
@ ForestGreen
Definition: palettes.hpp:136
@ DarkBlue
Definition: palettes.hpp:110
@ Gold
Definition: palettes.hpp:139
GroupTy< std::tuple< Modes... > > GroupFor
Group together many different modes::BasicMode.
Definition: group_type.hpp:335
static constexpr N abs(const N a)
absolute of a number
Definition: utils.h:46
Parent object for all custom user modes.
Definition: mode_type.hpp:53
Definition: automaton.hpp:23
uint32_t algeaStart
time of the latest algae start
Definition: automaton.hpp:27
uint32_t algeaPos
X index of the algae.
Definition: automaton.hpp:31
GridTy grid
cellular automaton
Definition: automaton.hpp:25
uint32_t algeaLifetime
duration of the algae
Definition: automaton.hpp:29
Bubbles rising in the sea. The user ramp control the random generation.
Definition: automaton.hpp:18
static constexpr int algeaLength
(ms) +/- 1s average algea size
Definition: automaton.hpp:45
static constexpr int algeaFreq
0-255 how likely event is algea?
Definition: automaton.hpp:43
static constexpr bool hasCustomRamp
hint manager that we have a custom ramp
Definition: automaton.hpp:148
static constexpr auto starColor
color of ???
Definition: automaton.hpp:54
static constexpr auto algeaColor
color of the algea
Definition: automaton.hpp:53
static constexpr int eventFreq
0-255 how likely are events?
Definition: automaton.hpp:41
static constexpr auto waterColor
color of the water
Definition: automaton.hpp:52
static constexpr int starFreq
0-255 how likely event is star?
Definition: automaton.hpp:49
static void on_enter_mode(auto &ctx)
Definition: automaton.hpp:56
static constexpr int bubbleFreq
0-255 the more the less bubbles
Definition: automaton.hpp:37
static constexpr int minBubbleDist
0-5 min distance of bubbles?
Definition: automaton.hpp:39
static constexpr int algeaSwims
(ms) how fast algea ondulates
Definition: automaton.hpp:47
static constexpr int nbBubbles
0-10 max number of bubble per turn
Definition: automaton.hpp:35
Definition: automaton.hpp:157
static constexpr uint8_t renderBlurAmount
add more blur
Definition: automaton.hpp:161
static constexpr bool scrollSkewed
scroll the grid skewed (no "bubble" effect
Definition: automaton.hpp:159
Definition: automaton.hpp:167
GridTy grid
celullar automaton
Definition: automaton.hpp:169
Draw the famous Sierpinski triangle, with an old CCTV effect.
Definition: automaton.hpp:155
static constexpr bool hasCustomRamp
Hint manager that we have a custom ramp.
Definition: automaton.hpp:201
Define the rules for a line.
Definition: grid_rule.hpp:16
Implement a line-based grid pattern, update line per line.
Definition: grid_rule.hpp:49
std::array< uint32_t, width > LineTy
Type of a line array.
Definition: grid_rule.hpp:58
void LMBD_INLINE fill(uint32_t color, uint16_t start, uint16_t end)
(indexable) Fill lamp with target color, from start to end
Definition: lamp_type.hpp:786
volatile const uint32_t now
(physical) The "now" on milliseconds, updated just before loop.
Definition: lamp_type.hpp:1075