v1_3.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. This program is free software: you can redistribute it and/or modify
  3. it under the terms of the GNU General Public License as published by
  4. the Free Software Foundation, either version 2 of the License, or
  5. (at your option) any later version.
  6. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9. GNU General Public License for more details.
  10. You should have received a copy of the GNU General Public License
  11. along with this program. If not, see <http://www.gnu.org/licenses/>.
  12. */
  13. #include "v1_3.h"
  14. // Optional override functions below.
  15. // You can leave any or all of these undefined.
  16. // These are only required if you want to perform custom actions.
  17. // For reference, visit https://docs.qmk.fm/#/custom_quantum_functions?id=layer-change-code
  18. // keyboard start-up codes
  19. // runs once when the firmware starts up
  20. void matrix_init_kb(void) {
  21. // Set the LEDs pins
  22. setPinOutput(D5); // Layer 1 Status LED
  23. matrix_init_user();
  24. }
  25. // looping keyboard codes
  26. // runs every cycle (a lot)
  27. /*void matrix_scan_kb(void) {
  28. matrix_scan_user();
  29. }*/
  30. // per-action keyboard codes
  31. // runs for every key-press action, just before processing by the firmware
  32. /*bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
  33. return process_record_user(keycode, record);
  34. }*/
  35. // Set LED based on layer
  36. __attribute__((weak)) layer_state_t layer_state_set_user(layer_state_t state) {
  37. writePin(D5, layer_state_cmp(state, 1));
  38. return state;
  39. }
  40. bool led_update_kb(led_t led_state) {
  41. bool res = led_update_user(led_state);
  42. if (res) {
  43. // writePin sets the pin high for 1 and low for 0.
  44. writePin(D4, led_state.caps_lock);
  45. }
  46. return res;
  47. }