FastLED 3.9.15
Loading...
Searching...
No Matches
WasmScreenCoords.ino

This sketch is fully compatible with the FastLED web compiler.

This sketch is fully compatible with the FastLED web compiler. To use it do the following:

  1. Install Fastled: pip install fastled
  2. cd into this examples page.
  3. Run the FastLED web compiler at root: fastled
  4. When the compiler is done a web page will open.
// @filter: (mem is large)
#include <Arduino.h>
#include <FastLED.h>
#ifdef __EMSCRIPTEN__
#include "fl/stl/vector.h"
#include "fl/stl/json.h"
#include "fl/stl/span.h"
#include "fl/math/math.h"
using fl::vec2f;
using fl::vector;
#define LED_PIN 3
#define BRIGHTNESS 96
#define COLOR_ORDER GRB
#define NUM_LEDS 256
void make_map(int stepx, int stepy, int num, fl::vector<vec2f>* _map) {
float x = 0;
float y = 0;
fl::vector<vec2f>& map = *_map;
for (int16_t i = 0; i < num; i++) {
map.push_back(vec2f{x, y});
x += stepx;
y += stepy;
}
}
void setup() {
for (CRGB& c : leds) {
}
for (CRGB& c : leds2) {
c = CRGB::Red;
}
FastLED.setBrightness(255);
make_map(1, 1, NUM_LEDS, &map);
make_map(-1, -1, NUM_LEDS, &map2);
fl::ScreenMap screenmap2 = fl::ScreenMap(map2.data(), map2.size());
FastLED.addLeds<WS2811, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS)
.setScreenMap(screenmap);
FastLED.addLeds<WS2811, LED_PIN+1, COLOR_ORDER>(leds2, NUM_LEDS)
.setScreenMap(screenmap2);
}
void loop() {
FastLED.show();
}
#else
void setup() {
Serial.begin(115200);
Serial.println("setup");
}
void loop() {
Serial.println("loop");
}
#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