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.

109 lines
2.6 KiB

  1. /* Copyright 2017-2019 Mathias Andersson <wraul@dbox.se>
  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 "kmac.h"
  17. #define CAPS_PIN B0
  18. #define SCROLL_PIN E6
  19. #define F_ROW_MASK 0b01
  20. #define WASD_MASK 0b10
  21. // Optional override functions below.
  22. // You can leave any or all of these undefined.
  23. // These are only required if you want to perform custom actions.
  24. void matrix_init_kb(void) {
  25. // put your keyboard start-up code here
  26. // runs once when the firmware starts up
  27. setPinOutput(CAPS_PIN);
  28. setPinOutput(SCROLL_PIN);
  29. matrix_init_user();
  30. }
  31. /*
  32. void matrix_scan_kb(void) {
  33. // put your looping keyboard code here
  34. // runs every cycle (a lot)
  35. matrix_scan_user();
  36. }
  37. bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
  38. // put your per-action keyboard code here
  39. // runs for every action, just before processing by the firmware
  40. return process_record_user(keycode, record);
  41. }
  42. */
  43. /* LED pin configuration
  44. * Scroll Lock: Low PE6
  45. * Caps Lock: Low PB0
  46. */
  47. void led_set_kb(uint8_t usb_led) {
  48. if (IS_LED_ON(usb_led, USB_LED_CAPS_LOCK)) {
  49. writePinLow(CAPS_PIN);
  50. } else {
  51. writePinHigh(CAPS_PIN);
  52. }
  53. if (IS_LED_ON(usb_led, USB_LED_SCROLL_LOCK)) {
  54. writePinLow(SCROLL_PIN);
  55. } else {
  56. writePinHigh(SCROLL_PIN);
  57. }
  58. led_set_user(usb_led);
  59. }
  60. void backlight_init_ports(void) {
  61. setPinOutput(B1);
  62. setPinOutput(B2);
  63. setPinOutput(B3);
  64. setPinOutput(B4);
  65. setPinOutput(D7);
  66. }
  67. /* Backlight pin configuration
  68. * F-row: High PB1
  69. * W: Low PB4
  70. * A: Low PB2
  71. * S: Low PB3
  72. * D: Low PD7
  73. */
  74. void backlight_set(uint8_t level) {
  75. // F-row
  76. if (level & F_ROW_MASK) {
  77. writePinHigh(B1);
  78. } else {
  79. writePinLow(B1);
  80. }
  81. // WASD
  82. if (level & WASD_MASK) {
  83. writePinLow(B2);
  84. writePinLow(B3);
  85. writePinLow(B4);
  86. writePinLow(D7);
  87. } else {
  88. writePinHigh(B2);
  89. writePinHigh(B3);
  90. writePinHigh(B4);
  91. writePinHigh(D7);
  92. }
  93. }