-
-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy path_TEMPLATE.h
More file actions
65 lines (60 loc) · 3.1 KB
/
Copy path_TEMPLATE.h
File metadata and controls
65 lines (60 loc) · 3.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// SPDX-License-Identifier: CC-BY-SA-4.0
// Pattern: <Name>
// Author: <handle>
// Source: <url> (optional)
// Lineage: original (or "remixed from @someone's ...")
// Generated from web/src/lib/presets/<file>.ts (the JS pattern is the source of truth)
//
// To make a new pattern, copy this file, rename the namespace, and register it
// in pattern_registry.h:
// custom<N>.h -> sketch ROOT (your patterns; reusable slots, editable as IDE tabs)
// presets/preset_<name>.h -> presets/ subfolder (curated; change includes to "../src/...")
// The includes below are the ROOT form (for custom patterns).
#pragma once
#include <Arduino.h>
#include "config.h"
#include "src/core_display.h"
#include "src/core_encoders.h"
#include "src/core_canvas.h"
// Conditional — include only when actually used:
// #include "src/core_math.h" // PFMath:: fastSin/fastCos, fastAtan2, buildSinLUT, lerp, fract
// #include "src/core_color.h" // PFColor:: hsvToRgb, buildPowLUT, ColorStop, sampleRamp
// #include "src/core_noise.h" // PFNoise:: cellHash, valueNoise2D, perlin2D, fractal2D
// #include "src/core_tables.h" // PFTables:: init, rT[]/thetaT[] — per-pixel radius/angle from center
// #include "src/core_mem.h" // PFMem:: allocFloats — REQUIRED for framebuffer-sized buffers: never
// // declare them as static arrays (they lock internal DRAM from boot);
// // allocate once in setup(): if (!buf) buf = PFMem::allocFloats(N);
namespace TemplatePattern {
const char* NAME = "Template";
const char* const KNOB_LABELS[4] = {"k1", "k2", "k3", "k4"};
void setup() {
// runs once on load
}
void update(float dt, const InputFrame& input) {
// input.knobDeltas[i] : per-frame change in detents — 1 detent, 1 step,
// no acceleration. Scale it by YOUR parameter's range rather than a
// habit constant: (max - min) / 48 makes one knob cross its whole range
// in two turns, which is what every generated pattern now does.
// input.btnPressed[i] : true only on the frame button i is pressed (edge)
// input.btnHeld[i] : true while button i is held (level) (i = 0..3)
}
void draw() {
// PANEL_RES_W/H come from config.h — change them there for a different
// panel, never here. If this pattern was composed for a grid that is NOT
// the panel's (a 64x128 portrait pattern, say), declare it instead:
//
// constexpr int FRAME_W = 64, FRAME_H = 128; // near the top
// PFCanvas::setFrame(FRAME_W, FRAME_H); // first line of draw()
// ...then loop FRAME_W/FRAME_H and pass those x,y straight to setPixel.
//
// The canvas maps the frame onto the panel (straight through, quarter
// turn, or centred). Never rotate the coordinates yourself, and don't use
// PFTables inside a declared frame — see README.md.
for (int y = 0; y < PANEL_RES_H; y++) {
for (int x = 0; x < PANEL_RES_W; x++) {
PFCanvas::setPixel(x, y, 0, 0, 0); // r,g,b 0..255
}
}
PFCanvas::present(); // required — must be the last line
}
} // namespace TemplatePattern