Commit | Line | Data |
---|---|---|
23839b8c | 1 | /* Copyright 2017 Yang Liu |
2 | * | |
3 | * This program is free software: you can redistribute it and/or modify | |
4 | * it under the terms of the GNU General Public License as published by | |
5 | * the Free Software Foundation, either version 2 of the License, or | |
6 | * (at your option) any later version. | |
7 | * | |
8 | * This program is distributed in the hope that it will be useful, | |
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 | * GNU General Public License for more details. | |
12 | * | |
13 | * You should have received a copy of the GNU General Public License | |
14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
15 | */ | |
0a40654b YL |
16 | #ifndef RGBLIGHT_H |
17 | #define RGBLIGHT_H | |
18 | ||
3774a7fc | 19 | #ifdef RGBLIGHT_ANIMATIONS |
a7882b1f | 20 | #define RGBLIGHT_MODES 34 |
57e08eb8 JH |
21 | #else |
22 | #define RGBLIGHT_MODES 1 | |
0a40654b YL |
23 | #endif |
24 | ||
ad49db8c | 25 | #ifndef RGBLIGHT_EFFECT_BREATHE_CENTER |
26 | #define RGBLIGHT_EFFECT_BREATHE_CENTER 1.85 // 1-2.7 | |
27 | #endif | |
28 | ||
29 | #ifndef RGBLIGHT_EFFECT_BREATHE_MAX | |
30 | #define RGBLIGHT_EFFECT_BREATHE_MAX 255 // 0-255 | |
31 | #endif | |
32 | ||
0a40654b | 33 | #ifndef RGBLIGHT_EFFECT_SNAKE_LENGTH |
4580d3a7 | 34 | #define RGBLIGHT_EFFECT_SNAKE_LENGTH 4 |
0a40654b YL |
35 | #endif |
36 | ||
37 | #ifndef RGBLIGHT_EFFECT_KNIGHT_LENGTH | |
4580d3a7 | 38 | #define RGBLIGHT_EFFECT_KNIGHT_LENGTH 3 |
0a40654b | 39 | #endif |
4580d3a7 | 40 | |
0a40654b | 41 | #ifndef RGBLIGHT_EFFECT_KNIGHT_OFFSET |
94f8b758 | 42 | #define RGBLIGHT_EFFECT_KNIGHT_OFFSET 0 |
0a40654b YL |
43 | #endif |
44 | ||
4580d3a7 | 45 | #ifndef RGBLIGHT_EFFECT_KNIGHT_LED_NUM |
46 | #define RGBLIGHT_EFFECT_KNIGHT_LED_NUM RGBLED_NUM | |
47 | #endif | |
48 | ||
0e548f8b | 49 | #ifndef RGBLIGHT_EFFECT_CHRISTMAS_INTERVAL |
50 | #define RGBLIGHT_EFFECT_CHRISTMAS_INTERVAL 1000 | |
51 | #endif | |
52 | ||
53 | #ifndef RGBLIGHT_EFFECT_CHRISTMAS_STEP | |
54 | #define RGBLIGHT_EFFECT_CHRISTMAS_STEP 2 | |
55 | #endif | |
56 | ||
0a40654b YL |
57 | #ifndef RGBLIGHT_HUE_STEP |
58 | #define RGBLIGHT_HUE_STEP 10 | |
59 | #endif | |
60 | #ifndef RGBLIGHT_SAT_STEP | |
61 | #define RGBLIGHT_SAT_STEP 17 | |
62 | #endif | |
63 | #ifndef RGBLIGHT_VAL_STEP | |
64 | #define RGBLIGHT_VAL_STEP 17 | |
65 | #endif | |
66 | ||
67 | #define RGBLED_TIMER_TOP F_CPU/(256*64) | |
e9f74875 | 68 | // #define RGBLED_TIMER_TOP 0xFF10 |
0a40654b YL |
69 | |
70 | #include <stdint.h> | |
71 | #include <stdbool.h> | |
72 | #include "eeconfig.h" | |
d4cd5dda | 73 | #ifndef RGBLIGHT_CUSTOM_DRIVER |
42d5a324 | 74 | #include "ws2812.h" |
d4cd5dda LR |
75 | #endif |
76 | #include "rgblight_types.h" | |
c1b46206 | 77 | #include "rgblight_list.h" |
0a40654b | 78 | |
748181dc SW |
79 | extern LED_TYPE led[RGBLED_NUM]; |
80 | ||
9b0e21f8 FS |
81 | extern const uint8_t RGBLED_BREATHING_INTERVALS[4] PROGMEM; |
82 | extern const uint8_t RGBLED_RAINBOW_MOOD_INTERVALS[3] PROGMEM; | |
83 | extern const uint8_t RGBLED_RAINBOW_SWIRL_INTERVALS[3] PROGMEM; | |
84 | extern const uint8_t RGBLED_SNAKE_INTERVALS[3] PROGMEM; | |
85 | extern const uint8_t RGBLED_KNIGHT_INTERVALS[3] PROGMEM; | |
86 | ||
0a40654b YL |
87 | typedef union { |
88 | uint32_t raw; | |
89 | struct { | |
90 | bool enable :1; | |
91 | uint8_t mode :6; | |
92 | uint16_t hue :9; | |
93 | uint8_t sat :8; | |
94 | uint8_t val :8; | |
afacd423 | 95 | uint8_t speed :8;//EECONFIG needs to be increased to support this |
0a40654b YL |
96 | }; |
97 | } rgblight_config_t; | |
98 | ||
99 | void rgblight_init(void); | |
100 | void rgblight_increase(void); | |
101 | void rgblight_decrease(void); | |
102 | void rgblight_toggle(void); | |
285c5a91 | 103 | void rgblight_enable(void); |
16546ee0 | 104 | void rgblight_disable(void); |
0a40654b | 105 | void rgblight_step(void); |
5a1b68d5 | 106 | void rgblight_step_reverse(void); |
4580d3a7 | 107 | uint32_t rgblight_get_mode(void); |
0a40654b YL |
108 | void rgblight_mode(uint8_t mode); |
109 | void rgblight_set(void); | |
2e23689b | 110 | void rgblight_update_dword(uint32_t dword); |
0a40654b YL |
111 | void rgblight_increase_hue(void); |
112 | void rgblight_decrease_hue(void); | |
113 | void rgblight_increase_sat(void); | |
114 | void rgblight_decrease_sat(void); | |
115 | void rgblight_increase_val(void); | |
116 | void rgblight_decrease_val(void); | |
afacd423 | 117 | void rgblight_increase_speed(void); |
118 | void rgblight_decrease_speed(void); | |
0a40654b | 119 | void rgblight_sethsv(uint16_t hue, uint8_t sat, uint8_t val); |
12e66330 | 120 | uint16_t rgblight_get_hue(void); |
121 | uint8_t rgblight_get_sat(void); | |
122 | uint8_t rgblight_get_val(void); | |
0a40654b | 123 | void rgblight_setrgb(uint8_t r, uint8_t g, uint8_t b); |
16546ee0 CG |
124 | void rgblight_setrgb_at(uint8_t r, uint8_t g, uint8_t b, uint8_t index); |
125 | void rgblight_sethsv_at(uint16_t hue, uint8_t sat, uint8_t val, uint8_t index); | |
0a40654b | 126 | |
0a40654b | 127 | uint32_t eeconfig_read_rgblight(void); |
620ac4b2 ET |
128 | void eeconfig_update_rgblight(uint32_t val); |
129 | void eeconfig_update_rgblight_default(void); | |
0a40654b YL |
130 | void eeconfig_debug_rgblight(void); |
131 | ||
afacd423 | 132 | void rgb_matrix_increase(void); |
133 | void rgb_matrix_decrease(void); | |
134 | ||
e9f74875 JH |
135 | void sethsv(uint16_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1); |
136 | void setrgb(uint8_t r, uint8_t g, uint8_t b, LED_TYPE *led1); | |
751719e6 | 137 | |
0a40654b | 138 | void rgblight_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val); |
751719e6 DJ |
139 | void rgblight_mode_noeeprom(uint8_t mode); |
140 | void rgblight_toggle_noeeprom(void); | |
141 | void rgblight_enable_noeeprom(void); | |
142 | void rgblight_disable_noeeprom(void); | |
143 | ||
144 | void rgblight_sethsv_eeprom_helper(uint16_t hue, uint8_t sat, uint8_t val, bool write_to_eeprom); | |
145 | void rgblight_mode_eeprom_helper(uint8_t mode, bool write_to_eeprom); | |
146 | ||
0a40654b | 147 | |
4094544d EZ |
148 | #define EZ_RGB(val) rgblight_show_solid_color((val >> 16) & 0xFF, (val >> 8) & 0xFF, val & 0xFF) |
149 | void rgblight_show_solid_color(uint8_t r, uint8_t g, uint8_t b); | |
e9f74875 JH |
150 | |
151 | void rgblight_task(void); | |
152 | ||
0a40654b YL |
153 | void rgblight_timer_init(void); |
154 | void rgblight_timer_enable(void); | |
155 | void rgblight_timer_disable(void); | |
156 | void rgblight_timer_toggle(void); | |
157 | void rgblight_effect_breathing(uint8_t interval); | |
158 | void rgblight_effect_rainbow_mood(uint8_t interval); | |
159 | void rgblight_effect_rainbow_swirl(uint8_t interval); | |
160 | void rgblight_effect_snake(uint8_t interval); | |
161 | void rgblight_effect_knight(uint8_t interval); | |
cae269b0 | 162 | void rgblight_effect_christmas(void); |
0a40654b YL |
163 | |
164 | #endif |