diff options
author | Wilba <Jason.S.Williams@gmail.com> | 2019-07-21 21:46:22 +1000 |
---|---|---|
committer | Danny <nooges@users.noreply.github.com> | 2019-07-21 07:46:22 -0400 |
commit | bffbb4b42d3167125f54b5aeb7a30fef44ff5dbe (patch) | |
tree | 679ba294b68488b74e54300a435654057f09af81 /keyboards/wilba_tech/wt_main.c | |
parent | d686c0ea43d6a9db7768da64ee54c3ba25c018f7 (diff) | |
download | qmk_firmware-bffbb4b42d3167125f54b5aeb7a30fef44ff5dbe.tar.gz |
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.c | 125 |
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 @@ */ #include "quantum.h" + +// Check that no backlight functions are called +#if RGB_BACKLIGHT_ENABLED +#include "keyboards/wilba_tech/wt_rgb_backlight.h" +#endif // RGB_BACKLIGHT_ENABLED #ifdef WT_MONO_BACKLIGHT #include "keyboards/wilba_tech/wt_mono_backlight.h" -#endif -#include "keyboards/zeal60/zeal60_api.h" // Temporary hack -#include "keyboards/zeal60/zeal60_keycodes.h" // Temporary hack +#endif // WT_MONO_BACKLIGHT +#include "keyboards/wilba_tech/via_api.h" // Temporary hack +#include "keyboards/wilba_tech/via_keycodes.h" // Temporary hack #include "raw_hid.h" #include "dynamic_keymap.h" @@ -145,6 +150,23 @@ void raw_hid_receive( uint8_t *data, uint8_t length ) break; } #endif // DYNAMIC_KEYMAP_ENABLE +#if RGB_BACKLIGHT_ENABLED + case id_backlight_config_set_value: + { + backlight_config_set_value(command_data); + break; + } + case id_backlight_config_get_value: + { + backlight_config_get_value(command_data); + break; + } + case id_backlight_config_save: + { + backlight_config_save(); + break; + } +#endif // RGB_BACKLIGHT_ENABLED case id_eeprom_reset: { eeprom_reset(); @@ -180,29 +202,40 @@ void main_init(void) // If the EEPROM has the magic, the data is good. // OK to load from EEPROM. if (eeprom_is_valid()) { - //backlight_config_load(); +#if RGB_BACKLIGHT_ENABLED + backlight_config_load(); +#endif // RGB_BACKLIGHT_ENABLED } else { +#if RGB_BACKLIGHT_ENABLED // If the EEPROM has not been saved before, or is out of date, // save the default values to the EEPROM. Default values // come from construction of the zeal_backlight_config instance. - //backlight_config_save(); + backlight_config_save(); +#endif // RGB_BACKLIGHT_ENABLED #ifdef DYNAMIC_KEYMAP_ENABLE // This resets the keymaps in EEPROM to what is in flash. dynamic_keymap_reset(); // This resets the macros in EEPROM to nothing. dynamic_keymap_macro_reset(); -#endif +#endif // DYNAMIC_KEYMAP_ENABLE // Save the magic number last, in case saving was interrupted eeprom_set_valid(true); } + +#if RGB_BACKLIGHT_ENABLED + // Initialize LED drivers for backlight. + backlight_init_drivers(); + backlight_timer_init(); + backlight_timer_enable(); +#endif // RGB_BACKLIGHT_ENABLED #ifdef WT_MONO_BACKLIGHT // Initialize LED drivers for backlight. backlight_init_drivers(); backlight_timer_init(); backlight_timer_enable(); -#endif +#endif // WT_MONO_BACKLIGHT } void bootmagic_lite(void) @@ -234,6 +267,10 @@ void matrix_init_kb(void) void matrix_scan_kb(void) { +#if RGB_BACKLIGHT_ENABLED + // This only updates the LED driver buffers if something has changed. + backlight_update_pwm_buffers(); +#endif // RGB_BACKLIGHT_ENABLED #ifdef WT_MONO_BACKLIGHT // This only updates the LED driver buffers if something has changed. backlight_update_pwm_buffers(); @@ -243,6 +280,10 @@ void matrix_scan_kb(void) bool process_record_kb(uint16_t keycode, keyrecord_t *record) { +#if RGB_BACKLIGHT_ENABLED + process_record_backlight(keycode, record); +#endif // RGB_BACKLIGHT_ENABLED + switch(keycode) { case FN_MO13: if (record->event.pressed) { @@ -280,3 +321,73 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) return process_record_user(keycode, record); } + +// This overrides the one in quantum/keymap_common.c +uint16_t keymap_function_id_to_action( uint16_t function_id ) +{ + // Zeal60 specific "action functions" are 0xF00 to 0xFFF + // i.e. F(0xF00) to F(0xFFF) are mapped to + // enum zeal60_action_functions by masking last 8 bits. + if ( function_id >= 0x0F00 && function_id <= 0x0FFF ) + { + uint8_t id = function_id & 0xFF; + switch ( id ) { + case TRIPLE_TAP_1_3: + case TRIPLE_TAP_2_3: + { + return ACTION_FUNCTION_TAP(id); + break; + } + default: + break; + } + } + + return pgm_read_word(&fn_actions[function_id]); +} + + +// Zeal60 specific "action functions" +void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) +{ + switch (id) + { + case TRIPLE_TAP_1_3: + case TRIPLE_TAP_2_3: + if (record->event.pressed) { + layer_on( id == TRIPLE_TAP_1_3 ? 1 : 2 ); + if (record->tap.count && !record->tap.interrupted) { + if (record->tap.count >= 3) { + layer_invert(3); + } + } else { + record->tap.count = 0; + } + } else { + layer_off( id == TRIPLE_TAP_1_3 ? 1 : 2 ); + } + break; + } +} + +void led_set_kb(uint8_t usb_led) +{ +#if RGB_BACKLIGHT_ENABLED + backlight_set_indicator_state(usb_led); +#endif // RGB_BACKLIGHT_ENABLED +} + +void suspend_power_down_kb(void) +{ +#if RGB_BACKLIGHT_ENABLED + backlight_set_suspend_state(true); +#endif // RGB_BACKLIGHT_ENABLED +} + +void suspend_wakeup_init_kb(void) +{ +#if RGB_BACKLIGHT_ENABLED + backlight_set_suspend_state(false); +#endif // RGB_BACKLIGHT_ENABLED +} + |