FastLED 3.9.15
Loading...
Searching...
No Matches
WasmScreenCoords.ino
Go to the documentation of this file.
1
10
11#include <Arduino.h>
12#include <FastLED.h>
13
14
15#ifdef __EMSCRIPTEN__
16
17#include "fl/vector.h"
18
19
20#include "fl/json.h"
21#include "fl/slice.h"
22#include "fl/screenmap.h"
23#include "fl/math_macros.h"
24
25using fl::vec2f;
26using fl::vector;
27
28
29#define LED_PIN 3
30#define BRIGHTNESS 96
31#define COLOR_ORDER GRB
32#define NUM_LEDS 256
33
35CRGB leds2[NUM_LEDS];
36
37
38void make_map(int stepx, int stepy, int num, fl::vector<vec2f>* _map) {
39 float x = 0;
40 float y = 0;
41 fl::vector<vec2f>& map = *_map;
42 for (int16_t i = 0; i < num; i++) {
43 map.push_back(vec2f{x, y});
44 x += stepx;
45 y += stepy;
46 }
47}
48
49void setup() {
50 for (CRGB& c : leds) {
51 c = CRGB::Blue;
52 }
53 for (CRGB& c : leds2) {
54 c = CRGB::Red;
55 }
56 FastLED.setBrightness(255);
58 make_map(1, 1, NUM_LEDS, &map);
59 fl::ScreenMap screenmap = fl::ScreenMap(map.data(), map.size());
60
62 make_map(-1, -1, NUM_LEDS, &map2);
63 fl::ScreenMap screenmap2 = fl::ScreenMap(map2.data(), map2.size());
64
66 .setScreenMap(screenmap);
67
68 FastLED.addLeds<WS2811, LED_PIN+1, COLOR_ORDER>(leds2, NUM_LEDS)
69 .setScreenMap(screenmap2);
70}
71
72void loop() {
73 FastLED.show();
74}
75
76
77#else
78
79void setup() {
80 Serial.begin(115200);
81 Serial.println("setup");
82}
83
84void loop() {
85 Serial.println("loop");
86}
87
88#endif // __EMSCRIPTEN__
CRGB leds[NUM_LEDS]
#define NUM_LEDS
int y
Definition simple.h:93
int x
Definition simple.h:92
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS CFastLED FastLED
Global LED strip management instance.
Definition FastLED.cpp:74
central include file for FastLED, defines the CFastLED class/object
void setup()
void loop()
#define COLOR_ORDER
Definition advanced.h:42
#define LED_PIN
Definition advanced.h:40
WS2811 controller class.
Definition FastLED.h:266
fl::size size() const
Definition vector.h:545
void push_back(const T &value)
Definition vector.h:552
FastLED's Elegant JSON Library: fl::Json
vec2< float > vec2f
Definition geometry.h:333
HeapVector< T, Allocator > vector
Definition vector.h:1214
@ Blue
<div style='background:#0000FF;width:4em;height:4em;'></div>
Definition crgb.h:569
@ Red
<div style='background:#FF0000;width:4em;height:4em;'></div>
Definition crgb.h:679
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:86