FastLED 3.10.8
Loading...
Searching...
No Matches

◆ setupRpcAsyncTask()

fl::task::Handle autoresearch::setupRpcAsyncTask ( AutoResearchRemoteControl & remote_control,
int interval_ms = 10 )
inline

Setup async task for JSON-RPC processing.

Parameters
remote_controlReference to RemoteControl singleton
interval_msTask interval in milliseconds (default: 10ms)
Returns
Task handle (auto-registered with scheduler)

This function creates an async task that polls the RPC system at regular intervals, allowing RPC commands to be processed without blocking the main loop.

The 10ms default interval balances:

  • Responsiveness: 115200 baud ≈ 100 bytes in 10ms
  • CPU overhead: Minimal impact on LED peripheral operations

The task is automatically registered with the scheduler via .then() and will run until the program exits.

THREAD SAFETY:

  • Safe to capture remote_control by reference (singleton lifetime)
  • ESP32 Arduino runs on single core - task switching is atomic
  • No additional synchronization needed

Definition at line 43 of file AutoResearchAsync.h.

43 {
44 return fl::task::every_ms(interval_ms, FL_TRACE)
45 .then([&remote_control]() {
46 uint32_t current_time = millis();
47 remote_control.tick(current_time); // Calls Remote::update() which does pull + tick + push
48 });
49}
void tick(uint32_t current_millis)
Process RPC system (pull + tick + push)
Handle & then(function< void()> on_then) FL_NO_EXCEPT
Sets the callback invoked when the task runs successfully.
Definition task.cpp.hpp:276
Handle every_ms(int interval_ms) FL_NO_EXCEPT
Creates a task that runs at a fixed millisecond interval.
Definition task.cpp.hpp:320
fl::u32 uint32_t
Definition stdint.h:218
#define FL_TRACE
A macro to capture the current source file, line number, and time.
Definition trace.h:102

References fl::task::every_ms(), FL_TRACE, fl::task::Handle::then(), and AutoResearchRemoteControl::tick().

+ Here is the call graph for this function: