FastLED 3.9.15
Loading...
Searching...
No Matches
WasmScreenCoords.ino
Go to the documentation of this file.
1// @filter: (mem is large)
2
12
13#include <Arduino.h>
14#include <FastLED.h>
15
16
17#ifdef __EMSCRIPTEN__
18
19#include "fl/stl/vector.h"
20
21
22#include "fl/stl/json.h"
23#include "fl/stl/span.h"
24#include "fl/math/screenmap.h"
25#include "fl/math/math.h"
26
27using fl::vec2f;
28using fl::vector;
29
30
31#define LED_PIN 3
32#define BRIGHTNESS 96
33#define COLOR_ORDER GRB
34#define NUM_LEDS 256
35
38
39
40void make_map(int stepx, int stepy, int num, fl::vector<vec2f>* _map) {
41 float x = 0;
42 float y = 0;
43 fl::vector<vec2f>& map = *_map;
44 for (int16_t i = 0; i < num; i++) {
45 map.push_back(vec2f{x, y});
46 x += stepx;
47 y += stepy;
48 }
49}
50
51void setup() {
52 for (CRGB& c : leds) {
53 c = CRGB::Blue;
54 }
55 for (CRGB& c : leds2) {
56 c = CRGB::Red;
57 }
58 FastLED.setBrightness(255);
60 make_map(1, 1, NUM_LEDS, &map);
62
64 make_map(-1, -1, NUM_LEDS, &map2);
65 fl::ScreenMap screenmap2 = fl::ScreenMap(map2.data(), map2.size());
66
67 FastLED.addLeds<WS2811, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS)
68 .setScreenMap(screenmap);
69
70 FastLED.addLeds<WS2811, LED_PIN+1, COLOR_ORDER>(leds2, NUM_LEDS)
71 .setScreenMap(screenmap2);
72}
73
74void loop() {
75 FastLED.show();
76}
77
78
79#else
80
81void setup() {
82 Serial.begin(115200);
83 Serial.println("setup");
84}
85
86void loop() {
87 Serial.println("loop");
88}
89
90#endif // __EMSCRIPTEN__
void setup()
void loop()
#define COLOR_ORDER
#define NUM_LEDS
fl::CRGB leds[NUM_LEDS]
#define LED_PIN
fl::ScreenMap screenmap
int y
Definition simple.h:93
int x
Definition simple.h:92
CRGB leds2[lengths[RedStrip]]
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS CFastLED FastLED
Global LED strip management instance.
fl::size size() const
Definition rbtree.h:1117
fl::size size() const FL_NOEXCEPT
T * data() FL_NOEXCEPT
Definition vector.h:619
fl::CRGB CRGB
Definition crgb.h:25
FastLED's Elegant JSON Library: fl::json
MapRedBlackTree< Key, T, Compare, fl::allocator_slab< char > > map
Definition map.h:283
vec2< float > vec2f
Definition geometry.h:333
@ Red
<div style='background:#FF0000;width:4em;height:4em;'></div>
Definition crgb.h:622
@ Blue
<div style='background:#0000FF;width:4em;height:4em;'></div>
Definition crgb.h:512
#define Serial
Definition serial.h:304