aboutsummaryrefslogtreecommitdiff
path: root/keyboards/wilba_tech/wt_main.c
diff options
context:
space:
mode:
authorWilba <Jason.S.Williams@gmail.com>2019-07-21 21:46:22 +1000
committerDanny <nooges@users.noreply.github.com>2019-07-21 07:46:22 -0400
commitbffbb4b42d3167125f54b5aeb7a30fef44ff5dbe (patch)
tree679ba294b68488b74e54300a435654057f09af81 /keyboards/wilba_tech/wt_main.c
parentd686c0ea43d6a9db7768da64ee54c3ba25c018f7 (diff)
downloadqmk_firmware-bffbb4b42d3167125f54b5aeb7a30fef44ff5dbe.tar.gz
qmk_firmware-bffbb4b42d3167125f54b5aeb7a30fef44ff5dbe.zip
Refactoring wilba.tech PCBs, updating Rama Works U80-A (#6272)
* Added WT65-B, WT75-B, minor fixes * Update keyboards/wilba_tech/wt65_b/config.h Co-Authored-By: Drashna Jaelre <drashna@live.com> * Update keyboards/wilba_tech/wt65_b/readme.md Co-Authored-By: fauxpark <fauxpark@gmail.com> * Update keyboards/wilba_tech/wt75_b/config.h Co-Authored-By: Drashna Jaelre <drashna@live.com> * Change DEBOUNCING_DELAY to DEBOUNCE * Change DEBOUNCING_DELAY to DEBOUNCE * Move Zeal60/Zeal65 files to keyboards/wilba_tech * Change DEBOUNCING_DELAY to DEBOUNCE * Refactoring zeal60 code to wilba_tech * Moved Rama Works PCBs to wilba_tech * Rename Rama Works files * Cleanup info.json * Cleanup readme.md * Cleanup USB device strings * U80-A RGB matrix, IS31FL3731 driver changes * Fixed #include from keyboards/zeal60
Diffstat (limited to 'keyboards/wilba_tech/wt_main.c')
-rw-r--r--keyboards/wilba_tech/wt_main.c125
1 files changed, 118 insertions, 7 deletions
diff --git a/keyboards/wilba_tech/wt_main.c b/keyboards/wilba_tech/wt_main.c
index f8056839a..e6ea4a21b 100644
--- a/keyboards/wilba_tech/wt_main.c
+++ b/keyboards/wilba_tech/wt_main.c
@@ -15,11 +15,16 @@
15 */ 15 */
16 16
17#include "quantum.h" 17#include "quantum.h"
18
19// Check that no backlight functions are called
20#if RGB_BACKLIGHT_ENABLED
21#include "keyboards/wilba_tech/wt_rgb_backlight.h"
22#endif // RGB_BACKLIGHT_ENABLED
18#ifdef WT_MONO_BACKLIGHT 23#ifdef WT_MONO_BACKLIGHT
19#include "keyboards/wilba_tech/wt_mono_backlight.h" 24#include "keyboards/wilba_tech/wt_mono_backlight.h"
20#endif 25#endif // WT_MONO_BACKLIGHT
21#include "keyboards/zeal60/zeal60_api.h" // Temporary hack 26#include "keyboards/wilba_tech/via_api.h" // Temporary hack
22#include "keyboards/zeal60/zeal60_keycodes.h" // Temporary hack 27#include "keyboards/wilba_tech/via_keycodes.h" // Temporary hack
23 28
24#include "raw_hid.h" 29#include "raw_hid.h"
25#include "dynamic_keymap.h" 30#include "dynamic_keymap.h"
@@ -145,6 +150,23 @@ void raw_hid_receive( uint8_t *data, uint8_t length )
145 break; 150 break;
146 } 151 }
147#endif // DYNAMIC_KEYMAP_ENABLE 152#endif // DYNAMIC_KEYMAP_ENABLE
153#if RGB_BACKLIGHT_ENABLED
154 case id_backlight_config_set_value:
155 {
156 backlight_config_set_value(command_data);
157 break;
158 }
159 case id_backlight_config_get_value:
160 {
161 backlight_config_get_value(command_data);
162 break;
163 }
164 case id_backlight_config_save:
165 {
166 backlight_config_save();
167 break;
168 }
169#endif // RGB_BACKLIGHT_ENABLED
148 case id_eeprom_reset: 170 case id_eeprom_reset:
149 { 171 {
150 eeprom_reset(); 172 eeprom_reset();
@@ -180,29 +202,40 @@ void main_init(void)
180 // If the EEPROM has the magic, the data is good. 202 // If the EEPROM has the magic, the data is good.
181 // OK to load from EEPROM. 203 // OK to load from EEPROM.
182 if (eeprom_is_valid()) { 204 if (eeprom_is_valid()) {
183 //backlight_config_load(); 205#if RGB_BACKLIGHT_ENABLED
206 backlight_config_load();
207#endif // RGB_BACKLIGHT_ENABLED
184 } else { 208 } else {
209#if RGB_BACKLIGHT_ENABLED
185 // If the EEPROM has not been saved before, or is out of date, 210 // If the EEPROM has not been saved before, or is out of date,
186 // save the default values to the EEPROM. Default values 211 // save the default values to the EEPROM. Default values
187 // come from construction of the zeal_backlight_config instance. 212 // come from construction of the zeal_backlight_config instance.
188 //backlight_config_save(); 213 backlight_config_save();
214#endif // RGB_BACKLIGHT_ENABLED
189#ifdef DYNAMIC_KEYMAP_ENABLE 215#ifdef DYNAMIC_KEYMAP_ENABLE
190 // This resets the keymaps in EEPROM to what is in flash. 216 // This resets the keymaps in EEPROM to what is in flash.
191 dynamic_keymap_reset(); 217 dynamic_keymap_reset();
192 // This resets the macros in EEPROM to nothing. 218 // This resets the macros in EEPROM to nothing.
193 dynamic_keymap_macro_reset(); 219 dynamic_keymap_macro_reset();
194#endif 220#endif // DYNAMIC_KEYMAP_ENABLE
195 // Save the magic number last, in case saving was interrupted 221 // Save the magic number last, in case saving was interrupted
196 eeprom_set_valid(true); 222 eeprom_set_valid(true);
197 } 223 }
224
225#if RGB_BACKLIGHT_ENABLED
226 // Initialize LED drivers for backlight.
227 backlight_init_drivers();
198 228
229 backlight_timer_init();
230 backlight_timer_enable();
231#endif // RGB_BACKLIGHT_ENABLED
199#ifdef WT_MONO_BACKLIGHT 232#ifdef WT_MONO_BACKLIGHT
200 // Initialize LED drivers for backlight. 233 // Initialize LED drivers for backlight.
201 backlight_init_drivers(); 234 backlight_init_drivers();
202 235
203 backlight_timer_init(); 236 backlight_timer_init();
204 backlight_timer_enable(); 237 backlight_timer_enable();
205#endif 238#endif // WT_MONO_BACKLIGHT
206} 239}
207 240
208void bootmagic_lite(void) 241void bootmagic_lite(void)
@@ -234,6 +267,10 @@ void matrix_init_kb(void)
234 267
235void matrix_scan_kb(void) 268void matrix_scan_kb(void)
236{ 269{
270#if RGB_BACKLIGHT_ENABLED
271 // This only updates the LED driver buffers if something has changed.
272 backlight_update_pwm_buffers();
273#endif // RGB_BACKLIGHT_ENABLED
237#ifdef WT_MONO_BACKLIGHT 274#ifdef WT_MONO_BACKLIGHT
238 // This only updates the LED driver buffers if something has changed. 275 // This only updates the LED driver buffers if something has changed.
239 backlight_update_pwm_buffers(); 276 backlight_update_pwm_buffers();
@@ -243,6 +280,10 @@ void matrix_scan_kb(void)
243 280
244bool process_record_kb(uint16_t keycode, keyrecord_t *record) 281bool process_record_kb(uint16_t keycode, keyrecord_t *record)
245{ 282{
283#if RGB_BACKLIGHT_ENABLED
284 process_record_backlight(keycode, record);
285#endif // RGB_BACKLIGHT_ENABLED
286
246 switch(keycode) { 287 switch(keycode) {
247 case FN_MO13: 288 case FN_MO13:
248 if (record->event.pressed) { 289 if (record->event.pressed) {
@@ -280,3 +321,73 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record)
280 321
281 return process_record_user(keycode, record); 322 return process_record_user(keycode, record);
282} 323}
324
325// This overrides the one in quantum/keymap_common.c
326uint16_t keymap_function_id_to_action( uint16_t function_id )
327{
328 // Zeal60 specific "action functions" are 0xF00 to 0xFFF
329 // i.e. F(0xF00) to F(0xFFF) are mapped to
330 // enum zeal60_action_functions by masking last 8 bits.
331 if ( function_id >= 0x0F00 && function_id <= 0x0FFF )
332 {
333 uint8_t id = function_id & 0xFF;
334 switch ( id ) {
335 case TRIPLE_TAP_1_3:
336 case TRIPLE_TAP_2_3:
337 {
338 return ACTION_FUNCTION_TAP(id);
339 break;
340 }
341 default:
342 break;
343 }
344 }
345
346 return pgm_read_word(&fn_actions[function_id]);
347}
348
349
350// Zeal60 specific "action functions"
351void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
352{
353 switch (id)
354 {
355 case TRIPLE_TAP_1_3:
356 case TRIPLE_TAP_2_3:
357 if (record->event.pressed) {
358 layer_on( id == TRIPLE_TAP_1_3 ? 1 : 2 );
359 if (record->tap.count && !record->tap.interrupted) {
360 if (record->tap.count >= 3) {
361 layer_invert(3);
362 }
363 } else {
364 record->tap.count = 0;
365 }
366 } else {
367 layer_off( id == TRIPLE_TAP_1_3 ? 1 : 2 );
368 }
369 break;
370 }
371}
372
373void led_set_kb(uint8_t usb_led)
374{
375#if RGB_BACKLIGHT_ENABLED
376 backlight_set_indicator_state(usb_led);
377#endif // RGB_BACKLIGHT_ENABLED
378}
379
380void suspend_power_down_kb(void)
381{
382#if RGB_BACKLIGHT_ENABLED
383 backlight_set_suspend_state(true);
384#endif // RGB_BACKLIGHT_ENABLED
385}
386
387void suspend_wakeup_init_kb(void)
388{
389#if RGB_BACKLIGHT_ENABLED
390 backlight_set_suspend_state(false);
391#endif // RGB_BACKLIGHT_ENABLED
392}
393