Universal millisecond timer - returns milliseconds since system startup.
This function provides consistent timing across all FastLED platforms:
- Arduino/AVR: Hardware timer-based millis()
- ESP32/ESP8266: ESP-IDF timing functions
- ARM: Platform-specific ARM timers
- WASM: JavaScript-based timing
- Native/Testing: std::chrono implementation
- Stub: Fake timer for testing
- Returns
- Number of milliseconds since the system started
- Note
- Wraps around approximately every 49.7 days (2^32 milliseconds)
-
This function is designed to be zero-overhead - it compiles to a direct platform call in optimized builds
Behavior
- Consistent: All platforms return milliseconds since startup/initialization
- Monotonic: Time always increases (except on wraparound)
- Resolution: 1 millisecond resolution on all platforms
- Wraparound: Consistent wraparound behavior at 2^32 milliseconds
Usage
do_work();
static fl::u32 last_frame = 0;
if (now - last_frame >= 16) {
render_frame();
last_frame = now;
}
while (
fl::time() < timeout && !is_complete()) {
process_step();
}
fl::u32 time()
Universal millisecond timer - returns milliseconds since system startup.
Definition at line 136 of file time.cpp.
136 {
137#ifdef FASTLED_TESTING
138
139 {
141 const auto& provider = get_time_provider();
142 if (provider) {
143 return provider();
144 }
145 }
146#endif
147
148
150}
fl::u32 get_platform_time()
Get platform-specific time in milliseconds This function contains all platform-specific timing code.
References time().
Referenced by fl::HashMapLru< Key, T, Hash, KeyEqual, INLINED_COUNT >::ValueWithTimestamp::ValueWithTimestamp(), drawPlasmaWave(), fl::task::operator=(), rainbowWave(), fl::task::set_last_run_time(), fl::TaskImpl::set_last_run_time(), time(), fl::Scheduler::update(), and fl::Scheduler::update_tasks_of_type().