diff options
author | Wilba <Jason.S.Williams@gmail.com> | 2020-01-21 05:18:25 +1100 |
---|---|---|
committer | MechMerlin <30334081+mechmerlin@users.noreply.github.com> | 2020-01-20 10:18:25 -0800 |
commit | 484a9b12bc3961fc0dd9481d3cb734959db42191 (patch) | |
tree | ca2e4219b6514c1033be3ab3a975bd24f723f2ba | |
parent | ce81c4f89b61560ee35436b351b27fd23568c32f (diff) | |
download | qmk_firmware-484a9b12bc3961fc0dd9481d3cb734959db42191.tar.gz qmk_firmware-484a9b12bc3961fc0dd9481d3cb734959db42191.zip |
Add VIA support for QMK backlight, QMK RGBLight (#7911)
* Add VIA support for QMK backlight, QMK RGBLight
* clang-format changes
37 files changed, 500 insertions, 35 deletions
diff --git a/keyboards/cannonkeys/an_c/config.h b/keyboards/cannonkeys/an_c/config.h index 55414ba50..6390e0789 100644 --- a/keyboards/cannonkeys/an_c/config.h +++ b/keyboards/cannonkeys/an_c/config.h | |||
@@ -62,6 +62,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
62 | // dynamic keymaps start after this. | 62 | // dynamic keymaps start after this. |
63 | #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 1 | 63 | #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 1 |
64 | 64 | ||
65 | // VIA lighting is handled by the keyboard-level code | ||
66 | #define VIA_CUSTOM_LIGHTING_ENABLE | ||
67 | |||
68 | // Let VIA handle the QMK RGBLIGHT | ||
69 | #define VIA_QMK_RGBLIGHT_ENABLE | ||
70 | |||
65 | /* | 71 | /* |
66 | * Feature disable options | 72 | * Feature disable options |
67 | * These options are also useful to firmware size reduction. | 73 | * These options are also useful to firmware size reduction. |
diff --git a/keyboards/cannonkeys/instant60/config.h b/keyboards/cannonkeys/instant60/config.h index 2d23d5f83..4fa76cb88 100644 --- a/keyboards/cannonkeys/instant60/config.h +++ b/keyboards/cannonkeys/instant60/config.h | |||
@@ -62,6 +62,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
62 | // dynamic keymaps start after this. | 62 | // dynamic keymaps start after this. |
63 | #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 1 | 63 | #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 1 |
64 | 64 | ||
65 | // VIA lighting is handled by the keyboard-level code | ||
66 | #define VIA_CUSTOM_LIGHTING_ENABLE | ||
67 | |||
68 | // Let VIA handle the QMK RGBLIGHT | ||
69 | #define VIA_QMK_RGBLIGHT_ENABLE | ||
70 | |||
65 | /* | 71 | /* |
66 | * Feature disable options | 72 | * Feature disable options |
67 | * These options are also useful to firmware size reduction. | 73 | * These options are also useful to firmware size reduction. |
diff --git a/keyboards/cannonkeys/iron165/config.h b/keyboards/cannonkeys/iron165/config.h index 640f6fb65..6350514d7 100644 --- a/keyboards/cannonkeys/iron165/config.h +++ b/keyboards/cannonkeys/iron165/config.h | |||
@@ -54,6 +54,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
54 | // dynamic keymaps start after this. | 54 | // dynamic keymaps start after this. |
55 | #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 1 | 55 | #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 1 |
56 | 56 | ||
57 | // VIA lighting is handled by the keyboard-level code | ||
58 | #define VIA_CUSTOM_LIGHTING_ENABLE | ||
59 | |||
57 | /* | 60 | /* |
58 | * Feature disable options | 61 | * Feature disable options |
59 | * These options are also useful to firmware size reduction. | 62 | * These options are also useful to firmware size reduction. |
diff --git a/keyboards/cannonkeys/satisfaction75/config.h b/keyboards/cannonkeys/satisfaction75/config.h index 7a4354c8a..69d02806e 100644 --- a/keyboards/cannonkeys/satisfaction75/config.h +++ b/keyboards/cannonkeys/satisfaction75/config.h | |||
@@ -73,6 +73,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
73 | // 6 for 3x custom encoder settings, left, right, and press (18 bytes) | 73 | // 6 for 3x custom encoder settings, left, right, and press (18 bytes) |
74 | #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 21 | 74 | #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 21 |
75 | 75 | ||
76 | // VIA lighting is handled by the keyboard-level code | ||
77 | #define VIA_CUSTOM_LIGHTING_ENABLE | ||
78 | |||
76 | /* | 79 | /* |
77 | * Feature disable options | 80 | * Feature disable options |
78 | * These options are also useful to firmware size reduction. | 81 | * These options are also useful to firmware size reduction. |
diff --git a/keyboards/cannonkeys/satisfaction75/led_custom.h b/keyboards/cannonkeys/satisfaction75/led_custom.h index fe5c9e5dc..d818b48ce 100644 --- a/keyboards/cannonkeys/satisfaction75/led_custom.h +++ b/keyboards/cannonkeys/satisfaction75/led_custom.h | |||
@@ -3,3 +3,5 @@ | |||
3 | void backlight_task(void); | 3 | void backlight_task(void); |
4 | void breathing_interrupt_disable(void); | 4 | void breathing_interrupt_disable(void); |
5 | void breathing_interrupt_enable(void); | 5 | void breathing_interrupt_enable(void); |
6 | void breathing_enable(void); | ||
7 | void breathing_disable(void); | ||
diff --git a/keyboards/cannonkeys/satisfaction75/satisfaction75.c b/keyboards/cannonkeys/satisfaction75/satisfaction75.c index 0fe09c384..f92067c98 100644 --- a/keyboards/cannonkeys/satisfaction75/satisfaction75.c +++ b/keyboards/cannonkeys/satisfaction75/satisfaction75.c | |||
@@ -55,6 +55,54 @@ backlight_config_t kb_backlight_config = { | |||
55 | }; | 55 | }; |
56 | 56 | ||
57 | #ifdef VIA_ENABLE | 57 | #ifdef VIA_ENABLE |
58 | |||
59 | void backlight_get_value( uint8_t *data ) | ||
60 | { | ||
61 | uint8_t *value_id = &(data[0]); | ||
62 | uint8_t *value_data = &(data[1]); | ||
63 | switch (*value_id) | ||
64 | { | ||
65 | case id_qmk_backlight_brightness: | ||
66 | { | ||
67 | // level / BACKLIGHT_LEVELS * 255 | ||
68 | value_data[0] = ((uint16_t)kb_backlight_config.level) * 255 / BACKLIGHT_LEVELS; | ||
69 | break; | ||
70 | } | ||
71 | case id_qmk_backlight_effect: | ||
72 | { | ||
73 | value_data[0] = kb_backlight_config.breathing ? 1 : 0; | ||
74 | break; | ||
75 | } | ||
76 | } | ||
77 | } | ||
78 | |||
79 | void backlight_set_value( uint8_t *data ) | ||
80 | { | ||
81 | uint8_t *value_id = &(data[0]); | ||
82 | uint8_t *value_data = &(data[1]); | ||
83 | switch (*value_id) | ||
84 | { | ||
85 | case id_qmk_backlight_brightness: | ||
86 | { | ||
87 | // level / 255 * BACKLIGHT_LEVELS | ||
88 | kb_backlight_config.level = ((uint16_t)value_data[0]) * BACKLIGHT_LEVELS / 255; | ||
89 | backlight_set(kb_backlight_config.level); | ||
90 | break; | ||
91 | } | ||
92 | case id_qmk_backlight_effect: | ||
93 | { | ||
94 | if ( value_data[0] == 0 ) { | ||
95 | kb_backlight_config.breathing = false; | ||
96 | breathing_disable(); | ||
97 | } else { | ||
98 | kb_backlight_config.breathing = true; | ||
99 | breathing_enable(); | ||
100 | } | ||
101 | break; | ||
102 | } | ||
103 | } | ||
104 | } | ||
105 | |||
58 | void raw_hid_receive_kb( uint8_t *data, uint8_t length ) | 106 | void raw_hid_receive_kb( uint8_t *data, uint8_t length ) |
59 | { | 107 | { |
60 | uint8_t *command_id = &(data[0]); | 108 | uint8_t *command_id = &(data[0]); |
@@ -139,6 +187,21 @@ void raw_hid_receive_kb( uint8_t *data, uint8_t length ) | |||
139 | } | 187 | } |
140 | break; | 188 | break; |
141 | } | 189 | } |
190 | case id_lighting_set_value: | ||
191 | { | ||
192 | backlight_set_value(command_data); | ||
193 | break; | ||
194 | } | ||
195 | case id_lighting_get_value: | ||
196 | { | ||
197 | backlight_get_value(command_data); | ||
198 | break; | ||
199 | } | ||
200 | case id_lighting_save: | ||
201 | { | ||
202 | backlight_config_save(); | ||
203 | break; | ||
204 | } | ||
142 | default: | 205 | default: |
143 | { | 206 | { |
144 | // Unhandled message. | 207 | // Unhandled message. |
diff --git a/keyboards/cannonkeys/savage65/config.h b/keyboards/cannonkeys/savage65/config.h index b69aba39e..98ec1067a 100644 --- a/keyboards/cannonkeys/savage65/config.h +++ b/keyboards/cannonkeys/savage65/config.h | |||
@@ -62,6 +62,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
62 | // dynamic keymaps start after this. | 62 | // dynamic keymaps start after this. |
63 | #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 1 | 63 | #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 1 |
64 | 64 | ||
65 | // VIA lighting is handled by the keyboard-level code | ||
66 | #define VIA_CUSTOM_LIGHTING_ENABLE | ||
67 | |||
68 | // Let VIA handle the QMK RGBLIGHT | ||
69 | #define VIA_QMK_RGBLIGHT_ENABLE | ||
70 | |||
65 | /* | 71 | /* |
66 | * Feature disable options | 72 | * Feature disable options |
67 | * These options are also useful to firmware size reduction. | 73 | * These options are also useful to firmware size reduction. |
diff --git a/keyboards/cannonkeys/stm32f072/keyboard.c b/keyboards/cannonkeys/stm32f072/keyboard.c index bf35a76c1..fdda018fc 100644 --- a/keyboards/cannonkeys/stm32f072/keyboard.c +++ b/keyboards/cannonkeys/stm32f072/keyboard.c | |||
@@ -126,8 +126,86 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) { | |||
126 | return process_record_user(keycode, record);; | 126 | return process_record_user(keycode, record);; |
127 | } | 127 | } |
128 | 128 | ||
129 | #ifdef VIA_ENABLE | ||
129 | 130 | ||
131 | void backlight_get_value( uint8_t *data ) | ||
132 | { | ||
133 | uint8_t *value_id = &(data[0]); | ||
134 | uint8_t *value_data = &(data[1]); | ||
135 | switch (*value_id) | ||
136 | { | ||
137 | case id_qmk_backlight_brightness: | ||
138 | { | ||
139 | // level / BACKLIGHT_LEVELS * 255 | ||
140 | value_data[0] = ((uint16_t)kb_backlight_config.level) * 255 / BACKLIGHT_LEVELS; | ||
141 | break; | ||
142 | } | ||
143 | case id_qmk_backlight_effect: | ||
144 | { | ||
145 | value_data[0] = kb_backlight_config.breathing ? 1 : 0; | ||
146 | break; | ||
147 | } | ||
148 | } | ||
149 | } | ||
130 | 150 | ||
151 | void backlight_set_value( uint8_t *data ) | ||
152 | { | ||
153 | uint8_t *value_id = &(data[0]); | ||
154 | uint8_t *value_data = &(data[1]); | ||
155 | switch (*value_id) | ||
156 | { | ||
157 | case id_qmk_backlight_brightness: | ||
158 | { | ||
159 | // level / 255 * BACKLIGHT_LEVELS | ||
160 | kb_backlight_config.level = ((uint16_t)value_data[0]) * BACKLIGHT_LEVELS / 255; | ||
161 | backlight_set(kb_backlight_config.level); | ||
162 | break; | ||
163 | } | ||
164 | case id_qmk_backlight_effect: | ||
165 | { | ||
166 | if ( value_data[0] == 0 ) { | ||
167 | kb_backlight_config.breathing = false; | ||
168 | breathing_disable(); | ||
169 | } else { | ||
170 | kb_backlight_config.breathing = true; | ||
171 | breathing_enable(); | ||
172 | } | ||
173 | break; | ||
174 | } | ||
175 | } | ||
176 | } | ||
177 | |||
178 | void raw_hid_receive_kb( uint8_t *data, uint8_t length ) | ||
179 | { | ||
180 | uint8_t *command_id = &(data[0]); | ||
181 | uint8_t *command_data = &(data[1]); | ||
182 | switch ( *command_id ) | ||
183 | { | ||
184 | case id_lighting_set_value: | ||
185 | { | ||
186 | backlight_set_value(command_data); | ||
187 | break; | ||
188 | } | ||
189 | case id_lighting_get_value: | ||
190 | { | ||
191 | backlight_get_value(command_data); | ||
192 | break; | ||
193 | } | ||
194 | case id_lighting_save: | ||
195 | { | ||
196 | backlight_config_save(); | ||
197 | break; | ||
198 | } | ||
199 | default: | ||
200 | { | ||
201 | // Unhandled message. | ||
202 | *command_id = id_unhandled; | ||
203 | break; | ||
204 | } | ||
205 | } | ||
206 | // DO NOT call raw_hid_send(data,length) here, let caller do this | ||
207 | } | ||
208 | #endif | ||
131 | 209 | ||
132 | // | 210 | // |
133 | // In the case of VIA being disabled, we still need to check if | 211 | // In the case of VIA being disabled, we still need to check if |
diff --git a/keyboards/cannonkeys/stm32f072/led_custom.h b/keyboards/cannonkeys/stm32f072/led_custom.h index 28e0f02ed..550d5b84c 100644 --- a/keyboards/cannonkeys/stm32f072/led_custom.h +++ b/keyboards/cannonkeys/stm32f072/led_custom.h | |||
@@ -4,3 +4,5 @@ void backlight_task(void); | |||
4 | void breathing_interrupt_disable(void); | 4 | void breathing_interrupt_disable(void); |
5 | void breathing_interrupt_enable(void); | 5 | void breathing_interrupt_enable(void); |
6 | void breathing_toggle(void); | 6 | void breathing_toggle(void); |
7 | void breathing_enable(void); | ||
8 | void breathing_disable(void); | ||
diff --git a/keyboards/cannonkeys/tmov2/config.h b/keyboards/cannonkeys/tmov2/config.h index d5f1d0788..159382fbc 100644 --- a/keyboards/cannonkeys/tmov2/config.h +++ b/keyboards/cannonkeys/tmov2/config.h | |||
@@ -62,6 +62,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
62 | // dynamic keymaps start after this. | 62 | // dynamic keymaps start after this. |
63 | #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 1 | 63 | #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 1 |
64 | 64 | ||
65 | // VIA lighting is handled by the keyboard-level code | ||
66 | #define VIA_CUSTOM_LIGHTING_ENABLE | ||
67 | |||
68 | // Let VIA handle the QMK RGBLIGHT | ||
69 | #define VIA_QMK_RGBLIGHT_ENABLE | ||
70 | |||
65 | /* | 71 | /* |
66 | * Feature disable options | 72 | * Feature disable options |
67 | * These options are also useful to firmware size reduction. | 73 | * These options are also useful to firmware size reduction. |
diff --git a/keyboards/hs60/v2/config.h b/keyboards/hs60/v2/config.h index 91fdf6080..42d10bdb5 100644 --- a/keyboards/hs60/v2/config.h +++ b/keyboards/hs60/v2/config.h | |||
@@ -138,3 +138,5 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
138 | // dynamic keymaps start after this. | 138 | // dynamic keymaps start after this. |
139 | #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31 | 139 | #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31 |
140 | 140 | ||
141 | // VIA lighting is handled by the keyboard-level code | ||
142 | #define VIA_CUSTOM_LIGHTING_ENABLE | ||
diff --git a/keyboards/nk65/config.h b/keyboards/nk65/config.h index 767959b62..46450a14c 100755 --- a/keyboards/nk65/config.h +++ b/keyboards/nk65/config.h | |||
@@ -141,3 +141,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
141 | // Backlight config starts after VIA's EEPROM usage, | 141 | // Backlight config starts after VIA's EEPROM usage, |
142 | // dynamic keymaps start after this. | 142 | // dynamic keymaps start after this. |
143 | #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31 | 143 | #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31 |
144 | |||
145 | // VIA lighting is handled by the keyboard-level code | ||
146 | #define VIA_CUSTOM_LIGHTING_ENABLE | ||
diff --git a/keyboards/projectkb/alice/config.h b/keyboards/projectkb/alice/config.h index 4a068a889..94c1fd16d 100644 --- a/keyboards/projectkb/alice/config.h +++ b/keyboards/projectkb/alice/config.h | |||
@@ -62,6 +62,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
62 | // dynamic keymaps start after this. | 62 | // dynamic keymaps start after this. |
63 | #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 1 | 63 | #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 1 |
64 | 64 | ||
65 | // VIA lighting is handled by the keyboard-level code | ||
66 | #define VIA_CUSTOM_LIGHTING_ENABLE | ||
67 | |||
68 | // Let VIA handle the QMK RGBLIGHT | ||
69 | #define VIA_QMK_RGBLIGHT_ENABLE | ||
70 | |||
65 | /* | 71 | /* |
66 | * Feature disable options | 72 | * Feature disable options |
67 | * These options are also useful to firmware size reduction. | 73 | * These options are also useful to firmware size reduction. |
diff --git a/keyboards/wilba_tech/rama_works_koyu/config.h b/keyboards/wilba_tech/rama_works_koyu/config.h index 9cbbd6620..7f945b4a4 100644 --- a/keyboards/wilba_tech/rama_works_koyu/config.h +++ b/keyboards/wilba_tech/rama_works_koyu/config.h | |||
@@ -121,4 +121,7 @@ | |||
121 | 121 | ||
122 | // Backlight config starts after VIA's EEPROM usage, | 122 | // Backlight config starts after VIA's EEPROM usage, |
123 | // dynamic keymaps start after this. | 123 | // dynamic keymaps start after this. |
124 | #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31 \ No newline at end of file | 124 | #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31 |
125 | |||
126 | // VIA lighting is handled by the keyboard-level code | ||
127 | #define VIA_CUSTOM_LIGHTING_ENABLE | ||
diff --git a/keyboards/wilba_tech/rama_works_m60_a/config.h b/keyboards/wilba_tech/rama_works_m60_a/config.h index 8381a4db0..849d1a461 100644 --- a/keyboards/wilba_tech/rama_works_m60_a/config.h +++ b/keyboards/wilba_tech/rama_works_m60_a/config.h | |||
@@ -119,3 +119,6 @@ | |||
119 | // Backlight config starts after VIA's EEPROM usage, | 119 | // Backlight config starts after VIA's EEPROM usage, |
120 | // dynamic keymaps start after this. | 120 | // dynamic keymaps start after this. |
121 | #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31 | 121 | #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31 |
122 | |||
123 | // VIA lighting is handled by the keyboard-level code | ||
124 | #define VIA_CUSTOM_LIGHTING_ENABLE | ||
diff --git a/keyboards/wilba_tech/rama_works_m6_a/config.h b/keyboards/wilba_tech/rama_works_m6_a/config.h index 1a61604bb..cbb75e289 100644 --- a/keyboards/wilba_tech/rama_works_m6_a/config.h +++ b/keyboards/wilba_tech/rama_works_m6_a/config.h | |||
@@ -109,3 +109,6 @@ | |||
109 | // Backlight config starts after VIA's EEPROM usage, | 109 | // Backlight config starts after VIA's EEPROM usage, |
110 | // dynamic keymaps start after this. | 110 | // dynamic keymaps start after this. |
111 | #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 43 | 111 | #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 43 |
112 | |||
113 | // VIA lighting is handled by the keyboard-level code | ||
114 | #define VIA_CUSTOM_LIGHTING_ENABLE | ||
diff --git a/keyboards/wilba_tech/rama_works_m6_b/config.h b/keyboards/wilba_tech/rama_works_m6_b/config.h index 3ebfd80da..1af1cf694 100644 --- a/keyboards/wilba_tech/rama_works_m6_b/config.h +++ b/keyboards/wilba_tech/rama_works_m6_b/config.h | |||
@@ -152,3 +152,6 @@ | |||
152 | // Backlight config starts after VIA's EEPROM usage, | 152 | // Backlight config starts after VIA's EEPROM usage, |
153 | // dynamic keymaps start after this. | 153 | // dynamic keymaps start after this. |
154 | #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 43 | 154 | #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 43 |
155 | |||
156 | // VIA lighting is handled by the keyboard-level code | ||
157 | #define VIA_CUSTOM_LIGHTING_ENABLE | ||
diff --git a/keyboards/wilba_tech/rama_works_u80_a/config.h b/keyboards/wilba_tech/rama_works_u80_a/config.h index 748b2cb29..2523b962e 100644 --- a/keyboards/wilba_tech/rama_works_u80_a/config.h +++ b/keyboards/wilba_tech/rama_works_u80_a/config.h | |||
@@ -235,3 +235,6 @@ | |||
235 | // Backlight config starts after VIA's EEPROM usage, | 235 | // Backlight config starts after VIA's EEPROM usage, |
236 | // dynamic keymaps start after this. | 236 | // dynamic keymaps start after this. |
237 | #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31 | 237 | #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31 |
238 | |||
239 | // VIA lighting is handled by the keyboard-level code | ||
240 | #define VIA_CUSTOM_LIGHTING_ENABLE | ||
diff --git a/keyboards/wilba_tech/wt60_a/config.h b/keyboards/wilba_tech/wt60_a/config.h index 269afbcb8..e07b91166 100644 --- a/keyboards/wilba_tech/wt60_a/config.h +++ b/keyboards/wilba_tech/wt60_a/config.h | |||
@@ -204,3 +204,5 @@ | |||
204 | // dynamic keymaps start after this. | 204 | // dynamic keymaps start after this. |
205 | #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 7 | 205 | #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 7 |
206 | 206 | ||
207 | // VIA lighting is handled by the keyboard-level code | ||
208 | #define VIA_CUSTOM_LIGHTING_ENABLE | ||
diff --git a/keyboards/wilba_tech/wt65_a/config.h b/keyboards/wilba_tech/wt65_a/config.h index ad4c120f4..bf19fe38c 100644 --- a/keyboards/wilba_tech/wt65_a/config.h +++ b/keyboards/wilba_tech/wt65_a/config.h | |||
@@ -201,3 +201,5 @@ | |||
201 | // dynamic keymaps start after this. | 201 | // dynamic keymaps start after this. |
202 | #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 7 | 202 | #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 7 |
203 | 203 | ||
204 | // VIA lighting is handled by the keyboard-level code | ||
205 | #define VIA_CUSTOM_LIGHTING_ENABLE | ||
diff --git a/keyboards/wilba_tech/wt65_b/config.h b/keyboards/wilba_tech/wt65_b/config.h index f98fa4e72..d74275a28 100644 --- a/keyboards/wilba_tech/wt65_b/config.h +++ b/keyboards/wilba_tech/wt65_b/config.h | |||
@@ -201,3 +201,5 @@ | |||
201 | // dynamic keymaps start after this. | 201 | // dynamic keymaps start after this. |
202 | #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 7 | 202 | #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 7 |
203 | 203 | ||
204 | // VIA lighting is handled by the keyboard-level code | ||
205 | #define VIA_CUSTOM_LIGHTING_ENABLE | ||
diff --git a/keyboards/wilba_tech/wt75_a/config.h b/keyboards/wilba_tech/wt75_a/config.h index 0c0a2ff08..9b058eec4 100644 --- a/keyboards/wilba_tech/wt75_a/config.h +++ b/keyboards/wilba_tech/wt75_a/config.h | |||
@@ -204,3 +204,5 @@ | |||
204 | // dynamic keymaps start after this. | 204 | // dynamic keymaps start after this. |
205 | #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 7 | 205 | #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 7 |
206 | 206 | ||
207 | // VIA lighting is handled by the keyboard-level code | ||
208 | #define VIA_CUSTOM_LIGHTING_ENABLE | ||
diff --git a/keyboards/wilba_tech/wt75_b/config.h b/keyboards/wilba_tech/wt75_b/config.h index 0c7b3dbfa..d22ac97e0 100644 --- a/keyboards/wilba_tech/wt75_b/config.h +++ b/keyboards/wilba_tech/wt75_b/config.h | |||
@@ -204,3 +204,5 @@ | |||
204 | // dynamic keymaps start after this. | 204 | // dynamic keymaps start after this. |
205 | #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 7 | 205 | #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 7 |
206 | 206 | ||
207 | // VIA lighting is handled by the keyboard-level code | ||
208 | #define VIA_CUSTOM_LIGHTING_ENABLE | ||
diff --git a/keyboards/wilba_tech/wt75_c/config.h b/keyboards/wilba_tech/wt75_c/config.h index b84f2444d..08b3c2ec4 100644 --- a/keyboards/wilba_tech/wt75_c/config.h +++ b/keyboards/wilba_tech/wt75_c/config.h | |||
@@ -204,3 +204,5 @@ | |||
204 | // dynamic keymaps start after this. | 204 | // dynamic keymaps start after this. |
205 | #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 7 | 205 | #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 7 |
206 | 206 | ||
207 | // VIA lighting is handled by the keyboard-level code | ||
208 | #define VIA_CUSTOM_LIGHTING_ENABLE | ||
diff --git a/keyboards/wilba_tech/wt80_a/config.h b/keyboards/wilba_tech/wt80_a/config.h index b706956ef..591697015 100644 --- a/keyboards/wilba_tech/wt80_a/config.h +++ b/keyboards/wilba_tech/wt80_a/config.h | |||
@@ -200,3 +200,6 @@ | |||
200 | // Backlight config starts after VIA's EEPROM usage, | 200 | // Backlight config starts after VIA's EEPROM usage, |
201 | // dynamic keymaps start after this. | 201 | // dynamic keymaps start after this. |
202 | #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 7 | 202 | #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 7 |
203 | |||
204 | // VIA lighting is handled by the keyboard-level code | ||
205 | #define VIA_CUSTOM_LIGHTING_ENABLE | ||
diff --git a/keyboards/wilba_tech/wt_main.c b/keyboards/wilba_tech/wt_main.c index 1ad12ee4a..32721b654 100644 --- a/keyboards/wilba_tech/wt_main.c +++ b/keyboards/wilba_tech/wt_main.c | |||
@@ -123,17 +123,17 @@ void raw_hid_receive_kb(uint8_t *data, uint8_t length) { | |||
123 | switch ( *command_id ) | 123 | switch ( *command_id ) |
124 | { | 124 | { |
125 | #if RGB_BACKLIGHT_ENABLED || MONO_BACKLIGHT_ENABLED | 125 | #if RGB_BACKLIGHT_ENABLED || MONO_BACKLIGHT_ENABLED |
126 | case id_backlight_config_set_value: | 126 | case id_lighting_set_value: |
127 | { | 127 | { |
128 | backlight_config_set_value(command_data); | 128 | backlight_config_set_value(command_data); |
129 | break; | 129 | break; |
130 | } | 130 | } |
131 | case id_backlight_config_get_value: | 131 | case id_lighting_get_value: |
132 | { | 132 | { |
133 | backlight_config_get_value(command_data); | 133 | backlight_config_get_value(command_data); |
134 | break; | 134 | break; |
135 | } | 135 | } |
136 | case id_backlight_config_save: | 136 | case id_lighting_save: |
137 | { | 137 | { |
138 | backlight_config_save(); | 138 | backlight_config_save(); |
139 | break; | 139 | break; |
diff --git a/keyboards/wilba_tech/wt_mono_backlight.c b/keyboards/wilba_tech/wt_mono_backlight.c index daf738da2..fbc3102e8 100644 --- a/keyboards/wilba_tech/wt_mono_backlight.c +++ b/keyboards/wilba_tech/wt_mono_backlight.c | |||
@@ -26,9 +26,13 @@ | |||
26 | #include "quantum/color.h" | 26 | #include "quantum/color.h" |
27 | #include "tmk_core/common/eeprom.h" | 27 | #include "tmk_core/common/eeprom.h" |
28 | 28 | ||
29 | #include "via.h" // uses only the EEPROM address | 29 | #include "via.h" // uses EEPROM address, lighting value IDs |
30 | #define MONO_BACKLIGHT_CONFIG_EEPROM_ADDR (VIA_EEPROM_CUSTOM_CONFIG_ADDR) | 30 | #define MONO_BACKLIGHT_CONFIG_EEPROM_ADDR (VIA_EEPROM_CUSTOM_CONFIG_ADDR) |
31 | 31 | ||
32 | #if VIA_EEPROM_CUSTOM_CONFIG_SIZE == 0 | ||
33 | #error VIA_EEPROM_CUSTOM_CONFIG_SIZE was not defined to store backlight_config struct | ||
34 | #endif | ||
35 | |||
32 | #include "drivers/issi/is31fl3736.h" | 36 | #include "drivers/issi/is31fl3736.h" |
33 | 37 | ||
34 | #define ISSI_ADDR_DEFAULT 0x50 | 38 | #define ISSI_ADDR_DEFAULT 0x50 |
diff --git a/keyboards/wilba_tech/wt_rgb_backlight.c b/keyboards/wilba_tech/wt_rgb_backlight.c index babb844d2..4af8e15e3 100644 --- a/keyboards/wilba_tech/wt_rgb_backlight.c +++ b/keyboards/wilba_tech/wt_rgb_backlight.c | |||
@@ -50,9 +50,13 @@ LED_TYPE g_ws2812_leds[WS2812_LED_TOTAL]; | |||
50 | #include "quantum/color.h" | 50 | #include "quantum/color.h" |
51 | #include "tmk_core/common/eeprom.h" | 51 | #include "tmk_core/common/eeprom.h" |
52 | 52 | ||
53 | #include "via.h" // uses only the EEPROM address | 53 | #include "via.h" // uses EEPROM address, lighting value IDs |
54 | #define RGB_BACKLIGHT_CONFIG_EEPROM_ADDR (VIA_EEPROM_CUSTOM_CONFIG_ADDR) | 54 | #define RGB_BACKLIGHT_CONFIG_EEPROM_ADDR (VIA_EEPROM_CUSTOM_CONFIG_ADDR) |
55 | 55 | ||
56 | #if VIA_EEPROM_CUSTOM_CONFIG_SIZE == 0 | ||
57 | #error VIA_EEPROM_CUSTOM_CONFIG_SIZE was not defined to store backlight_config struct | ||
58 | #endif | ||
59 | |||
56 | #if defined(RGB_BACKLIGHT_M6_B) | 60 | #if defined(RGB_BACKLIGHT_M6_B) |
57 | #include "drivers/issi/is31fl3218.h" | 61 | #include "drivers/issi/is31fl3218.h" |
58 | #define BACKLIGHT_LED_COUNT 6 | 62 | #define BACKLIGHT_LED_COUNT 6 |
diff --git a/keyboards/wilba_tech/zeal60/config.h b/keyboards/wilba_tech/zeal60/config.h index cb2f6a96b..9e2badd2a 100644 --- a/keyboards/wilba_tech/zeal60/config.h +++ b/keyboards/wilba_tech/zeal60/config.h | |||
@@ -117,4 +117,7 @@ | |||
117 | 117 | ||
118 | // Backlight config starts after VIA's EEPROM usage, | 118 | // Backlight config starts after VIA's EEPROM usage, |
119 | // dynamic keymaps start after this. | 119 | // dynamic keymaps start after this. |
120 | #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31 \ No newline at end of file | 120 | #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31 |
121 | |||
122 | // VIA lighting is handled by the keyboard-level code | ||
123 | #define VIA_CUSTOM_LIGHTING_ENABLE | ||
diff --git a/keyboards/wilba_tech/zeal65/config.h b/keyboards/wilba_tech/zeal65/config.h index 01649d76f..df32aff77 100644 --- a/keyboards/wilba_tech/zeal65/config.h +++ b/keyboards/wilba_tech/zeal65/config.h | |||
@@ -118,3 +118,6 @@ | |||
118 | // Backlight config starts after VIA's EEPROM usage, | 118 | // Backlight config starts after VIA's EEPROM usage, |
119 | // dynamic keymaps start after this. | 119 | // dynamic keymaps start after this. |
120 | #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31 | 120 | #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31 |
121 | |||
122 | // VIA lighting is handled by the keyboard-level code | ||
123 | #define VIA_CUSTOM_LIGHTING_ENABLE \ No newline at end of file | ||
diff --git a/keyboards/xelus/dawn60/config.h b/keyboards/xelus/dawn60/config.h index 7691bb301..59eb828fa 100644 --- a/keyboards/xelus/dawn60/config.h +++ b/keyboards/xelus/dawn60/config.h | |||
@@ -140,3 +140,6 @@ | |||
140 | // Backlight config starts after VIA's EEPROM usage, | 140 | // Backlight config starts after VIA's EEPROM usage, |
141 | // dynamic keymaps start after this. | 141 | // dynamic keymaps start after this. |
142 | #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31 | 142 | #define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31 |
143 | |||
144 | // VIA lighting is handled by the keyboard-level code | ||
145 | #define VIA_CUSTOM_LIGHTING_ENABLE | ||
diff --git a/quantum/backlight/backlight.c b/quantum/backlight/backlight.c index e57b31d10..4aa74667d 100644 --- a/quantum/backlight/backlight.c +++ b/quantum/backlight/backlight.c | |||
@@ -130,18 +130,30 @@ void backlight_step(void) { | |||
130 | backlight_set(backlight_config.level); | 130 | backlight_set(backlight_config.level); |
131 | } | 131 | } |
132 | 132 | ||
133 | /** \brief Backlight set level | 133 | /** \brief Backlight set level without EEPROM update |
134 | * | 134 | * |
135 | * FIXME: needs doc | ||
136 | */ | 135 | */ |
137 | void backlight_level(uint8_t level) { | 136 | void backlight_level_noeeprom(uint8_t level) { |
138 | if (level > BACKLIGHT_LEVELS) level = BACKLIGHT_LEVELS; | 137 | if (level > BACKLIGHT_LEVELS) level = BACKLIGHT_LEVELS; |
139 | backlight_config.level = level; | 138 | backlight_config.level = level; |
140 | backlight_config.enable = !!backlight_config.level; | 139 | backlight_config.enable = !!backlight_config.level; |
141 | eeconfig_update_backlight(backlight_config.raw); | ||
142 | backlight_set(backlight_config.level); | 140 | backlight_set(backlight_config.level); |
143 | } | 141 | } |
144 | 142 | ||
143 | /** \brief Backlight set level | ||
144 | * | ||
145 | * FIXME: needs doc | ||
146 | */ | ||
147 | void backlight_level(uint8_t level) { | ||
148 | backlight_level_noeeprom(level); | ||
149 | eeconfig_update_backlight(backlight_config.raw); | ||
150 | } | ||
151 | |||
152 | /** \brief Update current backlight state to EEPROM | ||
153 | * | ||
154 | */ | ||
155 | void eeconfig_update_backlight_current(void) { eeconfig_update_backlight(backlight_config.raw); } | ||
156 | |||
145 | /** \brief Get backlight level | 157 | /** \brief Get backlight level |
146 | * | 158 | * |
147 | * FIXME: needs doc | 159 | * FIXME: needs doc |
diff --git a/quantum/backlight/backlight.h b/quantum/backlight/backlight.h index 9f0a5e81d..08acf942f 100644 --- a/quantum/backlight/backlight.h +++ b/quantum/backlight/backlight.h | |||
@@ -48,8 +48,10 @@ bool is_backlight_enabled(void); | |||
48 | void backlight_step(void); | 48 | void backlight_step(void); |
49 | void backlight_increase(void); | 49 | void backlight_increase(void); |
50 | void backlight_decrease(void); | 50 | void backlight_decrease(void); |
51 | void backlight_level_noeeprom(uint8_t level); | ||
51 | void backlight_level(uint8_t level); | 52 | void backlight_level(uint8_t level); |
52 | uint8_t get_backlight_level(void); | 53 | uint8_t get_backlight_level(void); |
54 | void eeconfig_update_backlight_current(void); | ||
53 | 55 | ||
54 | // implementation specific | 56 | // implementation specific |
55 | void backlight_init_ports(void); | 57 | void backlight_init_ports(void); |
diff --git a/quantum/rgblight.c b/quantum/rgblight.c index 26887f057..85b319110 100644 --- a/quantum/rgblight.c +++ b/quantum/rgblight.c | |||
@@ -160,6 +160,10 @@ void eeconfig_update_rgblight(uint32_t val) { | |||
160 | #endif | 160 | #endif |
161 | } | 161 | } |
162 | 162 | ||
163 | void eeconfig_update_rgblight_current(void) { | ||
164 | eeconfig_update_rgblight(rgblight_config.raw); | ||
165 | } | ||
166 | |||
163 | void eeconfig_update_rgblight_default(void) { | 167 | void eeconfig_update_rgblight_default(void) { |
164 | rgblight_config.enable = 1; | 168 | rgblight_config.enable = 1; |
165 | rgblight_config.mode = RGBLIGHT_MODE_STATIC_LIGHT; | 169 | rgblight_config.mode = RGBLIGHT_MODE_STATIC_LIGHT; |
@@ -501,6 +505,22 @@ void rgblight_sethsv(uint8_t hue, uint8_t sat, uint8_t val) { rgblight_sethsv_ee | |||
501 | 505 | ||
502 | void rgblight_sethsv_noeeprom(uint8_t hue, uint8_t sat, uint8_t val) { rgblight_sethsv_eeprom_helper(hue, sat, val, false); } | 506 | void rgblight_sethsv_noeeprom(uint8_t hue, uint8_t sat, uint8_t val) { rgblight_sethsv_eeprom_helper(hue, sat, val, false); } |
503 | 507 | ||
508 | uint8_t rgblight_get_speed(void) { return rgblight_config.speed; } | ||
509 | |||
510 | void rgblight_set_speed_eeprom_helper(uint8_t speed, bool write_to_eeprom) { | ||
511 | rgblight_config.speed = speed; | ||
512 | if (write_to_eeprom) { | ||
513 | eeconfig_update_rgblight(rgblight_config.raw); // EECONFIG needs to be increased to support this | ||
514 | dprintf("rgblight set speed [EEPROM]: %u\n", rgblight_config.speed); | ||
515 | } else { | ||
516 | dprintf("rgblight set speed [NOEEPROM]: %u\n", rgblight_config.speed); | ||
517 | } | ||
518 | } | ||
519 | |||
520 | void rgblight_set_speed(uint8_t speed) { rgblight_set_speed_eeprom_helper(speed, true); } | ||
521 | |||
522 | void rgblight_set_speed_noeeprom(uint8_t speed) { rgblight_set_speed_eeprom_helper(speed, false); } | ||
523 | |||
504 | uint8_t rgblight_get_hue(void) { return rgblight_config.hue; } | 524 | uint8_t rgblight_get_hue(void) { return rgblight_config.hue; } |
505 | 525 | ||
506 | uint8_t rgblight_get_sat(void) { return rgblight_config.sat; } | 526 | uint8_t rgblight_get_sat(void) { return rgblight_config.sat; } |
diff --git a/quantum/rgblight.h b/quantum/rgblight.h index e3aa098e4..f6746e50f 100644 --- a/quantum/rgblight.h +++ b/quantum/rgblight.h | |||
@@ -233,6 +233,11 @@ void rgblight_decrease_speed(void); | |||
233 | void rgblight_sethsv(uint8_t hue, uint8_t sat, uint8_t val); | 233 | void rgblight_sethsv(uint8_t hue, uint8_t sat, uint8_t val); |
234 | void rgblight_sethsv_noeeprom(uint8_t hue, uint8_t sat, uint8_t val); | 234 | void rgblight_sethsv_noeeprom(uint8_t hue, uint8_t sat, uint8_t val); |
235 | 235 | ||
236 | /* effect speed */ | ||
237 | uint8_t rgblight_get_speed(void); | ||
238 | void rgblight_set_speed(uint8_t speed); | ||
239 | void rgblight_set_speed_noeeprom(uint8_t speed); | ||
240 | |||
236 | /* query */ | 241 | /* query */ |
237 | uint8_t rgblight_get_mode(void); | 242 | uint8_t rgblight_get_mode(void); |
238 | uint8_t rgblight_get_hue(void); | 243 | uint8_t rgblight_get_hue(void); |
@@ -245,6 +250,7 @@ uint32_t rgblight_read_dword(void); | |||
245 | void rgblight_update_dword(uint32_t dword); | 250 | void rgblight_update_dword(uint32_t dword); |
246 | uint32_t eeconfig_read_rgblight(void); | 251 | uint32_t eeconfig_read_rgblight(void); |
247 | void eeconfig_update_rgblight(uint32_t val); | 252 | void eeconfig_update_rgblight(uint32_t val); |
253 | void eeconfig_update_rgblight_current(void); | ||
248 | void eeconfig_update_rgblight_default(void); | 254 | void eeconfig_update_rgblight_default(void); |
249 | void eeconfig_debug_rgblight(void); | 255 | void eeconfig_debug_rgblight(void); |
250 | 256 | ||
diff --git a/quantum/via.c b/quantum/via.c index b3934d9f0..f85af8d9e 100644 --- a/quantum/via.c +++ b/quantum/via.c | |||
@@ -22,14 +22,42 @@ | |||
22 | # error "DYNAMIC_KEYMAP_ENABLE is not enabled" | 22 | # error "DYNAMIC_KEYMAP_ENABLE is not enabled" |
23 | #endif | 23 | #endif |
24 | 24 | ||
25 | // If VIA_CUSTOM_LIGHTING_ENABLE is not defined, then VIA_QMK_BACKLIGHT_ENABLE is set | ||
26 | // if BACKLIGHT_ENABLE is set, so handling of QMK Backlight values happens here by default. | ||
27 | // if VIA_CUSTOM_LIGHTING_ENABLE is defined, then VIA_QMK_BACKLIGHT_ENABLE must be explicitly | ||
28 | // set in keyboard-level config.h, so handling of QMK Backlight values happens here | ||
29 | #if defined(BACKLIGHT_ENABLE) && !defined(VIA_CUSTOM_LIGHTING_ENABLE) | ||
30 | # define VIA_QMK_BACKLIGHT_ENABLE | ||
31 | #endif | ||
32 | |||
33 | // If VIA_CUSTOM_LIGHTING_ENABLE is not defined, then VIA_QMK_RGBLIGHT_ENABLE is set | ||
34 | // if RGBLIGHT_ENABLE is set, so handling of QMK RGBLIGHT values happens here by default. | ||
35 | // If VIA_CUSTOM_LIGHTING_ENABLE is defined, then VIA_QMK_RGBLIGHT_ENABLE must be explicitly | ||
36 | // set in keyboard-level config.h, so handling of QMK RGBLIGHT values happens here | ||
37 | #if defined(RGBLIGHT_ENABLE) && !defined(VIA_CUSTOM_LIGHTING_ENABLE) | ||
38 | # define VIA_QMK_RGBLIGHT_ENABLE | ||
39 | #endif | ||
40 | |||
25 | #include "quantum.h" | 41 | #include "quantum.h" |
26 | 42 | ||
27 | #include "via.h" | 43 | #include "via.h" |
44 | |||
28 | #include "raw_hid.h" | 45 | #include "raw_hid.h" |
29 | #include "dynamic_keymap.h" | 46 | #include "dynamic_keymap.h" |
30 | #include "tmk_core/common/eeprom.h" | 47 | #include "tmk_core/common/eeprom.h" |
31 | #include "version.h" // for QMK_BUILDDATE used in EEPROM magic | 48 | #include "version.h" // for QMK_BUILDDATE used in EEPROM magic |
32 | 49 | ||
50 | // Forward declare some helpers. | ||
51 | #if defined(VIA_QMK_BACKLIGHT_ENABLE) | ||
52 | void via_qmk_backlight_set_value(uint8_t *data); | ||
53 | void via_qmk_backlight_get_value(uint8_t *data); | ||
54 | #endif | ||
55 | |||
56 | #if defined(VIA_QMK_RGBLIGHT_ENABLE) | ||
57 | void via_qmk_rgblight_set_value(uint8_t *data); | ||
58 | void via_qmk_rgblight_get_value(uint8_t *data); | ||
59 | #endif | ||
60 | |||
33 | // Can be called in an overriding via_init_kb() to test if keyboard level code usage of | 61 | // Can be called in an overriding via_init_kb() to test if keyboard level code usage of |
34 | // EEPROM is invalid and use/save defaults. | 62 | // EEPROM is invalid and use/save defaults. |
35 | bool via_eeprom_is_valid(void) { | 63 | bool via_eeprom_is_valid(void) { |
@@ -282,10 +310,52 @@ void raw_hid_receive(uint8_t *data, uint8_t length) { | |||
282 | dynamic_keymap_reset(); | 310 | dynamic_keymap_reset(); |
283 | break; | 311 | break; |
284 | } | 312 | } |
285 | case id_backlight_config_set_value: | 313 | case id_lighting_set_value: { |
286 | case id_backlight_config_get_value: | 314 | #if defined(VIA_QMK_BACKLIGHT_ENABLE) |
287 | case id_backlight_config_save: { | 315 | via_qmk_backlight_set_value(command_data); |
316 | #endif | ||
317 | #if defined(VIA_QMK_RGBLIGHT_ENABLE) | ||
318 | via_qmk_rgblight_set_value(command_data); | ||
319 | #endif | ||
320 | #if defined(VIA_CUSTOM_LIGHTING_ENABLE) | ||
288 | raw_hid_receive_kb(data, length); | 321 | raw_hid_receive_kb(data, length); |
322 | #endif | ||
323 | #if !defined(VIA_QMK_BACKLIGHT_ENABLE) && !defined(VIA_QMK_RGBLIGHT_ENABLE) && !defined(VIA_CUSTOM_LIGHTING_ENABLE) | ||
324 | // Return the unhandled state | ||
325 | *command_id = id_unhandled; | ||
326 | #endif | ||
327 | break; | ||
328 | } | ||
329 | case id_lighting_get_value: { | ||
330 | #if defined(VIA_QMK_BACKLIGHT_ENABLE) | ||
331 | via_qmk_backlight_get_value(command_data); | ||
332 | #endif | ||
333 | #if defined(VIA_QMK_RGBLIGHT_ENABLE) | ||
334 | via_qmk_rgblight_get_value(command_data); | ||
335 | #endif | ||
336 | #if defined(VIA_CUSTOM_LIGHTING_ENABLE) | ||
337 | raw_hid_receive_kb(data, length); | ||
338 | #endif | ||
339 | #if !defined(VIA_QMK_BACKLIGHT_ENABLE) && !defined(VIA_QMK_RGBLIGHT_ENABLE) && !defined(VIA_CUSTOM_LIGHTING_ENABLE) | ||
340 | // Return the unhandled state | ||
341 | *command_id = id_unhandled; | ||
342 | #endif | ||
343 | break; | ||
344 | } | ||
345 | case id_lighting_save: { | ||
346 | #if defined(VIA_QMK_BACKLIGHT_ENABLE) | ||
347 | eeconfig_update_backlight_current(); | ||
348 | #endif | ||
349 | #if defined(VIA_QMK_RGBLIGHT_ENABLE) | ||
350 | eeconfig_update_rgblight_current(); | ||
351 | #endif | ||
352 | #if defined(VIA_CUSTOM_LIGHTING_ENABLE) | ||
353 | raw_hid_receive_kb(data, length); | ||
354 | #endif | ||
355 | #if !defined(VIA_QMK_BACKLIGHT_ENABLE) && !defined(VIA_QMK_RGBLIGHT_ENABLE) && !defined(VIA_CUSTOM_LIGHTING_ENABLE) | ||
356 | // Return the unhandled state | ||
357 | *command_id = id_unhandled; | ||
358 | #endif | ||
289 | break; | 359 | break; |
290 | } | 360 | } |
291 | case id_dynamic_keymap_macro_get_count: { | 361 | case id_dynamic_keymap_macro_get_count: { |
@@ -355,3 +425,109 @@ void raw_hid_receive(uint8_t *data, uint8_t length) { | |||
355 | // (i.e. returning state to the host, or the unhandled state). | 425 | // (i.e. returning state to the host, or the unhandled state). |
356 | raw_hid_send(data, length); | 426 | raw_hid_send(data, length); |
357 | } | 427 | } |
428 | |||
429 | #if defined(VIA_QMK_BACKLIGHT_ENABLE) | ||
430 | |||
431 | # if BACKLIGHT_LEVELS == 0 | ||
432 | # error BACKLIGHT_LEVELS == 0 | ||
433 | # endif | ||
434 | |||
435 | void via_qmk_backlight_get_value(uint8_t *data) { | ||
436 | uint8_t *value_id = &(data[0]); | ||
437 | uint8_t *value_data = &(data[1]); | ||
438 | switch (*value_id) { | ||
439 | case id_qmk_backlight_brightness: { | ||
440 | // level / BACKLIGHT_LEVELS * 255 | ||
441 | value_data[0] = ((uint16_t)get_backlight_level()) * 255 / BACKLIGHT_LEVELS; | ||
442 | break; | ||
443 | } | ||
444 | case id_qmk_backlight_effect: { | ||
445 | # ifdef BACKLIGHT_BREATHING | ||
446 | value_data[0] = is_backlight_breathing() ? 1 : 0; | ||
447 | # else | ||
448 | value_data[0] = 0; | ||
449 | # endif | ||
450 | break; | ||
451 | } | ||
452 | } | ||
453 | } | ||
454 | |||
455 | void via_qmk_backlight_set_value(uint8_t *data) { | ||
456 | uint8_t *value_id = &(data[0]); | ||
457 | uint8_t *value_data = &(data[1]); | ||
458 | switch (*value_id) { | ||
459 | case id_qmk_backlight_brightness: { | ||
460 | // level / 255 * BACKLIGHT_LEVELS | ||
461 | backlight_level_noeeprom(((uint16_t)value_data[0]) * BACKLIGHT_LEVELS / 255); | ||
462 | break; | ||
463 | } | ||
464 | case id_qmk_backlight_effect: { | ||
465 | # ifdef BACKLIGHT_BREATHING | ||
466 | if (value_data[0] == 0) { | ||
467 | backlight_disable_breathing(); | ||
468 | } else { | ||
469 | backlight_enable_breathing(); | ||
470 | } | ||
471 | # endif | ||
472 | break; | ||
473 | } | ||
474 | } | ||
475 | } | ||
476 | |||
477 | #endif // #if defined(VIA_QMK_BACKLIGHT_ENABLE) | ||
478 | |||
479 | #if defined(VIA_QMK_RGBLIGHT_ENABLE) | ||
480 | |||
481 | void via_qmk_rgblight_get_value(uint8_t *data) { | ||
482 | uint8_t *value_id = &(data[0]); | ||
483 | uint8_t *value_data = &(data[1]); | ||
484 | switch (*value_id) { | ||
485 | case id_qmk_rgblight_brightness: { | ||
486 | value_data[0] = rgblight_get_val(); | ||
487 | break; | ||
488 | } | ||
489 | case id_qmk_rgblight_effect: { | ||
490 | value_data[0] = rgblight_get_mode(); | ||
491 | break; | ||
492 | } | ||
493 | case id_qmk_rgblight_effect_speed: { | ||
494 | value_data[0] = rgblight_get_speed(); | ||
495 | break; | ||
496 | } | ||
497 | case id_qmk_rgblight_color: { | ||
498 | value_data[0] = rgblight_get_hue(); | ||
499 | value_data[1] = rgblight_get_sat(); | ||
500 | break; | ||
501 | } | ||
502 | } | ||
503 | } | ||
504 | |||
505 | void via_qmk_rgblight_set_value(uint8_t *data) { | ||
506 | uint8_t *value_id = &(data[0]); | ||
507 | uint8_t *value_data = &(data[1]); | ||
508 | switch (*value_id) { | ||
509 | case id_qmk_rgblight_brightness: { | ||
510 | rgblight_sethsv_noeeprom(rgblight_get_hue(), rgblight_get_sat(), value_data[0]); | ||
511 | break; | ||
512 | } | ||
513 | case id_qmk_rgblight_effect: { | ||
514 | rgblight_mode_noeeprom(value_data[0]); | ||
515 | if (value_data[0] == 0) { | ||
516 | rgblight_disable_noeeprom(); | ||
517 | } else { | ||
518 | rgblight_enable_noeeprom(); | ||
519 | } | ||
520 | break; | ||
521 | } | ||
522 | case id_qmk_rgblight_effect_speed: { | ||
523 | rgblight_set_speed_noeeprom(value_data[0]); | ||
524 | break; | ||
525 | } | ||
526 | case id_qmk_rgblight_color: { | ||
527 | rgblight_sethsv_noeeprom(value_data[0], value_data[1], rgblight_get_val()); | ||
528 | break; | ||
529 | } | ||
530 | } | ||
531 | } | ||
532 | |||
533 | #endif // #if defined(VIA_QMK_RGBLIGHT_ENABLE) | ||
diff --git a/quantum/via.h b/quantum/via.h index 98f8dea8c..012547e05 100644 --- a/quantum/via.h +++ b/quantum/via.h | |||
@@ -51,29 +51,45 @@ | |||
51 | #define VIA_PROTOCOL_VERSION 0x0009 | 51 | #define VIA_PROTOCOL_VERSION 0x0009 |
52 | 52 | ||
53 | enum via_command_id { | 53 | enum via_command_id { |
54 | id_get_protocol_version = 0x01, // always 0x01 | 54 | id_get_protocol_version = 0x01, // always 0x01 |
55 | id_get_keyboard_value, | 55 | id_get_keyboard_value = 0x02, |
56 | id_set_keyboard_value, | 56 | id_set_keyboard_value = 0x03, |
57 | id_dynamic_keymap_get_keycode, | 57 | id_dynamic_keymap_get_keycode = 0x04, |
58 | id_dynamic_keymap_set_keycode, | 58 | id_dynamic_keymap_set_keycode = 0x05, |
59 | id_dynamic_keymap_reset, | 59 | id_dynamic_keymap_reset = 0x06, |
60 | id_backlight_config_set_value, | 60 | id_lighting_set_value = 0x07, |
61 | id_backlight_config_get_value, | 61 | id_lighting_get_value = 0x08, |
62 | id_backlight_config_save, | 62 | id_lighting_save = 0x09, |
63 | id_eeprom_reset, | 63 | id_eeprom_reset = 0x0A, |
64 | id_bootloader_jump, | 64 | id_bootloader_jump = 0x0B, |
65 | id_dynamic_keymap_macro_get_count, | 65 | id_dynamic_keymap_macro_get_count = 0x0C, |
66 | id_dynamic_keymap_macro_get_buffer_size, | 66 | id_dynamic_keymap_macro_get_buffer_size = 0x0D, |
67 | id_dynamic_keymap_macro_get_buffer, | 67 | id_dynamic_keymap_macro_get_buffer = 0x0E, |
68 | id_dynamic_keymap_macro_set_buffer, | 68 | id_dynamic_keymap_macro_set_buffer = 0x0F, |
69 | id_dynamic_keymap_macro_reset, | 69 | id_dynamic_keymap_macro_reset = 0x10, |
70 | id_dynamic_keymap_get_layer_count, | 70 | id_dynamic_keymap_get_layer_count = 0x11, |
71 | id_dynamic_keymap_get_buffer, | 71 | id_dynamic_keymap_get_buffer = 0x12, |
72 | id_dynamic_keymap_set_buffer, | 72 | id_dynamic_keymap_set_buffer = 0x13, |
73 | id_unhandled = 0xFF, | 73 | id_unhandled = 0xFF, |
74 | }; | 74 | }; |
75 | 75 | ||
76 | enum via_keyboard_value_id { id_uptime = 0x01, id_layout_options, id_switch_matrix_state }; | 76 | enum via_keyboard_value_id { |
77 | id_uptime = 0x01, // | ||
78 | id_layout_options = 0x02, | ||
79 | id_switch_matrix_state = 0x03 | ||
80 | }; | ||
81 | |||
82 | enum via_lighting_value { | ||
83 | // QMK BACKLIGHT | ||
84 | id_qmk_backlight_brightness = 0x09, | ||
85 | id_qmk_backlight_effect = 0x0A, | ||
86 | |||
87 | // QMK RGBLIGHT | ||
88 | id_qmk_rgblight_brightness = 0x80, | ||
89 | id_qmk_rgblight_effect = 0x81, | ||
90 | id_qmk_rgblight_effect_speed = 0x82, | ||
91 | id_qmk_rgblight_color = 0x83, | ||
92 | }; | ||
77 | 93 | ||
78 | // Can't use SAFE_RANGE here, it might change if someone adds | 94 | // Can't use SAFE_RANGE here, it might change if someone adds |
79 | // new values to enum quantum_keycodes. | 95 | // new values to enum quantum_keycodes. |