FastLED 3.9.15
Loading...
Searching...
No Matches
time_functions.h
Go to the documentation of this file.
1#pragma once
2
5
6#include "fl/stl/int.h"
7#include "fl/stl/chrono.h" // fl::millis()
9#include "platforms/is_platform.h" // FL_IS_AVR
10#include "fl/stl/noexcept.h"
11
12namespace fl {
13
16
19 u32 ms = fl::millis();
20 u16 s16;
21 s16 = ms / 1000;
22 return s16;
23}
24
27 u32 ms = fl::millis();
28 u16 m16;
29 m16 = (ms / (60000L)) & 0xFFFF;
30 return m16;
31}
32
35 u32 ms = fl::millis();
36 u8 h8;
37 h8 = (ms / (3600000L)) & 0xFF;
38 return h8;
39}
40
46 u16 out16;
47#if defined(FL_IS_AVR)
48 asm volatile(" lsr %D[in] \n\t"
49 " ror %C[in] \n\t"
50 " ror %B[in] \n\t"
51 " lsr %D[in] \n\t"
52 " ror %C[in] \n\t"
53 " ror %B[in] \n\t"
54 " mov %B[out],%C[in] \n\t"
55 " mov %A[out],%B[in] \n\t"
56 : [in] "+r"(in32), [out] "=r"(out16));
57#else
58 out16 = (in32 >> 10) & 0xFFFF;
59#endif
60 return out16;
61}
62
67 u32 ms = fl::millis();
68 u16 s16;
69 s16 = div1024_32_16(ms);
70 return s16;
71}
72
74
75} // namespace fl
FastLED chrono implementation - duration types for time measurements.
Defines static inlining macros for lib8tion functions.
LIB8STATIC u16 bseconds16() FL_NOEXCEPT
Returns the current time-since-boot in "binary seconds", which are actually 1024/1000 of a second lon...
LIB8STATIC u16 div1024_32_16(u32 in32) FL_NOEXCEPT
Helper routine to divide a 32-bit value by 1024, returning only the low 16 bits.
LIB8STATIC u16 minutes16() FL_NOEXCEPT
Return the current minutes since boot in a 16-bit value.
LIB8STATIC u16 seconds16() FL_NOEXCEPT
Return the current seconds since boot in a 16-bit value.
LIB8STATIC u8 hours8() FL_NOEXCEPT
Return the current hours since boot in an 8-bit value.
#define LIB8STATIC
Define a LIB8TION member function as static inline with an "unused" attribute.
Definition lib8static.h:12
unsigned char u8
Definition stdint.h:131
fl::u32 millis()
Universal millisecond timer - returns milliseconds since system startup.
Base definition for an LED controller.
Definition crgb.hpp:179
#define FL_NOEXCEPT