You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

106 lines
3.5 KiB

  1. /* Copyright 2022 imchipwood && deveth0
  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 "quantum.h"
  17. #ifdef RGB_MATRIX_ENABLE
  18. led_config_t g_led_config = {{// Key Matrix to LED Index
  19. {NO_LED, 0, 1, 2, 3},
  20. {NO_LED, 7, 6, 5, 4},
  21. {NO_LED, 8, 9, 10, 11},
  22. {NO_LED, 15, 14, 13, 12}},
  23. {// LED Index to Physical Position
  24. {0, 0},
  25. {75, 0},
  26. {149, 0},
  27. {224, 0},
  28. {224, 21},
  29. {149, 21},
  30. {75, 21},
  31. {0, 21},
  32. {0, 43},
  33. {75, 43},
  34. {149, 43},
  35. {224, 43},
  36. {224, 64},
  37. {149, 64},
  38. {75, 64},
  39. {0, 64}},
  40. {// LED Index to Flag
  41. 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}};
  42. #endif
  43. void keyboard_pre_init_kb(void) {
  44. // Set LED IO as outputs
  45. gpio_set_pin_output(LED_00);
  46. gpio_set_pin_output(LED_01);
  47. gpio_set_pin_output(LED_02);
  48. keyboard_pre_init_user();
  49. }
  50. bool shutdown_kb(bool jump_to_bootloader) {
  51. if (!shutdown_user(jump_to_bootloader)) {
  52. return false;
  53. }
  54. // Shutdown LEDs
  55. gpio_write_pin_low(LED_00);
  56. gpio_write_pin_low(LED_01);
  57. gpio_write_pin_low(LED_02);
  58. return true;
  59. }
  60. layer_state_t layer_state_set_kb(layer_state_t state) {
  61. // Layer LEDs act as binary indication of current layer
  62. uint8_t layer = get_highest_layer(state);
  63. gpio_write_pin(LED_00, layer & 0b1);
  64. gpio_write_pin(LED_01, (layer >> 1) & 0b1);
  65. uprintf("%d string", layer);
  66. return layer_state_set_user(state);
  67. }
  68. // Optional override functions below.
  69. // You can leave any or all of these undefined.
  70. // These are only required if you want to perform custom actions.
  71. void matrix_init_kb(void) {
  72. // put your keyboard start-up code here
  73. // runs once when the firmware starts up
  74. uint8_t led_delay_ms = 80;
  75. for (int i = 0; i < 2; i++) {
  76. gpio_write_pin_high(LED_00);
  77. gpio_write_pin_high(LED_01);
  78. gpio_write_pin_high(LED_02);
  79. wait_ms(led_delay_ms);
  80. gpio_write_pin_low(LED_00);
  81. gpio_write_pin_low(LED_01);
  82. gpio_write_pin_low(LED_02);
  83. if (i < 1) {
  84. wait_ms(led_delay_ms);
  85. }
  86. }
  87. matrix_init_user();
  88. }
  89. bool led_update_kb(led_t led_state) {
  90. if (!led_update_user(led_state)) return false;
  91. // put your keyboard LED indicator (ex: Caps Lock LED) toggling code here
  92. gpio_write_pin(LED_02, !led_state.num_lock);
  93. return true;
  94. }