FastLED 3.9.3
Loading...
Searching...
No Matches
SdCard.ino
1
2
3
4#ifdef __AVR__
5void setup() {
6 // put your setup code here, to run once:
7}
8
9void loop() {
10 // put your main code here, to run repeatedly:
11}
12#else
13
14#include <FastLED.h>
15#include "Arduino.h"
16
17
18#include "fx/2d/noisepalette.hpp"
19// #include "fx/2d/animartrix.hpp"
20#include "fx/fx_engine.h"
21#include "fx/video.h"
22#include "file_system.h"
23#include "ui.h"
24
25#include "file_system.h"
26
27#define LED_PIN 2
28#define LED_TYPE WS2811
29#define COLOR_ORDER GRB
30#define FPS 30
31#define CHIP_SELECT_PIN 5
32
33
34#define MATRIX_WIDTH 32
35#define MATRIX_HEIGHT 32
36
37
38#define NUM_LEDS (MATRIX_WIDTH * MATRIX_HEIGHT)
39#define IS_SERPINTINE true
40
41CRGB leds[NUM_LEDS];
42XYMap xyMap(MATRIX_WIDTH, MATRIX_HEIGHT, IS_SERPINTINE); // No serpentine
43
44FileSystem filesystem;
45Video video;
46
47
48void setup() {
49 Serial.begin(115200);
50 delay(1000); // sanity delay
51 if (!filesystem.beginSd(CHIP_SELECT_PIN)) {
52 Serial.println("Failed to initialize file system.");
53 }
54 FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS)
55 .setCorrection(TypicalLEDStrip)
56 .setScreenMap(xyMap);
58 //fxEngine.addFx(animartrix);
59 video = filesystem.openVideo("data/video.dat", NUM_LEDS, FPS);
60 if (!video) {
61 Serial.println("Failed to instantiate video");
62 }
63}
64
65void loop() {
66 uint32_t now = millis();
67
68 // fxEngine.draw(millis(), leds);
69 video.draw(now, leds);
70
72 Serial.println("Drawing");
73 for (int i = 0; i < NUM_LEDS;) {
74 int nleft = MIN(8, NUM_LEDS - i);
75 for (int j = 0; j < nleft; j++) {
76 CRGB c = leds[i + j];
77 Serial.print("(");
78 Serial.print(c.r);
79 Serial.print(", ");
80 Serial.print(c.g);
81 Serial.print(", ");
82 Serial.print(c.b);
83 Serial.print(") ");
84 }
85 Serial.println();
86 i += nleft;
87 }
88 }
89 FastLED.show();
90}
91
92#endif
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
Definition video.h:23
Definition xymap.h:39
@ TypicalLEDStrip
Typical values for SMD5050 LEDs.
Definition color.h:19
uint8_t r
Red channel value.
Definition crgb.h:43
uint8_t g
Green channel value.
Definition crgb.h:47
uint8_t b
Blue channel value.
Definition crgb.h:51
#define EVERY_N_SECONDS(N)
Checks whether to execute a block of code every N seconds.
Definition lib8tion.h:1288
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:39