wt70_jb.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /* Copyright 2020 Jason Williams (Wilba)
  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. */
  16. #include "wt70_jb.h"
  17. bool g_first_execution = false;
  18. void keyboard_pre_init_kb(void) {
  19. setPinOutput(F1);
  20. keyboard_pre_init_user();
  21. }
  22. bool led_update_kb(led_t led_state) {
  23. if (led_update_user(led_state)) {
  24. writePin(F1, led_state.caps_lock);
  25. }
  26. return true;
  27. }
  28. // This is some magic so that PCBs flashed with VIA firmware at the factory
  29. // will start with an RGB test pattern. Not relevant for non-VIA firmware.
  30. #ifdef VIA_ENABLE
  31. // Called from via_init() if VIA_ENABLE
  32. // Called from matrix_init_kb() if not VIA_ENABLE
  33. void via_init_kb(void)
  34. {
  35. // If the EEPROM has the magic, the data is good.
  36. // OK to load from EEPROM
  37. if (via_eeprom_is_valid()) {
  38. } else {
  39. // Cache "first execution" state so we can do something
  40. // specific after QMK initialization has done its thing.
  41. g_first_execution = true;
  42. // DO NOT set EEPROM valid here, let caller do this
  43. }
  44. }
  45. void keyboard_post_init_kb() {
  46. // This is a workaround to ensure "EEPROM cleared" PCBs will
  47. // start with the RGB test mode, essential for testing LEDs.
  48. if ( g_first_execution ) {
  49. rgblight_mode(RGBLIGHT_MODE_RGB_TEST);
  50. }
  51. }
  52. #endif // VIA_ENABLE