FastLED 3.9.15
Loading...
Searching...
No Matches
time.h File Reference

Detailed Description

Universal timing functions for FastLED.

This header provides a universal fl::time() function that works consistently across all FastLED-supported platforms. It abstracts away platform-specific timing implementations and provides a clean, testable API.

Usage

#include "fl/time.h"
void loop() {
fl::u32 now = fl::time();
// Use timing for animations
static fl::u32 last_update = 0;
if (now - last_update >= 16) { // ~60 FPS
update_animation();
last_update = now;
}
}
void loop()
Universal timing functions for FastLED.
fl::u32 time()
Universal millisecond timer - returns milliseconds since system startup.
Definition time.cpp:136

Support

For unit testing, time injection is available:

#ifdef FASTLED_TESTING
#include "fl/time.h"
TEST(AnimationTest, TimingTest) {
fl::MockTimeProvider mock(1000);
fl::inject_time_provider(mock);
EXPECT_EQ(fl::time(), 1000);
mock.advance(16);
EXPECT_EQ(fl::time(), 1016);
fl::clear_time_provider();
}
#endif

Definition in file time.h.

#include "fl/namespace.h"
#include "fl/int.h"
+ Include dependency graph for time.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  fl
 IMPORTANT!
 

Functions

fl::u32 fl::time ()
 Universal millisecond timer - returns milliseconds since system startup.