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