FastLED 3.10.6
Loading...
Searching...
No Matches

◆ enableBackgroundFlush()

bool fl::AsyncLogger::enableBackgroundFlush ( fl::u32 interval_ms,
fl::size messages_per_tick = 5 )

Enable background timer-based flushing (opt-in)

Parameters
interval_msFlush interval in milliseconds (e.g., 100 = 10 Hz)
messages_per_tickMaximum messages to flush per timer tick (default 5)
Returns
true if enabled successfully, false if platform doesn't support timers

Definition at line 158 of file async_logger.cpp.hpp.

158 {
159 detail::BackgroundFlushState& state = Singleton<detail::BackgroundFlushState>::instance();
160
161 // If already enabled, disable first
162 if (state.mEnabled) {
164 }
165
166 // Configure flush parameters
167 state.mMessagesPerTick = messages_per_tick;
168
169 // Setup ISR timer configuration
170 fl::isr::config config;
172 config.user_data = &state;
173 config.frequency_hz = 1000 / interval_ms; // Convert ms to Hz
174 config.priority = fl::isr::ISR_PRIORITY_LOW; // Low priority to avoid interfering with LED timing
176
177 // Attach timer ISR (returns 0 on success, negative on error)
178 if (fl::isr::attach_timer_handler(config, &state.mTimerHandle) != 0) {
179 return false; // Platform doesn't support timers or attachment failed
180 }
181
182 state.mEnabled = true;
183 return true;
184}
TestState state
void disableBackgroundFlush()
Disable background flushing.
static T & instance() FL_NO_EXCEPT
Definition singleton.h:41
void FL_IRAM async_log_flush_timer_isr(void *user_data)
constexpr u32 ISR_FLAG_IRAM_SAFE
Definition constants.h:21
int attach_timer_handler(const config &cfg, handle *out_handle)
Attach a timer-based ISR handler.
constexpr u8 ISR_PRIORITY_LOW
Definition constants.h:13
handler_fn handler
Definition handler.h:20
void * user_data
Definition handler.h:21

References fl::detail::async_log_flush_timer_isr(), fl::isr::attach_timer_handler(), disableBackgroundFlush(), fl::isr::config::flags, fl::isr::config::frequency_hz, fl::isr::config::handler, fl::Singleton< T, N >::instance(), fl::isr::ISR_FLAG_IRAM_SAFE, fl::isr::ISR_PRIORITY_LOW, fl::isr::config::priority, state, and fl::isr::config::user_data.

Referenced by ~AsyncLogger().

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