FastLED 3.9.15
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 34 of file AutoResearchAsync.h.

34 {
35 return fl::task::every_ms(interval_ms, FL_TRACE)
36 .then([&remote_control]() {
37 uint32_t current_time = millis();
38 remote_control.tick(current_time); // Calls Remote::update() which does pull + tick + push
39 });
40}
void tick(uint32_t current_millis)
Process RPC system (pull + tick + push)
Handle & then(function< void()> on_then) FL_NOEXCEPT
Definition task.cpp.hpp:276
Handle every_ms(int interval_ms)
Definition task.cpp.hpp:320
#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().

Referenced by setup().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: