first commit
This commit is contained in:
commit
5893b00dd2
1669 changed files with 1982740 additions and 0 deletions
58
libraries/FastLED/dev/ANIMartRIX.hpp
Normal file
58
libraries/FastLED/dev/ANIMartRIX.hpp
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
/// @file DemoReel100.ino
|
||||
/// @brief FastLED "100 lines of code" demo reel, showing off some effects
|
||||
/// @example DemoReel100.ino
|
||||
|
||||
|
||||
#include "fx/2d/animartrix.hpp"
|
||||
|
||||
#include <Arduino.h>
|
||||
#include "FastLED.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#define WIDTH 22 // how many columns?
|
||||
#define HEIGHT 22 // how many rows?
|
||||
|
||||
|
||||
#define DEBUG_PRINT 0
|
||||
|
||||
#define NUM_LED (WIDTH * HEIGHT)
|
||||
#define SERPENTINE true
|
||||
|
||||
#define CYCLE_THROUGH_ANIMATIONS 10
|
||||
|
||||
CRGB leds[NUM_LED]; // framebuffer
|
||||
|
||||
XYMap xyMap(WIDTH, HEIGHT, SERPENTINE);
|
||||
AnimartrixPtr fxAnimator = AnimartrixPtr::New(xyMap, POLAR_WAVES);
|
||||
|
||||
void setup() {
|
||||
FastLED.addLeds<WS2811, 2, GRB>(leds, NUM_LED);
|
||||
FastLED.setMaxPowerInVoltsAndMilliamps(5, 2000); // optional current limiting [5V, 2000mA]
|
||||
Serial.begin(115200); // check serial monitor for current fps count
|
||||
// fill_rainbow(leds, NUM_LED, 0);
|
||||
fill_solid(leds, NUM_LED, CRGB::Black);
|
||||
FastLED.show();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
uint32_t now = millis();
|
||||
// Change animation every 10 seconds
|
||||
#if CYCLE_THROUGH_ANIMATIONS > 0
|
||||
EVERY_N_SECONDS(CYCLE_THROUGH_ANIMATIONS) {
|
||||
fxAnimator->fxNext();
|
||||
#if DEBUG_PRINT
|
||||
std::cout << "New animation: " << fxAnimator.fxName() << std::endl;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
fxAnimator->draw(Fx::DrawContext{millis(), leds});
|
||||
FastLED.show();
|
||||
uint32_t elapsed = millis() - now;
|
||||
|
||||
EVERY_N_SECONDS(1) {
|
||||
#if DEBUG_PRINT
|
||||
std::cout << "frame time: " << elapsed << "ms" << std::endl;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
1
libraries/FastLED/dev/NoiseRing.hpp
Normal file
1
libraries/FastLED/dev/NoiseRing.hpp
Normal file
|
|
@ -0,0 +1 @@
|
|||
#include "../examples/FxNoiseRing/FxNoiseRing.ino"
|
||||
88
libraries/FastLED/dev/apa102hd.hpp
Normal file
88
libraries/FastLED/dev/apa102hd.hpp
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
/// @file Apa102HD.ino
|
||||
/// @brief Example showing how to use the APA102HD gamma correction.
|
||||
///
|
||||
/// In this example we compare two strips of LEDs.
|
||||
/// One strip is in HD mode, the other is in software gamma mode.
|
||||
///
|
||||
/// Each strip is a linear ramp of brightnesses, from 0 to 255.
|
||||
/// Showcasing all the different brightnesses.
|
||||
///
|
||||
/// Why do we love gamma correction? Gamma correction more closely
|
||||
/// matches how humans see light. Led values are measured in fractions
|
||||
/// of max power output (1/255, 2/255, etc.), while humans see light
|
||||
/// in a logarithmic way. Gamma correction converts to this eye friendly
|
||||
/// curve. Gamma correction wants a LED with a high bit depth. The APA102
|
||||
/// gives us the standard 3 components (red, green, blue) with 8 bits each, it
|
||||
/// *also* has a 5 bit brightness component. This gives us a total of 13 bits,
|
||||
/// which allows us to achieve a higher dynamic range. This means deeper fades.
|
||||
///
|
||||
/// Example:
|
||||
/// CRGB leds[NUM_LEDS] = {0};
|
||||
/// void setup() {
|
||||
/// FastLED.addLeds<
|
||||
/// APA102HD, // <--- This selects HD mode.
|
||||
/// STRIP_0_DATA_PIN,
|
||||
/// STRIP_0_CLOCK_PIN,
|
||||
/// RGB
|
||||
/// >(leds, NUM_LEDS);
|
||||
/// }
|
||||
|
||||
#define FASTLED_ALL_PINS_HARDWARE_SPI 1
|
||||
#include <Arduino.h>
|
||||
#include <FastLED.h>
|
||||
#include <lib8tion.h>
|
||||
|
||||
#define NUM_LEDS 20
|
||||
// uint8_t DATA_PIN, uint8_t CLOCK_PIN,
|
||||
|
||||
#define STRIP_0_DATA_PIN 1
|
||||
#define STRIP_0_CLOCK_PIN 2
|
||||
#define STRIP_1_DATA_PIN 3
|
||||
#define STRIP_1_CLOCK_PIN 4
|
||||
|
||||
|
||||
CRGB leds_hd[NUM_LEDS] = {0}; // HD mode implies gamma.
|
||||
CRGB leds[NUM_LEDS] = {0}; // Software gamma mode.
|
||||
|
||||
// This is the regular gamma correction function that we used to have
|
||||
// to do. It's used here to showcase the difference between APA102HD
|
||||
// mode which does the gamma correction for you.
|
||||
CRGB software_gamma(const CRGB& in) {
|
||||
CRGB out;
|
||||
// dim8_raw are the old gamma correction functions.
|
||||
out.r = dim8_raw(in.r);
|
||||
out.g = dim8_raw(in.g);
|
||||
out.b = dim8_raw(in.b);
|
||||
return out;
|
||||
}
|
||||
|
||||
void setup() {
|
||||
delay(500); // power-up safety delay
|
||||
// Two strips of LEDs, one in HD mode, one in software gamma mode.
|
||||
FastLED.addLeds<APA102HD, STRIP_0_DATA_PIN, STRIP_0_CLOCK_PIN, RGB>(leds_hd, NUM_LEDS);
|
||||
FastLED.addLeds<APA102, STRIP_1_DATA_PIN, STRIP_1_CLOCK_PIN, RGB>(leds, NUM_LEDS);
|
||||
}
|
||||
|
||||
uint8_t wrap_8bit(int i) {
|
||||
// Module % operator here wraps a large "i" so that it is
|
||||
// always in [0, 255] range when returned. For example, if
|
||||
// "i" is 256, then this will return 0. If "i" is 257
|
||||
// then this will return 1. No matter how big the "i" is, the
|
||||
// output range will always be [0, 255]
|
||||
return i % 256;
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// Draw a a linear ramp of brightnesses to showcase the difference between
|
||||
// the HD and non-HD mode.
|
||||
for (int i = 0; i < NUM_LEDS; i++) {
|
||||
uint8_t brightness = map(i, 0, NUM_LEDS - 1, 0, 255);
|
||||
CRGB c(brightness, brightness, brightness); // Just make a shade of white.
|
||||
leds_hd[i] = c; // The APA102HD leds do their own gamma correction.
|
||||
CRGB c_gamma_corrected = software_gamma(c);
|
||||
leds[i] = c_gamma_corrected; // Set the software gamma corrected
|
||||
// values to the other strip.
|
||||
}
|
||||
FastLED.show(); // All leds are now written out.
|
||||
delay(8); // Wait 8 milliseconds until the next frame.
|
||||
}
|
||||
34
libraries/FastLED/dev/cylon.hpp
Normal file
34
libraries/FastLED/dev/cylon.hpp
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
/// @brief An animation that moves a single LED back and forth (Larson Scanner effect) using the fx library cylon
|
||||
/// @example Cylon.ino
|
||||
|
||||
#include <FastLED.h>
|
||||
#include "fx/1d/cylon.hpp"
|
||||
|
||||
// How many leds in your strip?
|
||||
#define NUM_LEDS 64
|
||||
|
||||
// For led chips like Neopixels, which have a data line, ground, and power, you just
|
||||
// need to define DATA_PIN. For led chipsets that are SPI based (four wires - data, clock,
|
||||
// ground, and power).
|
||||
#define DATA_PIN 2
|
||||
|
||||
// Define the array of leds
|
||||
CRGB leds[NUM_LEDS];
|
||||
|
||||
// Create a Cylon instance
|
||||
Cylon cylon(NUM_LEDS);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(57600);
|
||||
Serial.println("resetting");
|
||||
FastLED.addLeds<WS2812,DATA_PIN,BRG>(leds,NUM_LEDS).setRgbw();
|
||||
FastLED.setBrightness(84);
|
||||
cylon.lazyInit();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Serial.print("x");
|
||||
cylon.draw(millis(), leds);
|
||||
FastLED.show();
|
||||
delay(cylon.delay_ms);
|
||||
}
|
||||
46
libraries/FastLED/dev/demoreel100.hpp
Normal file
46
libraries/FastLED/dev/demoreel100.hpp
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
/// @file DemoReel100.ino
|
||||
/// @brief FastLED "100 lines of code" demo reel, showing off some effects
|
||||
/// @example DemoReel100.ino
|
||||
|
||||
#include <FastLED.h>
|
||||
#include "fx/1d/demoreel100.hpp"
|
||||
|
||||
#define DATA_PIN 2
|
||||
//#define CLK_PIN 4
|
||||
#define LED_TYPE WS2811
|
||||
#define COLOR_ORDER BRG
|
||||
#define NUM_LEDS 64
|
||||
CRGB leds[NUM_LEDS];
|
||||
|
||||
#define BRIGHTNESS 96
|
||||
#define FRAMES_PER_SECOND 120
|
||||
|
||||
DemoReel100Ref demoReel = DemoReel100Ref::New(NUM_LEDS);
|
||||
|
||||
void setup() {
|
||||
delay(3000); // 3 second delay for recovery
|
||||
|
||||
// tell FastLED about the LED strip configuration
|
||||
FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip).setRgbw();
|
||||
//FastLED.addLeds<LED_TYPE,DATA_PIN,CLK_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
|
||||
|
||||
// set master brightness control
|
||||
FastLED.setBrightness(BRIGHTNESS);
|
||||
|
||||
// Initialize the DemoReel100 instance
|
||||
demoReel.lazyInit();
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
// Run the DemoReel100 draw function
|
||||
demoReel.draw(millis(), leds);
|
||||
|
||||
// send the 'leds' array out to the actual LED strip
|
||||
FastLED.show();
|
||||
// insert a delay to keep the framerate modest
|
||||
FastLED.delay(1000/FRAMES_PER_SECOND);
|
||||
}
|
||||
|
||||
|
||||
17
libraries/FastLED/dev/dev.ino
Normal file
17
libraries/FastLED/dev/dev.ino
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
|
||||
|
||||
#if defined(ESP32)
|
||||
|
||||
#include "esp_log.h"
|
||||
|
||||
// use gcc intialize constructor
|
||||
// to set log level to ESP_LOG_VERBOSE
|
||||
// before setup() is called
|
||||
__attribute__((constructor))
|
||||
void on_startup() {
|
||||
esp_log_level_set("*", ESP_LOG_VERBOSE); // set all components to ERROR level
|
||||
}
|
||||
|
||||
#endif // ESP32
|
||||
|
||||
#include "../examples/FestivalStick/FestivalStick.ino"
|
||||
125
libraries/FastLED/dev/dev.py
Normal file
125
libraries/FastLED/dev/dev.py
Normal file
|
|
@ -0,0 +1,125 @@
|
|||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
HERE = Path(__file__).resolve().parent
|
||||
PROJECT_ROOT = HERE.parent
|
||||
PLATFORMIO_INI = PROJECT_ROOT / "platformio.ini"
|
||||
|
||||
ESP32C6 = """
|
||||
[platformio]
|
||||
src_dir = dev ; target is ./dev/dev.ino
|
||||
|
||||
[env:dev]
|
||||
; This is the espressif32 platform which is the 4.1 toolchain as of 2024-Aug-23rd
|
||||
; platform = espressif32
|
||||
; The following platform enables the espressif32 platform to use the 5.1 toolchain, simulating
|
||||
; the new Arduino 2.3.1+ toolchain.
|
||||
|
||||
# Developement branch of the open source espressif32 platform
|
||||
platform = https://github.com/pioarduino/platform-espressif32/releases/download/53.03.10/platform-espressif32.zip
|
||||
|
||||
framework = arduino
|
||||
board = esp32-c6-devkitc-1
|
||||
|
||||
upload_protocol = esptool
|
||||
|
||||
monitor_filters =
|
||||
default
|
||||
esp32_exception_decoder ; Decode exceptions so that they are human readable.
|
||||
|
||||
; Symlink in the FastLED library so that changes to the library are reflected in the project
|
||||
; build immediatly.
|
||||
lib_deps =
|
||||
FastLED=symlink://./
|
||||
|
||||
build_type = debug
|
||||
|
||||
build_flags =
|
||||
-DDEBUG
|
||||
-g
|
||||
-Og
|
||||
-DCORE_DEBUG_LEVEL=5
|
||||
-DLOG_LOCAL_LEVEL=ESP_LOG_VERBOSE
|
||||
;-DFASTLED_RMT5=1
|
||||
-DFASTLED_ESP32_SPI_BULK_TRANSFER=1
|
||||
-DENABLE_ESP32_I2S_YVES_DRIVER=1
|
||||
|
||||
check_tool = clangtidy
|
||||
"""
|
||||
|
||||
ESP32S3 = """
|
||||
[platformio]
|
||||
src_dir = dev ; target is ./dev/dev.ino
|
||||
|
||||
[env:dev]
|
||||
; This is the espressif32 platform which is the 4.1 toolchain as of 2024-Aug-23rd
|
||||
; platform = espressif32
|
||||
; The following platform enables the espressif32 platform to use the 5.1 toolchain, simulating
|
||||
; the new Arduino 2.3.1+ toolchain.
|
||||
|
||||
# Developement branch of the open source espressif32 platform
|
||||
platform = https://github.com/pioarduino/platform-espressif32/releases/download/53.03.10/platform-espressif32.zip
|
||||
|
||||
framework = arduino
|
||||
board = esp32-s3-devkitc-1
|
||||
|
||||
upload_protocol = esptool
|
||||
|
||||
monitor_filters =
|
||||
default
|
||||
esp32_exception_decoder ; Decode exceptions so that they are human readable.
|
||||
|
||||
; Symlink in the FastLED library so that changes to the library are reflected in the project
|
||||
; build immediatly.
|
||||
lib_deps =
|
||||
FastLED=symlink://./
|
||||
|
||||
build_type = debug
|
||||
|
||||
build_flags =
|
||||
-DDEBUG
|
||||
-g
|
||||
-Og
|
||||
-DCORE_DEBUG_LEVEL=5
|
||||
-DLOG_LOCAL_LEVEL=ESP_LOG_VERBOSE
|
||||
;-DFASTLED_RMT5=1
|
||||
-DFASTLED_ESP32_SPI_BULK_TRANSFER=1
|
||||
-DENABLE_ESP32_I2S_YVES_DRIVER=1
|
||||
|
||||
check_tool = clangtidy
|
||||
"""
|
||||
|
||||
_ALL = {"esp32c6": ESP32C6, "esp32s3": ESP32S3}
|
||||
|
||||
|
||||
def prompt_user(msg: str) -> int:
|
||||
while True:
|
||||
try:
|
||||
return int(input(msg))
|
||||
except ValueError:
|
||||
print("Please enter a valid integer")
|
||||
continue
|
||||
|
||||
|
||||
def main() -> None:
|
||||
print("This tool will update the platformio.ini file with the selected platform")
|
||||
print("Please select a platform:")
|
||||
print("[0]: Exit")
|
||||
for i, platform in enumerate(_ALL.keys()):
|
||||
print(f"[{i+1}]: {platform}")
|
||||
val = prompt_user("Enter a number: ")
|
||||
if val == 0:
|
||||
sys.exit(0)
|
||||
if val < 0 or val > len(_ALL):
|
||||
print("Invalid selection")
|
||||
sys.exit(1)
|
||||
platform = list(_ALL.keys())[val - 1]
|
||||
with PLATFORMIO_INI.open("w") as f:
|
||||
f.write(_ALL[platform])
|
||||
print(f"Selected platform: {platform}")
|
||||
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
1
libraries/FastLED/dev/esp_virtual_driver.hpp
Normal file
1
libraries/FastLED/dev/esp_virtual_driver.hpp
Normal file
|
|
@ -0,0 +1 @@
|
|||
#include "../examples/EspI2SDemo/EspI2SDemo.ino"
|
||||
2
libraries/FastLED/dev/fake_main_for_esp32dev.cpp
Normal file
2
libraries/FastLED/dev/fake_main_for_esp32dev.cpp
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
// For some reason, platformio refuses to compile unless at least one .cpp file is present in this directory.
|
||||
// This file is not used in the build process, but is required to satisfy platformio.
|
||||
33
libraries/FastLED/dev/fire2012.hpp
Normal file
33
libraries/FastLED/dev/fire2012.hpp
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
#include <FastLED.h>
|
||||
#include "fx/1d/fire2012.hpp"
|
||||
|
||||
#define LED_PIN 2
|
||||
#define COLOR_ORDER BRG
|
||||
#define CHIPSET WS2811
|
||||
#define NUM_LEDS 30
|
||||
|
||||
#define BRIGHTNESS 128
|
||||
#define FRAMES_PER_SECOND 30
|
||||
#define COOLING 55
|
||||
#define SPARKING 120
|
||||
#define REVERSE_DIRECTION false
|
||||
|
||||
CRGB leds[NUM_LEDS];
|
||||
Fire2012 fire(NUM_LEDS, COOLING, SPARKING, REVERSE_DIRECTION);
|
||||
|
||||
void setup() {
|
||||
delay(3000); // sanity delay
|
||||
FastLED.addLeds<CHIPSET, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS)
|
||||
.setCorrection(TypicalLEDStrip)
|
||||
.setRgbw();
|
||||
FastLED.setBrightness(BRIGHTNESS);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
fire.draw(millis(), leds); // run simulation frame, passing leds array
|
||||
|
||||
FastLED.show(); // display this frame
|
||||
FastLED.delay(1000 / FRAMES_PER_SECOND);
|
||||
}
|
||||
|
||||
55
libraries/FastLED/dev/fx_engine.hpp
Normal file
55
libraries/FastLED/dev/fx_engine.hpp
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
/// @file Noise.ino
|
||||
/// @brief Demonstrates how to use noise generation on a 2D LED matrix
|
||||
/// @example Noise.ino
|
||||
|
||||
|
||||
#include <FastLED.h>
|
||||
|
||||
#include "fx/2d/noisepalette.h"
|
||||
#include "fx/2d/animartrix.hpp"
|
||||
#include "fx/fx_engine.h"
|
||||
#include "fx/storage/sd.h"
|
||||
|
||||
#define LED_PIN 2
|
||||
#define BRIGHTNESS 96
|
||||
#define LED_TYPE WS2811
|
||||
#define COLOR_ORDER GRB
|
||||
|
||||
#define MATRIX_WIDTH 22
|
||||
#define MATRIX_HEIGHT 22
|
||||
#define GRID_SERPENTINE 1
|
||||
|
||||
#define NUM_LEDS (MATRIX_WIDTH * MATRIX_HEIGHT)
|
||||
|
||||
#define SCALE 20
|
||||
#define SPEED 30
|
||||
|
||||
CRGB leds[NUM_LEDS];
|
||||
XYMap xyMap(MATRIX_WIDTH, MATRIX_HEIGHT, GRID_SERPENTINE);
|
||||
NoisePaletteRef noisePalette = Fx::make<NoisePalette>(xyMap);
|
||||
AnimartrixRef animartrix = Fx::make<Animartrix>(xyMap, POLAR_WAVES);
|
||||
|
||||
FxEngine fxEngine(NUM_LEDS);
|
||||
|
||||
|
||||
|
||||
void setup() {
|
||||
delay(1000); // sanity delay
|
||||
FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS)
|
||||
.setCorrection(TypicalLEDStrip);
|
||||
FastLED.setBrightness(96);
|
||||
noisePalette->lazyInit();
|
||||
noisePalette->setSpeed(SPEED);
|
||||
noisePalette->setScale(SCALE);
|
||||
noisePalette->setPalettePreset(2);
|
||||
fxEngine.addFx(noisePalette);
|
||||
fxEngine.addFx(animartrix);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
EVERY_N_SECONDS(1) {
|
||||
fxEngine.nextFx(500);
|
||||
}
|
||||
fxEngine.draw(millis(), leds);
|
||||
FastLED.show();
|
||||
}
|
||||
75
libraries/FastLED/dev/noisepalette.hpp
Normal file
75
libraries/FastLED/dev/noisepalette.hpp
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
/// @file Noise.ino
|
||||
/// @brief Demonstrates how to use noise generation on a 2D LED matrix
|
||||
/// @example Noise.ino
|
||||
|
||||
#include "fx/2d/noisepalette.h"
|
||||
#include <FastLED.h>
|
||||
|
||||
#define LED_PIN 2
|
||||
#define BRIGHTNESS 96
|
||||
#define LED_TYPE WS2811
|
||||
#define COLOR_ORDER GRB
|
||||
|
||||
#define MATRIX_WIDTH 22
|
||||
#define MATRIX_HEIGHT 22
|
||||
#define GRID_SERPENTINE 1
|
||||
|
||||
#define NUM_LEDS (MATRIX_WIDTH * MATRIX_HEIGHT)
|
||||
|
||||
// This example combines two features of FastLED to produce a remarkable range
|
||||
// of effects from a relatively small amount of code. This example combines
|
||||
// FastLED's color palette lookup functions with FastLED's Perlin noise
|
||||
// generator, and the combination is extremely powerful.
|
||||
//
|
||||
// You might want to look at the "ColorPalette" and "Noise" examples separately
|
||||
// if this example code seems daunting.
|
||||
//
|
||||
//
|
||||
// The basic setup here is that for each frame, we generate a new array of
|
||||
// 'noise' data, and then map it onto the LED matrix through a color palette.
|
||||
//
|
||||
// Periodically, the color palette is changed, and new noise-generation
|
||||
// parameters are chosen at the same time. In this example, specific
|
||||
// noise-generation values have been selected to match the given color palettes;
|
||||
// some are faster, or slower, or larger, or smaller than others, but there's no
|
||||
// reason these parameters can't be freely mixed-and-matched.
|
||||
//
|
||||
// In addition, this example includes some fast automatic 'data smoothing' at
|
||||
// lower noise speeds to help produce smoother animations in those cases.
|
||||
//
|
||||
// The FastLED built-in color palettes (Forest, Clouds, Lava, Ocean, Party) are
|
||||
// used, as well as some 'hand-defined' ones, and some proceedurally generated
|
||||
// palettes.
|
||||
|
||||
// Scale determines how far apart the pixels in our noise matrix are. Try
|
||||
// changing these values around to see how it affects the motion of the display.
|
||||
// The higher the value of scale, the more "zoomed out" the noise iwll be. A
|
||||
// value of 1 will be so zoomed in, you'll mostly see solid colors.
|
||||
#define SCALE 20
|
||||
|
||||
// We're using the x/y dimensions to map to the x/y pixels on the matrix. We'll
|
||||
// use the z-axis for "time". speed determines how fast time moves forward. Try
|
||||
// 1 for a very slow moving effect, or 60 for something that ends up looking
|
||||
// like water.
|
||||
#define SPEED 30
|
||||
|
||||
CRGB leds[NUM_LEDS];
|
||||
XYMap xyMap(MATRIX_WIDTH, MATRIX_HEIGHT, GRID_SERPENTINE);
|
||||
NoisePaletteRef noisePalette = Fx::make<NoisePaletteRef>(xyMap);
|
||||
|
||||
|
||||
void setup() {
|
||||
delay(1000); // sanity delay
|
||||
FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS)
|
||||
.setCorrection(TypicalLEDStrip);
|
||||
FastLED.setBrightness(96);
|
||||
noisePalette->lazyInit();
|
||||
noisePalette->setSpeed(SPEED);
|
||||
noisePalette->setScale(SCALE);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
EVERY_N_MILLISECONDS(5000) { noisePalette->changeToRandomPalette(); }
|
||||
noisePalette->draw(DrawContext{millis(), leds});
|
||||
FastLED.show();
|
||||
}
|
||||
26
libraries/FastLED/dev/noisewave.hpp
Normal file
26
libraries/FastLED/dev/noisewave.hpp
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#include <FastLED.h>
|
||||
#include "fx/1d/noisewave.hpp"
|
||||
|
||||
#define LED_PIN 2
|
||||
#define COLOR_ORDER BRG
|
||||
#define CHIPSET WS2811
|
||||
#define NUM_LEDS 484
|
||||
|
||||
CRGB leds[NUM_LEDS];
|
||||
NoiseWaveRef noiseWave = Fx::make<NoiseWave>(NUM_LEDS);
|
||||
|
||||
void setup() {
|
||||
delay(3000); // sanity delay
|
||||
FastLED.addLeds<CHIPSET, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS)
|
||||
.setCorrection(TypicalLEDStrip);
|
||||
FastLED.setBrightness(128);
|
||||
noiseWave->lazyInit();
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
noiseWave->draw(DrawContext{millis(), leds});
|
||||
FastLED.show();
|
||||
FastLED.delay(1000 / 60);
|
||||
}
|
||||
|
||||
26
libraries/FastLED/dev/pacifica.hpp
Normal file
26
libraries/FastLED/dev/pacifica.hpp
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#define FASTLED_ALLOW_INTERRUPTS 0
|
||||
#include <FastLED.h>
|
||||
#include "fx/1d/pacifica.hpp"
|
||||
|
||||
#define DATA_PIN 2
|
||||
#define NUM_LEDS 60
|
||||
#define MAX_POWER_MILLIAMPS 500
|
||||
#define LED_TYPE WS2812B
|
||||
#define COLOR_ORDER BRG
|
||||
|
||||
CRGB leds[NUM_LEDS];
|
||||
Pacifica pacifica(NUM_LEDS);
|
||||
|
||||
void setup() {
|
||||
delay(3000); // 3 second delay for boot recovery, and a moment of silence
|
||||
FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS)
|
||||
.setCorrection(TypicalLEDStrip);
|
||||
FastLED.setMaxPowerInVoltsAndMilliamps(5, MAX_POWER_MILLIAMPS);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
EVERY_N_MILLISECONDS(20) {
|
||||
pacifica.draw(millis(), leds);
|
||||
FastLED.show();
|
||||
}
|
||||
}
|
||||
28
libraries/FastLED/dev/pride2015.hpp
Normal file
28
libraries/FastLED/dev/pride2015.hpp
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
#include <FastLED.h>
|
||||
#include "fx/1d/pride2015.hpp"
|
||||
|
||||
#define DATA_PIN 2
|
||||
#define LED_TYPE WS2811
|
||||
#define COLOR_ORDER BRG
|
||||
#define NUM_LEDS 200
|
||||
#define BRIGHTNESS 255
|
||||
|
||||
CRGB leds[NUM_LEDS];
|
||||
Pride2015 pride(NUM_LEDS);
|
||||
|
||||
void setup() {
|
||||
delay(3000); // 3 second delay for recovery
|
||||
|
||||
// tell FastLED about the LED strip configuration
|
||||
FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS)
|
||||
.setCorrection(TypicalLEDStrip)
|
||||
.setDither(BRIGHTNESS < 255);
|
||||
|
||||
// set master brightness control
|
||||
FastLED.setBrightness(BRIGHTNESS);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
pride.draw(millis(), leds);
|
||||
FastLED.show();
|
||||
}
|
||||
48
libraries/FastLED/dev/rgborder.hpp
Normal file
48
libraries/FastLED/dev/rgborder.hpp
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
#include "fx/pride2015.hpp"
|
||||
|
||||
#define DATA_PIN 2
|
||||
#define LED_TYPE WS2811
|
||||
#define COLOR_ORDER GRB
|
||||
#define NUM_LEDS 200
|
||||
#define BRIGHTNESS 128
|
||||
|
||||
#define DELAY 500
|
||||
|
||||
CRGB leds[NUM_LEDS];
|
||||
|
||||
void fill(CRGB c) {
|
||||
for (int i = 0; i < NUM_LEDS; i++) {
|
||||
leds[i] = c;
|
||||
}
|
||||
}
|
||||
|
||||
void Blink(CRGB color, int count) {
|
||||
for (int i = 0; i < count; i++) {
|
||||
fill(color);
|
||||
FastLED.show();
|
||||
delay(DELAY); // On for 500ms
|
||||
fill(CRGB::Black);
|
||||
FastLED.show();
|
||||
delay(DELAY); // Off for 500ms
|
||||
}
|
||||
delay(DELAY * 2); // Pause for 1s
|
||||
}
|
||||
|
||||
void setup() {
|
||||
// tell FastLED about the LED strip configuration
|
||||
FastLED.addLeds<LED_TYPE, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS)
|
||||
.setCorrection(TypicalLEDStrip)
|
||||
.setDither(BRIGHTNESS < 255);
|
||||
|
||||
// set master brightness control
|
||||
FastLED.setBrightness(BRIGHTNESS);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// Blink red once,
|
||||
Blink(CRGB::Red, 1);
|
||||
// Blink green twice
|
||||
Blink(CRGB::Green, 2);
|
||||
// Blink blue three times
|
||||
Blink(CRGB::Blue, 3);
|
||||
}
|
||||
106
libraries/FastLED/dev/rmt51.hpp
Normal file
106
libraries/FastLED/dev/rmt51.hpp
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
|
||||
|
||||
#include <FastLED.h>
|
||||
#include <iostream>
|
||||
|
||||
// How many leds in your strip?
|
||||
#define NUM_LEDS 10
|
||||
|
||||
// For led chips like WS2812, which have a data line, ground, and power, you just
|
||||
// need to define DATA_PIN. For led chipsets that are SPI based (four wires - data, clock,
|
||||
// ground, and power), like the LPD8806 define both DATA_PIN and CLOCK_PIN
|
||||
// Clock pin only needed for SPI based chipsets when not using hardware SPI
|
||||
#define DATA_PIN 2
|
||||
|
||||
// Define the array of leds
|
||||
CRGB leds[NUM_LEDS];
|
||||
|
||||
// Time scaling factors for each component
|
||||
#define TIME_FACTOR_HUE 60
|
||||
#define TIME_FACTOR_SAT 100
|
||||
#define TIME_FACTOR_VAL 100
|
||||
|
||||
#define DELAY 200
|
||||
#define BRIGHNESS 8
|
||||
|
||||
// #define COLOR_ORDER_TEST
|
||||
// #define TIMING_TEST
|
||||
#define STRESS_TEST
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
FastLED.addLeds<WS2812, 2, BRG>(leds, NUM_LEDS).setRgbw(RgbwDefault());
|
||||
#ifdef STRESS_TEST
|
||||
FastLED.addLeds<WS2812, 1, BRG>(leds, NUM_LEDS).setRgbw(RgbwDefault());
|
||||
FastLED.addLeds<WS2812, 3, BRG>(leds, NUM_LEDS).setRgbw(RgbwDefault());
|
||||
FastLED.addLeds<WS2812, 4, BRG>(leds, NUM_LEDS).setRgbw(RgbwDefault());
|
||||
FastLED.addLeds<WS2812, 5, BRG>(leds, NUM_LEDS).setRgbw(RgbwDefault());
|
||||
FastLED.addLeds<WS2812, 6, BRG>(leds, NUM_LEDS).setRgbw(RgbwDefault());
|
||||
FastLED.addLeds<WS2812, 7, BRG>(leds, NUM_LEDS).setRgbw(RgbwDefault());
|
||||
FastLED.addLeds<WS2812, 8, BRG>(leds, NUM_LEDS).setRgbw(RgbwDefault());
|
||||
FastLED.addLeds<WS2812, 9, BRG>(leds, NUM_LEDS).setRgbw(RgbwDefault());
|
||||
#endif
|
||||
FastLED.setBrightness(BRIGHNESS); // Set global brightness to 50%
|
||||
delay(2000); // If something ever goes wrong this delay will allow upload.
|
||||
}
|
||||
|
||||
void fill(CRGB color) {
|
||||
for (int i = 0; i < NUM_LEDS; i++) {
|
||||
leds[i] = color;
|
||||
}
|
||||
}
|
||||
|
||||
void Blink(CRGB color, int times) {
|
||||
for (int i = 0; i < times; i++) {
|
||||
fill(color);
|
||||
FastLED.show();
|
||||
delay(DELAY);
|
||||
fill(CRGB::Black);
|
||||
FastLED.show();
|
||||
delay(DELAY);
|
||||
}
|
||||
delay(DELAY*2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void blink_loop() {
|
||||
Blink(CRGB::Red, 1);
|
||||
Blink(CRGB::Green, 2);
|
||||
Blink(CRGB::Blue, 3);
|
||||
Blink(CRGB::White, 4);
|
||||
delay(DELAY);
|
||||
// long delay to make the cycle visible
|
||||
delay(DELAY * 4);
|
||||
}
|
||||
|
||||
|
||||
void hue_loop() {
|
||||
uint32_t ms = millis();
|
||||
|
||||
for(int i = 0; i < NUM_LEDS; i++) {
|
||||
// Use different noise functions for each LED and each color component
|
||||
uint8_t hue = inoise16(ms * TIME_FACTOR_HUE, i * 1000, 0) >> 8;
|
||||
uint8_t sat = inoise16(ms * TIME_FACTOR_SAT, i * 2000, 1000) >> 8;
|
||||
uint8_t val = inoise16(ms * TIME_FACTOR_VAL, i * 3000, 2000) >> 8;
|
||||
|
||||
// Map the noise to full range for saturation and value
|
||||
sat = map(sat, 0, 255, 30, 255);
|
||||
val = map(val, 0, 255, 100, 255);
|
||||
|
||||
leds[i] = CHSV(hue, sat, val);
|
||||
}
|
||||
|
||||
FastLED.show();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
#ifdef COLOR_ORDER_TEST
|
||||
blink_loop();
|
||||
#elif defined(TIMING_TEST)
|
||||
timing_loop();
|
||||
#else
|
||||
hue_loop();
|
||||
#endif
|
||||
}
|
||||
53
libraries/FastLED/dev/s3_parallel.hpp
Normal file
53
libraries/FastLED/dev/s3_parallel.hpp
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
#include <FastLED.h>
|
||||
#include <iostream>
|
||||
|
||||
#define NUM_LEDS_PER_STRIP 60 // Number of LEDs in each strip
|
||||
#define NUM_STRIPS 3 // Number of parallel strips
|
||||
|
||||
// Define the pins for each strip
|
||||
#define STRIP_1_PIN 13
|
||||
#define STRIP_2_PIN 12
|
||||
#define STRIP_3_PIN 14
|
||||
#define STRIP_4_PIN 14
|
||||
|
||||
// Create separate LED arrays for each strip
|
||||
CRGB leds1[NUM_LEDS_PER_STRIP];
|
||||
CRGB leds2[NUM_LEDS_PER_STRIP];
|
||||
CRGB leds3[NUM_LEDS_PER_STRIP];
|
||||
CRGB leds4[NUM_LEDS_PER_STRIP];
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
//Initialize FastLED for multiple strips
|
||||
FastLED.addLeds<WS2812B, STRIP_1_PIN, GRB>(leds1, NUM_LEDS_PER_STRIP);
|
||||
FastLED.addLeds<WS2812B, STRIP_2_PIN, GRB>(leds2, NUM_LEDS_PER_STRIP);
|
||||
FastLED.addLeds<WS2812B, STRIP_3_PIN, GRB>(leds3, NUM_LEDS_PER_STRIP);
|
||||
FastLED.addLeds<WS2812B, STRIP_4_PIN, GRB>(leds3, NUM_LEDS_PER_STRIP);
|
||||
Serial.println("Setup");
|
||||
std::cout << "Setup" << std::endl;
|
||||
|
||||
FastLED.setBrightness(64); // Set initial brightness (0-255)
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// Create a simple rainbow pattern
|
||||
static uint8_t hue = 0;
|
||||
|
||||
// Update each strip
|
||||
for(int i = 0; i < NUM_LEDS_PER_STRIP; i++) {
|
||||
leds1[i] = CHSV(hue + (i * 4), 255, 255);
|
||||
leds2[i] = CHSV(hue + (i * 4), 255, 255);
|
||||
leds3[i] = CHSV(hue + (i * 4), 255, 255);
|
||||
leds4[i] = CHSV(hue + (i * 4), 255, 255);
|
||||
}
|
||||
|
||||
FastLED.show();
|
||||
|
||||
EVERY_N_MILLISECONDS(20) {
|
||||
hue++;
|
||||
}
|
||||
EVERY_N_SECONDS(1) {
|
||||
// Serial.println("Alive");
|
||||
std::cout << "Alive" << std::endl;
|
||||
}
|
||||
}
|
||||
49
libraries/FastLED/dev/scale_up.hpp
Normal file
49
libraries/FastLED/dev/scale_up.hpp
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
/// @file Noise.ino
|
||||
/// @brief Demonstrates how to use noise generation on a 2D LED matrix
|
||||
/// @example Noise.ino
|
||||
|
||||
|
||||
#include <FastLED.h>
|
||||
|
||||
#include "fx/2d/noisepalette.h"
|
||||
#include "fx/fx_engine.h"
|
||||
#include "fx/2d/animartrix.hpp"
|
||||
#include "fx/2d/scale_up.h"
|
||||
#include "fx/fx_engine.h"
|
||||
|
||||
#define LED_PIN 2
|
||||
#define BRIGHTNESS 96
|
||||
#define LED_TYPE WS2811
|
||||
#define COLOR_ORDER GRB
|
||||
|
||||
#define MATRIX_SMALL_WIDTH 11
|
||||
#define MATRIX_SMALL_HEIGHT 11
|
||||
#define MATRIX_WIDTH 22
|
||||
#define MATRIX_HEIGHT 22
|
||||
#define GRID_SERPENTINE 1
|
||||
|
||||
#define NUM_LEDS (MATRIX_WIDTH * MATRIX_HEIGHT)
|
||||
|
||||
#define SCALE 20
|
||||
#define SPEED 30
|
||||
|
||||
CRGB leds[NUM_LEDS];
|
||||
XYMap xyMap(MATRIX_WIDTH, MATRIX_HEIGHT, GRID_SERPENTINE);
|
||||
XYMap xyMapSmall = XYMap::constructRectangularGrid(MATRIX_SMALL_WIDTH, MATRIX_SMALL_HEIGHT);
|
||||
AnimartrixRef animartrix = Fx::make<Animatrix>(xyMapSmall, POLAR_WAVES);
|
||||
ScaleUp scaleUp(xyMap, animartrix.get());
|
||||
FxEngine fxEngine(NUM_LEDS);
|
||||
|
||||
|
||||
void setup() {
|
||||
delay(1000); // sanity delay
|
||||
FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS)
|
||||
.setCorrection(TypicalLEDStrip);
|
||||
FastLED.setBrightness(96);
|
||||
fxEngine.addFx(&scaleUp);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
fxEngine.draw(millis(), leds);
|
||||
FastLED.show();
|
||||
}
|
||||
49
libraries/FastLED/dev/sd_card.hpp
Normal file
49
libraries/FastLED/dev/sd_card.hpp
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
/// @file Noise.ino
|
||||
/// @brief Demonstrates how to use noise generation on a 2D LED matrix
|
||||
/// @example Noise.ino
|
||||
|
||||
|
||||
#include <FastLED.h>
|
||||
|
||||
#include "fx/storage/sd.hpp"
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
#define SCALE 20
|
||||
#define SPEED 30
|
||||
#define CS_PIN 5
|
||||
|
||||
FsRef SD_CARD_READER = FsRef::New(CS_PIN);
|
||||
|
||||
|
||||
void runFsTest() {
|
||||
cout << "Running SD card test" << endl;
|
||||
SD_CARD_READER->begin(CS_PIN);
|
||||
FileHandleRef file = SD_CARD_READER->openRead("/test.txt");
|
||||
if (!file) {
|
||||
cout << "Failed to open file" << endl;
|
||||
return;
|
||||
}
|
||||
cout << "File opened" << endl;
|
||||
char buffer[256];
|
||||
size_t bytesRead = file->read((uint8_t*)buffer, sizeof(buffer));
|
||||
cout << "Read " << bytesRead << " bytes" << endl;
|
||||
cout << "File contents: " << buffer << endl;
|
||||
file->close();
|
||||
cout << "File closed" << endl;
|
||||
SD_CARD_READER->end();
|
||||
cout << "SD card test complete" << endl;
|
||||
}
|
||||
|
||||
|
||||
void setup() {
|
||||
delay(1000); // sanity delay
|
||||
}
|
||||
|
||||
|
||||
|
||||
void loop() {
|
||||
runFsTest();
|
||||
delay(1000);
|
||||
}
|
||||
61
libraries/FastLED/dev/test_video_fx.hpp
Normal file
61
libraries/FastLED/dev/test_video_fx.hpp
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
/// @file VideoTest.ino
|
||||
/// @brief Demonstrates a video test using NoisePalette to generate content
|
||||
/// @example VideoTest.ino
|
||||
|
||||
#include <FastLED.h>
|
||||
#include "fx/2d/video.hpp"
|
||||
#include "fx/2d/noisepalette.hpp"
|
||||
#include "fx/fx_engine.h"
|
||||
#include "ref.h"
|
||||
|
||||
#define LED_PIN 2
|
||||
#define BRIGHTNESS 96
|
||||
#define LED_TYPE WS2811
|
||||
#define COLOR_ORDER GRB
|
||||
|
||||
#define MATRIX_WIDTH 16
|
||||
#define MATRIX_HEIGHT 16
|
||||
#define NUM_LEDS (MATRIX_WIDTH * MATRIX_HEIGHT)
|
||||
|
||||
#define SCALE 20
|
||||
#define SPEED 30
|
||||
|
||||
CRGB leds[NUM_LEDS];
|
||||
|
||||
VideoFxRef videoFx;
|
||||
NoisePaletteRef noisePalette;
|
||||
FxEngine fxEngine(NUM_LEDS);
|
||||
|
||||
void setup() {
|
||||
delay(1000); // sanity delay
|
||||
FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS)
|
||||
.setCorrection(TypicalLEDStrip);
|
||||
FastLED.setBrightness(BRIGHTNESS);
|
||||
|
||||
// Create and initialize XYMap
|
||||
XYMap xymap(MATRIX_WIDTH, MATRIX_HEIGHT);
|
||||
|
||||
// Create and initialize NoisePalette object
|
||||
noisePalette = NoisePaletteRef::New(xymap);
|
||||
noisePalette->lazyInit();
|
||||
noisePalette->setSpeed(SPEED);
|
||||
noisePalette->setScale(SCALE);
|
||||
|
||||
// Create and initialize VideoFx object
|
||||
videoFx = VideoFxRef::New(xymap, noisePalette);
|
||||
|
||||
// Add the video effect to the FxEngine
|
||||
fxEngine.addFx(videoFx);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
EVERY_N_MILLISECONDS(5000) { noisePalette->changeToRandomPalette(); }
|
||||
|
||||
// Draw the frame
|
||||
fxEngine.draw(millis(), leds);
|
||||
|
||||
// Show the LEDs
|
||||
FastLED.show();
|
||||
|
||||
FastLED.delay(1000 / 60); // 60 fps
|
||||
}
|
||||
30
libraries/FastLED/dev/twinklefox.hpp
Normal file
30
libraries/FastLED/dev/twinklefox.hpp
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
#include "FastLED.h"
|
||||
#include "fx/1d/twinklefox.hpp"
|
||||
|
||||
#define NUM_LEDS 100
|
||||
#define LED_TYPE WS2811
|
||||
#define COLOR_ORDER BRG
|
||||
#define DATA_PIN 2
|
||||
#define VOLTS 12
|
||||
#define MAX_MA 4000
|
||||
|
||||
CRGBArray<NUM_LEDS> leds;
|
||||
TwinkleFox twinkleFox(NUM_LEDS);
|
||||
|
||||
void setup() {
|
||||
delay(3000); // safety startup delay
|
||||
FastLED.setMaxPowerInVoltsAndMilliamps(VOLTS, MAX_MA);
|
||||
FastLED.addLeds<LED_TYPE, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS)
|
||||
.setCorrection(TypicalLEDStrip)
|
||||
.setRgbw();
|
||||
|
||||
twinkleFox.lazyInit();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
EVERY_N_SECONDS(SECONDS_PER_PALETTE) {
|
||||
twinkleFox.chooseNextColorPalette(twinkleFox.targetPalette);
|
||||
}
|
||||
twinkleFox.draw(millis(), leds);
|
||||
FastLED.show();
|
||||
}
|
||||
88
libraries/FastLED/dev/video_test.hpp
Normal file
88
libraries/FastLED/dev/video_test.hpp
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
/// @file VideoTest.ino
|
||||
/// @brief Demonstrates a simple video test using alternating black/red pixels
|
||||
/// @example VideoTest.ino
|
||||
|
||||
#include <FastLED.h>
|
||||
#include "fl/bytestreammemory.h"
|
||||
#include "fx/2d/video.hpp"
|
||||
#include "fx/fx_engine.h"
|
||||
#include "fl/ptr.h"
|
||||
#include <iostream>
|
||||
|
||||
using namespace fl;
|
||||
|
||||
#define LED_PIN 2
|
||||
#define BRIGHTNESS 96
|
||||
#define LED_TYPE WS2811
|
||||
#define COLOR_ORDER GRB
|
||||
|
||||
#define MATRIX_WIDTH 22
|
||||
#define MATRIX_HEIGHT 22
|
||||
#define NUM_LEDS (MATRIX_WIDTH * MATRIX_HEIGHT)
|
||||
|
||||
CRGB leds[NUM_LEDS];
|
||||
|
||||
const int BYTES_PER_FRAME = 3 * MATRIX_WIDTH * MATRIX_HEIGHT;
|
||||
const int NUM_FRAMES = 2;
|
||||
const uint32_t BUFFER_SIZE = BYTES_PER_FRAME * NUM_FRAMES;
|
||||
|
||||
ByteStreamMemoryPtr memoryStream;
|
||||
VideoPtr videoFx;
|
||||
FxEngine fxEngine(NUM_LEDS);
|
||||
|
||||
using namespace fl;
|
||||
|
||||
|
||||
void write_one_frame(ByteStreamMemoryPtr memoryStream) {
|
||||
//memoryStream->seek(0); // Reset to the beginning of the stream
|
||||
uint32_t total_bytes_written = 0;
|
||||
int toggle = (millis() / 500) % 2;
|
||||
for (uint32_t i = 0; i < NUM_LEDS; ++i) {
|
||||
CRGB color = (i % 2 == toggle) ? CRGB::Black : CRGB::Red;
|
||||
size_t bytes_written = memoryStream->write(color.raw, 3);
|
||||
if (bytes_written != 3) {
|
||||
std::cout << "Error writing to memory stream at LED " << i << std::endl;
|
||||
}
|
||||
total_bytes_written += bytes_written;
|
||||
}
|
||||
std::cout << "Total bytes written: " << total_bytes_written << " / " << BUFFER_SIZE << std::endl;
|
||||
}
|
||||
|
||||
void setup() {
|
||||
delay(1000); // sanity delay
|
||||
FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS)
|
||||
.setCorrection(TypicalLEDStrip);
|
||||
FastLED.setBrightness(BRIGHTNESS);
|
||||
|
||||
// Create and fill the ByteStreamMemory with test data
|
||||
memoryStream = Ptr::New<ByteStreamMemory>(BUFFER_SIZE);
|
||||
write_one_frame(memoryStream); // Write initial frame data
|
||||
|
||||
// Create and initialize Video fx object
|
||||
XYMap xymap(MATRIX_WIDTH, MATRIX_HEIGHT);
|
||||
videoFx = Fx::make<VideoPtr>(xymap);
|
||||
videoFx->beginStream(memoryStream);
|
||||
|
||||
// Add the video effect to the FxEngine
|
||||
fxEngine.addFx(videoFx);
|
||||
|
||||
std::cout << "Setup complete. Starting main loop." << std::endl;
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// Reset the memory stream position before reading
|
||||
//memoryStream->seek(0);
|
||||
write_one_frame(memoryStream); // Write next frame data
|
||||
|
||||
// Draw the frame
|
||||
fxEngine.draw(millis(), leds);
|
||||
|
||||
// Debug output
|
||||
//std::cout << "First LED: R=" << (int)leds[0].r << " G=" << (int)leds[0].g << " B=" << (int)leds[0].b << std::endl;
|
||||
//std::cout << "Last LED: R=" << (int)leds[NUM_LEDS-1].r << " G=" << (int)leds[NUM_LEDS-1].g << " B=" << (int)leds[NUM_LEDS-1].b << std::endl;
|
||||
|
||||
// Show the LEDs
|
||||
FastLED.show();
|
||||
|
||||
delay(100); // Adjust this delay to control frame rate
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue