FastLED 3.9.7
Loading...
Searching...
No Matches
intmap.h
Go to the documentation of this file.
1
3
4#pragma once
5
6#include "fl/namespace.h"
7#include "lib8static.h"
8#include <stdint.h>
9
11
14
24
25LIB8STATIC_ALWAYS_INLINE uint16_t map8_to_16(uint8_t x) {
26 return uint16_t(x) * 0x101;
27}
28
29// map16_to_8: map 16-bit values to 8-bit values
30// This function maps 16-bit values to 8-bit values.
31LIB8STATIC_ALWAYS_INLINE uint8_t map16_to_8(uint16_t x) {
32 // Tested to be nearly identical to double precision floating point
33 // doing this operation.
34 if (x == 0) {
35 return 0;
36 }
37 if (x >= 0xff00) {
38 return 0xff;
39 }
40 return uint8_t((x + 128) >> 8);
41}
42
43LIB8STATIC_ALWAYS_INLINE uint32_t map8_to_32(uint8_t x) {
44 return uint32_t(x) * 0x1010101;
45}
46
49
#define LIB8STATIC_ALWAYS_INLINE
Define a LIB8TION member function as always static inline.
Definition lib8static.h:12
Defines static inlining macros for lib8tion functions.
Implements the FastLED namespace macros.
#define FASTLED_NAMESPACE_END
End of the FastLED namespace.
Definition namespace.h:16
#define FASTLED_NAMESPACE_BEGIN
Start of the FastLED namespace.
Definition namespace.h:14