-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathplume_map.h
71 lines (57 loc) · 2.23 KB
/
plume_map.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
* Copyright Ben XO https://github.com/ben-xo All rights reserved.
*/
#include "config.h"
#define FADE_PLUME_FACTOR 51.0
#define FADE_PLUME_SCALE FADE_PLUME_FACTOR / ((float)STRIP_LENGTH/2)
// adapted from http://lolengine.net/blog/2011/12/20/cpp-lookup-table-generation
// Macro expansion for building tables with sizes of powers of 2
#define S4(i) S1((i)), S1((i)+1), S1((i)+2), S1((i)+3)
#define S16(i) S4((i)), S4((i)+4), S4((i)+8), S4((i)+12)
#define S64(i) S16((i)), S16((i)+16), S16((i)+32), S16((i)+48)
#define S256(i) S64((i)), S64((i)+64), S64((i)+128), S64((i)+192)
#define S1024(i) S256((i)), S256((i)+256), S256((i)+512), S256((i)+768)
#define BS4(i) BS1((i)), BS1((i)+1), BS1((i)+2), BS1((i)+3)
#define BS16(i) BS4((i)), BS4((i)+4), BS4((i)+8), BS4((i)+12)
#define BS64(i) BS16((i)), BS16((i)+16), BS16((i)+32), BS16((i)+48)
#define BS256(i) BS64((i)), BS64((i)+64), BS64((i)+128), BS64((i)+192)
#define BS1024(i) BS256((i)), BS256((i)+256), BS256((i)+512), BS256((i)+768)
# define BS1(i) ((uint8_t) (-(i * FADE_PLUME_SCALE) + FADE_PLUME_FACTOR))
# define S1(i) ((uint8_t) ((i - (STRIP_LENGTH/2)) * FADE_PLUME_SCALE))
/** STATIC LOOKUP TABLES FOR PLUME SCALING **/
#if STRIP_LENGTH > 128
static const uint8_t PROGMEM fade_pixel_plume_map[128] = {
BS64(0), BS64(64)
};
static const uint8_t PROGMEM fade_pixel_plume_map2[128] = {
S64(STRIP_LENGTH/2), S64(STRIP_LENGTH/2 + 64)
};
#elif STRIP_LENGTH > 64
static const uint8_t PROGMEM fade_pixel_plume_map[64] = {
BS64(0)
};
static const uint8_t PROGMEM fade_pixel_plume_map2[64] = {
S64(STRIP_LENGTH/2)
};
#elif STRIP_LENGTH > 32
static const uint8_t PROGMEM fade_pixel_plume_map[32] = {
BS16(0), BS16(16)
};
static const uint8_t PROGMEM fade_pixel_plume_map2[32] = {
S16(STRIP_LENGTH/2), S16(STRIP_LENGTH/2 + 16)
};
#elif STRIP_LENGTH > 16
static const uint8_t PROGMEM fade_pixel_plume_map[16] = {
BS16(0),
};
static const uint8_t PROGMEM fade_pixel_plume_map2[16] = {
S16(STRIP_LENGTH/2)
};
#else
static const uint8_t PROGMEM fade_pixel_plume_map[8] = {
BS4(0), BS4(4)
};
static const uint8_t PROGMEM fade_pixel_plume_map2[8] = {
S4(STRIP_LENGTH/2), S4(STRIP_LENGTH/2 + 4)
};
#endif