FastLED 3.9.15
Loading...
Searching...
No Matches
simple.h
Go to the documentation of this file.
1
2
3/*
4This demo is best viewed using the FastLED compiler.
5
6Windows/MacOS binaries: https://github.com/FastLED/FastLED/releases
7
8Python
9
10Install: pip install fastled
11Run: fastled <this sketch directory>
12This will compile and preview the sketch in the browser, and enable
13all the UI elements you see below.
14*/
15
16#include <Arduino.h>
17#include <FastLED.h>
18
19#include "fl/gfx/draw_visitor.h"
20#include "fl/math/math.h"
21#include "fl/gfx/raster.h"
22#include "fl/math/time_alpha.h"
23#include "fl/ui/ui.h"
24#include "fl/gfx/xypath.h"
25#include "fl/fx/time.h"
26
27// Sketch.
28#include "src/wave.h"
29#include "src/xypaths.h"
30#include "fl/stl/function.h"
31
32
33#define HEIGHT 64
34#define WIDTH 64
35#define NUM_LEDS ((WIDTH) * (HEIGHT))
36#define IS_SERPINTINE true
37#define TIME_ANIMATION 1000 // ms
38
41fl::UITitle title("Simple control of an xy path");
42fl::UIDescription description("This is more of a test for new features.");
43
44// fl::UIButton trigger("My Trigger");
45fl::UISlider pointX("Point X", WIDTH / 2.0f, 0.0f, WIDTH - 1, 1.0f);
46fl::UISlider pointY("Point Y", HEIGHT / 2.0f, 0.0f, HEIGHT - 1, 1.0f);
47
48fl::UIButton button("second trigger");
49
50
51int x = 0;
52int y = 0;
53bool triggered = false;
54
55
56void setup() {
57 Serial.begin(115200);
58 auto screenmap = xyMap.toScreenMap();
59 screenmap.setDiameter(.2);
60 FastLED.addLeds<NEOPIXEL, 2>(leds, NUM_LEDS).setScreenMap(screenmap);
61
62}
63void loop() {
65 triggered = button.clicked();
66 if (triggered) {
67 FL_WARN("Triggered");
68 }
69 x = pointX.as_int();
70 y = pointY.as_int();
71 leds[xyMap(x, y)] = fl::CRGB(255, 0, 0);
72
73 FastLED.show();
74}
fl::XYMap xyMap
#define NUM_LEDS
fl::UIDescription description("Demo of the Animatrix effects. @author of fx is StefanPetrick")
fl::UITitle title("Animartrix")
fl::CRGB leds[NUM_LEDS]
fl::ScreenMap screenmap
int y
Definition simple.h:93
bool triggered
Definition simple.h:94
int x
Definition simple.h:92
#define IS_SERPINTINE
Definition simple.h:49
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS CFastLED FastLED
Global LED strip management instance.
void setup()
Definition simple.h:56
fl::UISlider pointY("Point Y", HEIGHT/2.0f, 0.0f, HEIGHT - 1, 1.0f)
fl::UISlider pointX("Point X", WIDTH/2.0f, 0.0f, WIDTH - 1, 1.0f)
fl::UIButton button("second trigger")
void loop()
Definition simple.h:63
#define WIDTH
#define HEIGHT
#define FL_WARN(X)
Definition log.h:276
fl::CRGB CRGB
Definition video.h:15
void clear(CRGB(&arr)[N])
Definition clear.h:12
fl::UIButton button("Button")
Representation of an 8-bit RGB pixel (Red, Green, Blue)
Definition crgb.h:38
#define Serial
Definition serial.h:304
Aggregator header for the fl/ui/ family of per-element UI types.