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.

58 lines
1.7 KiB

  1. /*
  2. Copyright 2022 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_b.h"
  15. void keyboard_pre_init_kb(void) {
  16. setPinOutput(LAYER_1);
  17. setPinOutput(LAYER_2);
  18. setPinOutput(LAYER_3);
  19. setPinOutput(LAYER_4);
  20. setPinOutput(LAYER_5);
  21. keyboard_pre_init_user();
  22. }
  23. layer_state_t layer_state_set_kb(layer_state_t state) {
  24. state = layer_state_set_user(state);
  25. setLayerLed(state);
  26. return state;
  27. }
  28. /* Set indicator leds to indicate which layer is active */
  29. void setLayerLed(layer_state_t state){
  30. writePinLow(LAYER_1);
  31. writePinLow(LAYER_2);
  32. writePinLow(LAYER_3);
  33. writePinLow(LAYER_4);
  34. writePinLow(LAYER_5);
  35. switch (get_highest_layer(state)) {
  36. case 0:
  37. gpio_write_pin_high(LAYER_1);
  38. break;
  39. case 1:
  40. gpio_write_pin_high(LAYER_2);
  41. break;
  42. case 2:
  43. gpio_write_pin_high(LAYER_3);
  44. break;
  45. case 3:
  46. gpio_write_pin_high(LAYER_4);
  47. break;
  48. case 4:
  49. gpio_write_pin_high(LAYER_5);
  50. break;
  51. }
  52. }