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

◆ loop()

void loop ( )

Definition at line 358 of file NetTestReal.h.

358 {
359 // TUTORIAL: Cycle between different async approaches every 10 seconds
360 // This allows you to see both promise-based and await-based patterns in action
361 // The LEDs provide visual feedback about which approach succeeded
362
363 unsigned long current_time = millis();
364
365 // Switch approaches every 10 seconds
366 // 4 different approaches: Promise, Await, JSON Promise, JSON Await
367 if (current_time - last_request_time >= 10000) {
368 last_request_time = current_time;
369
370 // Cycle through 4 different approaches
371 if (approach_counter % 4 == 0) {
373 FL_WARN("CYCLE: Demonstrated Promise-based pattern (Green LEDs on success)");
374 } else if (approach_counter % 4 == 1) {
376 FL_WARN("CYCLE: Demonstrated Await-based pattern (Blue LEDs on success)");
377 } else if (approach_counter % 4 == 2) {
379 FL_WARN("CYCLE: Demonstrated JSON Promise pattern (Blue LEDs on success)");
380 } else if (approach_counter % 4 == 3) {
382 FL_WARN("CYCLE: Demonstrated JSON Await pattern (Cyan LEDs on success)");
383 }
384
386
387 FL_WARN("NEXT: Will switch to next approach in 10 seconds...");
388 }
389
390 // TUTORIAL NOTE: Async operations are automatically managed!
391 // * On WASM: delay() pumps async tasks every 1ms automatically
392 // * On all platforms: FastLED.show() triggers async updates via engine events
393 // * No manual async updates needed - everything happens behind the scenes!
394
395
396 // TUTORIAL: This delay automatically pumps async tasks on WASM!
397 // The delay is broken into 1ms chunks with async processing between chunks.
398 // This isn't necessary when calling the await approach, but is critical
399 // the standard promise.then() approach.
400 // Note: In the future loop() may become a macro to inject auto pumping
401 // of the async tasks.
402 delay(10);
403}
static u32 last_request_time
Definition NetTestReal.h:87
void test_promise_approach()
void test_json_await()
APPROACH 4: JSON Response with await pattern Same JSON handling but using await_top_level for synch...
void test_await_approach()
void test_json_response()
APPROACH 3: JSON Response Handling with FastLED's ideal JSON API This demonstrates fetch responses wi...
static int approach_counter
Definition NetTestReal.h:88
#define FL_WARN
Definition warn.h:12

References approach_counter, FL_WARN, last_request_time, test_await_approach(), test_json_await(), test_json_response(), and test_promise_approach().

+ Here is the call graph for this function: