FastLED 3.10.8
Loading...
Searching...
No Matches
Test.ino
Go to the documentation of this file.
1
4
5
6
7#include <Arduino.h>
8#include <FastLED.h>
9
10
11// Test configuration
12
13// Compile-time regression for FastLED#4827: legacy sketches call libc memory
14// functions unqualified on CRGB*. These must stay unambiguous on every board.
15static void legacyLibcOnCrgb() {
16 CRGB src[4] = {CRGB(1, 2, 3), CRGB(4, 5, 6), CRGB(7, 8, 9), CRGB(10, 11, 12)};
17 CRGB* dst = static_cast<CRGB*>(malloc(sizeof(CRGB) * 4)); // ok bare allocation
18 if (!dst) {
19 return;
20 }
21 memset(dst, 0, sizeof(CRGB) * 4);
22 memcpy(dst, src, sizeof(CRGB) * 4);
23 memmove(dst + 1, dst, sizeof(CRGB) * 3);
24 if (memcmp(dst, src, sizeof(CRGB)) != 0) {
25 Serial.println("legacy libc copy mismatch");
26 }
27 free(dst); // ok bare allocation
28}
29
30
31void setup() {
32 Serial.begin(115200); // Fast baud for avr8js
33 Serial.println("Test setup starting");
35
36
37 delay(100);
38}
39
40void loop() {
41 EVERY_N_MILLIS(1000) {
42 Serial.println("Test loop!");
43 }
44#if defined(FASTLED_ESP32_IS_QEMU)
45 // Busy-wait under Espressif QEMU. delay() sleeps in vTaskDelay until a
46 // timer-alarm tick wakes the task; on a loaded host the emulator
47 // sometimes never delivers that wake-up and loop() stalls for good
48 // (FastLED#4845: ~1 s into the run, every local repro on esp32c3). The
49 // EVERY_N_MILLIS above still exercises millis().
50 delayMicroseconds(1000);
51#else
52 delay(1); // Yield to the idle task (feeds the task watchdog).
53#endif
54}
void setup()
void loop()
static void legacyLibcOnCrgb()
Definition Test.ino:15
fl::CRGB CRGB
Definition crgb.h:25
#define EVERY_N_MILLIS(N)
Checks whether to execute a block of code every N milliseconds.
Definition lib8tion.h:1001
#define Serial
Definition serial.h:309