logo

qmk_firmware

custom branch of QMK firmware git clone https://anongit.hacktivis.me/git/qmk_firmware.git

rev_a.c (3672B)


  1. /*
  2. Copyright 2021 Stefan Sundin "4pplet" <4pplet@protonmail.com>
  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. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. #include "rev_a.h"
  15. void board_init(void) {
  16. gpio_set_pin_input_high(CAPS_PIN);
  17. gpio_set_pin_input_high(SCROLL_PIN);
  18. gpio_set_pin_input_high(NUM_PIN);
  19. }
  20. /* Set indicator leds to indicate lock states */
  21. bool led_update_kb(led_t led_state) {
  22. bool res = led_update_user(led_state);
  23. if(res && LOCK_LIGHTS) {
  24. if(led_state.caps_lock){
  25. gpio_set_pin_output(CAPS_PIN);
  26. gpio_write_pin(CAPS_PIN, 0);
  27. }
  28. else
  29. gpio_set_pin_input_high(CAPS_PIN);
  30. if(led_state.scroll_lock){
  31. gpio_set_pin_output(SCROLL_PIN);
  32. gpio_write_pin(SCROLL_PIN, 0);
  33. }
  34. else
  35. gpio_set_pin_input_high(SCROLL_PIN);
  36. if(led_state.num_lock){
  37. gpio_set_pin_output(NUM_PIN);
  38. gpio_write_pin(NUM_PIN, 0);
  39. }
  40. else
  41. gpio_set_pin_input_high(NUM_PIN);
  42. }
  43. return res;
  44. }
  45. layer_state_t layer_state_set_kb(layer_state_t state) {
  46. state = layer_state_set_user(state);
  47. if(DISPLAY_LAYERS){
  48. setLayerLed(state);
  49. }
  50. return state;
  51. }
  52. /* Set indicator leds to indicate which layer is active */
  53. void setLayerLed(layer_state_t state){
  54. switch(get_highest_layer(state)){
  55. case 0 :
  56. gpio_set_pin_output(LAYER_1);
  57. gpio_write_pin(LAYER_1, 0);
  58. gpio_set_pin_input_high(LAYER_2);
  59. gpio_set_pin_input_high(LAYER_3);
  60. gpio_set_pin_input_high(LAYER_4);
  61. gpio_set_pin_input_high(LAYER_5);
  62. break;
  63. case 1 :
  64. gpio_set_pin_output(LAYER_2);
  65. gpio_write_pin(LAYER_2, 0);
  66. gpio_set_pin_input_high(LAYER_1);
  67. gpio_set_pin_input_high(LAYER_3);
  68. gpio_set_pin_input_high(LAYER_4);
  69. gpio_set_pin_input_high(LAYER_5);
  70. break;
  71. case 2 :
  72. gpio_set_pin_output(LAYER_3);
  73. gpio_write_pin(LAYER_3, 0);
  74. gpio_set_pin_input_high(LAYER_1);
  75. gpio_set_pin_input_high(LAYER_2);
  76. gpio_set_pin_input_high(LAYER_4);
  77. gpio_set_pin_input_high(LAYER_5);
  78. break;
  79. case 3 :
  80. gpio_write_pin(LAYER_4, 0);
  81. gpio_set_pin_input_high(LAYER_5);
  82. gpio_set_pin_input_high(LAYER_1);
  83. gpio_set_pin_input_high(LAYER_2);
  84. gpio_set_pin_input_high(LAYER_3);
  85. gpio_set_pin_output(LAYER_4);
  86. break;
  87. case 4 :
  88. gpio_set_pin_output(LAYER_5);
  89. gpio_write_pin(LAYER_5, 0);
  90. gpio_set_pin_input_high(LAYER_1);
  91. gpio_set_pin_input_high(LAYER_2);
  92. gpio_set_pin_input_high(LAYER_3);
  93. gpio_set_pin_input_high(LAYER_4);
  94. break;
  95. default :
  96. gpio_set_pin_input_high(LAYER_1);
  97. gpio_set_pin_input_high(LAYER_2);
  98. gpio_set_pin_input_high(LAYER_3);
  99. gpio_set_pin_input_high(LAYER_4);
  100. gpio_set_pin_input_high(LAYER_5);
  101. }
  102. }