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.
5Install: pip install fastled
6Run: fastled <this sketch directory>
7This will compile and preview the sketch in the browser, and enable
8all the UI elements you see below.
9*/
10
11#include <Arduino.h>
12#include <FastLED.h>
13
14#include "fl/draw_visitor.h"
15#include "fl/math_macros.h"
16#include "fl/raster.h"
17#include "fl/time_alpha.h"
18#include "fl/ui.h"
19#include "fl/xypath.h"
20#include "fx/time.h"
21
22// Sketch.
23#include "src/wave.h"
24#include "src/xypaths.h"
25#include "fl/function.h"
26
27using namespace fl;
28
29#define HEIGHT 64
30#define WIDTH 64
31#define NUM_LEDS ((WIDTH) * (HEIGHT))
32#define IS_SERPINTINE true
33#define TIME_ANIMATION 1000 // ms
34
37UITitle title("Simple control of an xy path");
38UIDescription description("This is more of a test for new features.");
39
40// UIButton trigger("My Trigger");
41UISlider pointX("Point X", WIDTH / 2.0f, 0.0f, WIDTH - 1, 1.0f);
42UISlider pointY("Point Y", HEIGHT / 2.0f, 0.0f, HEIGHT - 1, 1.0f);
43
44UIButton button("second trigger");
45
46
47int x = 0;
48int y = 0;
49bool triggered = false;
50
51
52void setup() {
53 Serial.begin(115200);
54 auto screenmap = xyMap.toScreenMap();
55 screenmap.setDiameter(.2);
56 FastLED.addLeds<NEOPIXEL, 2>(leds, NUM_LEDS).setScreenMap(screenmap);
57
58}
59void loop() {
61 triggered = button.clicked();
62 if (triggered) {
63 FASTLED_WARN("Triggered");
64 }
65 x = pointX.as_int();
66 y = pointY.as_int();
67 leds[xyMap(x, y)] = CRGB(255, 0, 0);
68
69 FastLED.show();
70}
CRGB leds[NUM_LEDS]
Definition Apa102.ino:11
#define NUM_LEDS
Definition Apa102.ino:6
int y
Definition Audio.ino:72
UITitle title("Simple control of an xy path")
#define WIDTH
Definition Audio.ino:33
bool triggered
Definition Audio.ino:73
int x
Definition Audio.ino:71
#define IS_SERPINTINE
Definition Audio.ino:35
UIDescription description("This is more of a test for new features.")
#define HEIGHT
Definition Audio.ino:32
XYMap xyMap(WIDTH, HEIGHT, false)
CFastLED FastLED
Global LED strip management instance.
Definition FastLED.cpp:58
central include file for FastLED, defines the CFastLED class/object
UIButton button("Trigger")
LED controller for WS2812 LEDs with GRB color order.
Definition FastLED.h:155
void clear(CRGB(&arr)[N])
Definition clear.h:8
Implements a simple red square effect for 2D LED grids.
Definition crgb.h:16
UISlider pointX("Point X", WIDTH/2.0f, 0.0f, WIDTH - 1, 1.0f)
void setup()
Definition simple.h:52
UISlider pointY("Point Y", HEIGHT/2.0f, 0.0f, HEIGHT - 1, 1.0f)
void loop()
Definition simple.h:59
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:55
#define FASTLED_WARN
Definition warn.h:7