diff options
| author | Wilba <Jason.S.Williams@gmail.com> | 2019-10-12 15:37:03 +1100 |
|---|---|---|
| committer | Drashna Jaelre <drashna@live.com> | 2019-10-11 21:37:03 -0700 |
| commit | e47ab6a5752e16bd3b4288153798c12af1bee3d5 (patch) | |
| tree | 47fd56bfb7be699cc6b1ca84c3c22b8804000f5c /keyboards/wilba_tech/wt_main.c | |
| parent | 22aa2ce6b2f3bda51aca84d8f707c17f0301ff3b (diff) | |
| download | qmk_firmware-e47ab6a5752e16bd3b4288153798c12af1bee3d5.tar.gz qmk_firmware-e47ab6a5752e16bd3b4288153798c12af1bee3d5.zip | |
[Keyboard] wilba.tech PCB refactoring (#6982)
* Cleanup
* Refactor VIA rules.mk
* WT mono backlight refactor, VIA support
* Added WT75-C
* Fixed compile error
* Cleanup rules.mk
* Review changes
* Review changes
Diffstat (limited to 'keyboards/wilba_tech/wt_main.c')
| -rw-r--r-- | keyboards/wilba_tech/wt_main.c | 54 |
1 files changed, 22 insertions, 32 deletions
diff --git a/keyboards/wilba_tech/wt_main.c b/keyboards/wilba_tech/wt_main.c index e6ea4a21b..32fc6f9e4 100644 --- a/keyboards/wilba_tech/wt_main.c +++ b/keyboards/wilba_tech/wt_main.c | |||
| @@ -20,9 +20,9 @@ | |||
| 20 | #if RGB_BACKLIGHT_ENABLED | 20 | #if RGB_BACKLIGHT_ENABLED |
| 21 | #include "keyboards/wilba_tech/wt_rgb_backlight.h" | 21 | #include "keyboards/wilba_tech/wt_rgb_backlight.h" |
| 22 | #endif // RGB_BACKLIGHT_ENABLED | 22 | #endif // RGB_BACKLIGHT_ENABLED |
| 23 | #ifdef WT_MONO_BACKLIGHT | 23 | #if MONO_BACKLIGHT_ENABLED |
| 24 | #include "keyboards/wilba_tech/wt_mono_backlight.h" | 24 | #include "keyboards/wilba_tech/wt_mono_backlight.h" |
| 25 | #endif // WT_MONO_BACKLIGHT | 25 | #endif // MONO_BACKLIGHT_ENABLED |
| 26 | #include "keyboards/wilba_tech/via_api.h" // Temporary hack | 26 | #include "keyboards/wilba_tech/via_api.h" // Temporary hack |
| 27 | #include "keyboards/wilba_tech/via_keycodes.h" // Temporary hack | 27 | #include "keyboards/wilba_tech/via_keycodes.h" // Temporary hack |
| 28 | 28 | ||
| @@ -150,7 +150,7 @@ void raw_hid_receive( uint8_t *data, uint8_t length ) | |||
| 150 | break; | 150 | break; |
| 151 | } | 151 | } |
| 152 | #endif // DYNAMIC_KEYMAP_ENABLE | 152 | #endif // DYNAMIC_KEYMAP_ENABLE |
| 153 | #if RGB_BACKLIGHT_ENABLED | 153 | #if RGB_BACKLIGHT_ENABLED || MONO_BACKLIGHT_ENABLED |
| 154 | case id_backlight_config_set_value: | 154 | case id_backlight_config_set_value: |
| 155 | { | 155 | { |
| 156 | backlight_config_set_value(command_data); | 156 | backlight_config_set_value(command_data); |
| @@ -166,7 +166,7 @@ void raw_hid_receive( uint8_t *data, uint8_t length ) | |||
| 166 | backlight_config_save(); | 166 | backlight_config_save(); |
| 167 | break; | 167 | break; |
| 168 | } | 168 | } |
| 169 | #endif // RGB_BACKLIGHT_ENABLED | 169 | #endif // RGB_BACKLIGHT_ENABLED || MONO_BACKLIGHT_ENABLED |
| 170 | case id_eeprom_reset: | 170 | case id_eeprom_reset: |
| 171 | { | 171 | { |
| 172 | eeprom_reset(); | 172 | eeprom_reset(); |
| @@ -202,16 +202,16 @@ void main_init(void) | |||
| 202 | // If the EEPROM has the magic, the data is good. | 202 | // If the EEPROM has the magic, the data is good. |
| 203 | // OK to load from EEPROM. | 203 | // OK to load from EEPROM. |
| 204 | if (eeprom_is_valid()) { | 204 | if (eeprom_is_valid()) { |
| 205 | #if RGB_BACKLIGHT_ENABLED | 205 | #if RGB_BACKLIGHT_ENABLED || MONO_BACKLIGHT_ENABLED |
| 206 | backlight_config_load(); | 206 | backlight_config_load(); |
| 207 | #endif // RGB_BACKLIGHT_ENABLED | 207 | #endif // RGB_BACKLIGHT_ENABLED || MONO_BACKLIGHT_ENABLED |
| 208 | } else { | 208 | } else { |
| 209 | #if RGB_BACKLIGHT_ENABLED | 209 | #if RGB_BACKLIGHT_ENABLED || MONO_BACKLIGHT_ENABLED |
| 210 | // 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, |
| 211 | // save the default values to the EEPROM. Default values | 211 | // save the default values to the EEPROM. Default values |
| 212 | // come from construction of the zeal_backlight_config instance. | 212 | // come from construction of the backlight_config instance. |
| 213 | backlight_config_save(); | 213 | backlight_config_save(); |
| 214 | #endif // RGB_BACKLIGHT_ENABLED | 214 | #endif // RGB_BACKLIGHT_ENABLED || MONO_BACKLIGHT_ENABLED |
| 215 | #ifdef DYNAMIC_KEYMAP_ENABLE | 215 | #ifdef DYNAMIC_KEYMAP_ENABLE |
| 216 | // This resets the keymaps in EEPROM to what is in flash. | 216 | // This resets the keymaps in EEPROM to what is in flash. |
| 217 | dynamic_keymap_reset(); | 217 | dynamic_keymap_reset(); |
| @@ -222,20 +222,13 @@ void main_init(void) | |||
| 222 | eeprom_set_valid(true); | 222 | eeprom_set_valid(true); |
| 223 | } | 223 | } |
| 224 | 224 | ||
| 225 | #if RGB_BACKLIGHT_ENABLED | 225 | #if RGB_BACKLIGHT_ENABLED || MONO_BACKLIGHT_ENABLED |
| 226 | // Initialize LED drivers for backlight. | ||
| 227 | backlight_init_drivers(); | ||
| 228 | |||
| 229 | backlight_timer_init(); | ||
| 230 | backlight_timer_enable(); | ||
| 231 | #endif // RGB_BACKLIGHT_ENABLED | ||
| 232 | #ifdef WT_MONO_BACKLIGHT | ||
| 233 | // Initialize LED drivers for backlight. | 226 | // Initialize LED drivers for backlight. |
| 234 | backlight_init_drivers(); | 227 | backlight_init_drivers(); |
| 235 | 228 | ||
| 236 | backlight_timer_init(); | 229 | backlight_timer_init(); |
| 237 | backlight_timer_enable(); | 230 | backlight_timer_enable(); |
| 238 | #endif // WT_MONO_BACKLIGHT | 231 | #endif // RGB_BACKLIGHT_ENABLED || MONO_BACKLIGHT_ENABLED |
| 239 | } | 232 | } |
| 240 | 233 | ||
| 241 | void bootmagic_lite(void) | 234 | void bootmagic_lite(void) |
| @@ -267,22 +260,18 @@ void matrix_init_kb(void) | |||
| 267 | 260 | ||
| 268 | void matrix_scan_kb(void) | 261 | void matrix_scan_kb(void) |
| 269 | { | 262 | { |
| 270 | #if RGB_BACKLIGHT_ENABLED | 263 | #if RGB_BACKLIGHT_ENABLED || MONO_BACKLIGHT_ENABLED |
| 271 | // This only updates the LED driver buffers if something has changed. | ||
| 272 | backlight_update_pwm_buffers(); | ||
| 273 | #endif // RGB_BACKLIGHT_ENABLED | ||
| 274 | #ifdef WT_MONO_BACKLIGHT | ||
| 275 | // This only updates the LED driver buffers if something has changed. | 264 | // This only updates the LED driver buffers if something has changed. |
| 276 | backlight_update_pwm_buffers(); | 265 | backlight_update_pwm_buffers(); |
| 277 | #endif | 266 | #endif // RGB_BACKLIGHT_ENABLED || MONO_BACKLIGHT_ENABLED |
| 278 | matrix_scan_user(); | 267 | matrix_scan_user(); |
| 279 | } | 268 | } |
| 280 | 269 | ||
| 281 | bool process_record_kb(uint16_t keycode, keyrecord_t *record) | 270 | bool process_record_kb(uint16_t keycode, keyrecord_t *record) |
| 282 | { | 271 | { |
| 283 | #if RGB_BACKLIGHT_ENABLED | 272 | #if RGB_BACKLIGHT_ENABLED || MONO_BACKLIGHT_ENABLED |
| 284 | process_record_backlight(keycode, record); | 273 | process_record_backlight(keycode, record); |
| 285 | #endif // RGB_BACKLIGHT_ENABLED | 274 | #endif // RGB_BACKLIGHT_ENABLED || MONO_BACKLIGHT_ENABLED |
| 286 | 275 | ||
| 287 | switch(keycode) { | 276 | switch(keycode) { |
| 288 | case FN_MO13: | 277 | case FN_MO13: |
| @@ -372,22 +361,23 @@ void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) | |||
| 372 | 361 | ||
| 373 | void led_set_kb(uint8_t usb_led) | 362 | void led_set_kb(uint8_t usb_led) |
| 374 | { | 363 | { |
| 375 | #if RGB_BACKLIGHT_ENABLED | 364 | #if RGB_BACKLIGHT_ENABLED || MONO_BACKLIGHT_ENABLED |
| 376 | backlight_set_indicator_state(usb_led); | 365 | backlight_set_indicator_state(usb_led); |
| 377 | #endif // RGB_BACKLIGHT_ENABLED | 366 | #endif // RGB_BACKLIGHT_ENABLED || MONO_BACKLIGHT_ENABLED |
| 367 | led_set_user(usb_led); | ||
| 378 | } | 368 | } |
| 379 | 369 | ||
| 380 | void suspend_power_down_kb(void) | 370 | void suspend_power_down_kb(void) |
| 381 | { | 371 | { |
| 382 | #if RGB_BACKLIGHT_ENABLED | 372 | #if RGB_BACKLIGHT_ENABLED || MONO_BACKLIGHT_ENABLED |
| 383 | backlight_set_suspend_state(true); | 373 | backlight_set_suspend_state(true); |
| 384 | #endif // RGB_BACKLIGHT_ENABLED | 374 | #endif // RGB_BACKLIGHT_ENABLED || MONO_BACKLIGHT_ENABLED |
| 385 | } | 375 | } |
| 386 | 376 | ||
| 387 | void suspend_wakeup_init_kb(void) | 377 | void suspend_wakeup_init_kb(void) |
| 388 | { | 378 | { |
| 389 | #if RGB_BACKLIGHT_ENABLED | 379 | #if RGB_BACKLIGHT_ENABLED || MONO_BACKLIGHT_ENABLED |
| 390 | backlight_set_suspend_state(false); | 380 | backlight_set_suspend_state(false); |
| 391 | #endif // RGB_BACKLIGHT_ENABLED | 381 | #endif // RGB_BACKLIGHT_ENABLED || MONO_BACKLIGHT_ENABLED |
| 392 | } | 382 | } |
| 393 | 383 | ||
