FastLED 3.9.15
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 156 of file async_logger.cpp.hpp.

156 {
157 detail::BackgroundFlushState& state = Singleton<detail::BackgroundFlushState>::instance();
158
159 // If already enabled, disable first
160 if (state.mEnabled) {
162 }
163
164 // Configure flush parameters
165 state.mMessagesPerTick = messages_per_tick;
166
167 // Setup ISR timer configuration
168 fl::isr::config config;
170 config.user_data = &state;
171 config.frequency_hz = 1000 / interval_ms; // Convert ms to Hz
172 config.priority = fl::isr::ISR_PRIORITY_LOW; // Low priority to avoid interfering with LED timing
174
175 // Attach timer ISR (returns 0 on success, negative on error)
176 if (fl::isr::attach_timer_handler(config, &state.mTimerHandle) != 0) {
177 return false; // Platform doesn't support timers or attachment failed
178 }
179
180 state.mEnabled = true;
181 return true;
182}
TestState state
void disableBackgroundFlush()
Disable background flushing.
static T & instance() FL_NOEXCEPT
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: