FastLED 3.9.7
Loading...
Searching...
No Matches
WasmScreenCoords.ino
Go to the documentation of this file.
1
9
10
11// printf
12#include <stdio.h>
13#include <string>
14#include <vector>
15
16#include <FastLED.h>
17#include "fl/json.h"
18#include "fl/slice.h"
19#include "fl/screenmap.h"
20#include "fl/math_macros.h"
21
22
23
24#define LED_PIN 3
25#define BRIGHTNESS 96
26#define COLOR_ORDER GRB
27#define NUM_LEDS 256
28
29CRGB leds[NUM_LEDS];
30CRGB leds2[NUM_LEDS];
31
32
33void make_map(int stepx, int stepy, int num, std::vector<pair_xy_float>* _map) {
34 float x = 0;
35 float y = 0;
36 std::vector<pair_xy_float>& map = *_map;
37 for (int16_t i = 0; i < num; i++) {
38 map.push_back(pair_xy_float{x, y});
39 x += stepx;
40 y += stepy;
41 }
42}
43
44void setup() {
45 for (CRGB& c : leds) {
46 c = CRGB::Blue;
47 }
48 for (CRGB& c : leds2) {
49 c = CRGB::Red;
50 }
52 std::vector<pair_xy_float> map;
53 make_map(1, 1, NUM_LEDS, &map);
54 ScreenMap screenmap = ScreenMap(map.data(), map.size());
55
56 std::vector<pair_xy_float> map2;
57 make_map(-1, -1, NUM_LEDS, &map2);
58 ScreenMap screenmap2 = ScreenMap(map2.data(), map2.size());
59
60 FastLED.addLeds<WS2811, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS)
61 .setScreenMap(screenmap);
62
63 FastLED.addLeds<WS2811, LED_PIN+1, COLOR_ORDER>(leds2, NUM_LEDS)
64 .setScreenMap(screenmap2);
65}
66
67void loop() {
68 FastLED.show();
69}
70
71
CFastLED FastLED
Global LED strip management instance.
Definition FastLED.cpp:45
central include file for FastLED, defines the CFastLED class/object
void setBrightness(uint8_t scale)
Set the global brightness scaling.
Definition FastLED.h:723
void show(uint8_t scale)
Update all our controllers with the current led colors, using the passed in brightness.
Definition FastLED.cpp:94
static CLEDController & addLeds(CLEDController *pLed, struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
Add a CLEDController instance to the world.
Definition FastLED.cpp:79
WS2811 controller class.
Definition FastLED.h:234
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:54
@ Blue
Definition crgb.h:498
@ Red
Definition crgb.h:608