FastLED 3.9.15
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 "fl/stdint.h"
9
11
14
24
26 return uint16_t(x) * 0x101;
27}
28
30 return uint32_t(x) * 0x10001;
31}
32
33// map16_to_8: map 16-bit values to 8-bit values
34// This function maps 16-bit values to 8-bit values.
36 // Tested to be nearly identical to double precision floating point
37 // doing this operation.
38 if (x == 0) {
39 return 0;
40 }
41 if (x >= 0xff00) {
42 return 0xff;
43 }
44 return uint8_t((x + 128) >> 8);
45}
46
48 // Tested to be nearly identical to double precision floating point
49 // doing this operation.
50 if (x == 0) {
51 return 0;
52 }
53 if (x >= 0xffff0000) {
54 return 0xffff;
55 }
56 return uint16_t((x + 32768) >> 16);
57}
58
60 return uint32_t(x) * 0x1010101;
61}
62
65
int x
Definition simple.h:92
LIB8STATIC_ALWAYS_INLINE uint32_t map16_to_32(uint16_t x)
Definition intmap.h:29
LIB8STATIC_ALWAYS_INLINE uint8_t map16_to_8(uint16_t x)
Definition intmap.h:35
LIB8STATIC_ALWAYS_INLINE uint32_t map8_to_32(uint8_t x)
Definition intmap.h:59
LIB8STATIC_ALWAYS_INLINE uint16_t map32_to_16(uint32_t x)
Definition intmap.h:47
LIB8STATIC_ALWAYS_INLINE uint16_t map8_to_16(uint8_t x)
Definition intmap.h:25
#define LIB8STATIC_ALWAYS_INLINE
Define a LIB8TION member function as always static inline.
Definition lib8static.h:12
Defines static inlining macros for lib8tion functions.
#define FASTLED_NAMESPACE_END
Definition namespace.h:23
#define FASTLED_NAMESPACE_BEGIN
Definition namespace.h:22
Implements the FastLED namespace macros.