FastLED 3.9.15
Loading...
Searching...
No Matches

◆ loop()

void loop ( )

Definition at line 26 of file Spi.ino.

26 {
27 if (!spi_device.ok()) {
28 FL_WARN("SPI device was not initialized!");
29 delay(1000);
30 return;
31 }
32
33 // Example data for each lane - all lanes must have the same size
34 // Using C arrays and manual initialization for AVR compatibility
35 static const uint8_t lane0[] = {0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00,
36 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00};
37 static const uint8_t lane1[] = {0xAA, 0x55, 0xAA, 0x00, 0x00, 0x00, 0x00, 0x00,
38 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
39 static const uint8_t lane2[] = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80,
40 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
41 static const uint8_t lane3[] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
42 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF};
43
44
45 // Simple API - write all 4 lanes at once (starts transmission asynchronously)
46 auto result = spi_device.write(lane0, lane1, lane2, lane3);
47 if (!result.ok) {
48 FL_WARN("Write failed: " << result.error);
49 delay(1000);
50 return;
51 }
52
53 // Wait for transmission to complete (blocks until done)
54 spi_device.wait();
55
56 FL_DBG("Data transmitted to 4 lanes");
57
58 // Delay before next transmission
59 delay(100);
60}
fl::Spi spi_device(CLOCK_PIN, pins, fl::spi_output_mode_t::SPI_HW)
#define FL_WARN(X)
Definition log.h:276
#define FL_DBG
Definition log.h:388
void delay(u32 ms, bool run_async=true) FL_NOEXCEPT
Public delay wrapper that keeps bare Arduino delay() preferred after using fl::delay; while still all...
Definition delay.h:98
expected< T, E > result
Alias for expected (Rust-style naming)
Definition result.h:31
unsigned char uint8_t
Definition s16x16x4.h:209

References FL_DBG, FL_WARN, and spi_device.