logo

qmk_firmware

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

kmac.c (1558B)


  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 "quantum.h"
  17. #define F_ROW_MASK 0b01
  18. #define WASD_MASK 0b10
  19. void backlight_init_ports(void) {
  20. gpio_set_pin_output(B1);
  21. gpio_set_pin_output(B2);
  22. gpio_set_pin_output(B3);
  23. gpio_set_pin_output(B4);
  24. gpio_set_pin_output(D7);
  25. }
  26. /* Backlight pin configuration
  27. * F-row: High PB1
  28. * W: Low PB4
  29. * A: Low PB2
  30. * S: Low PB3
  31. * D: Low PD7
  32. */
  33. void backlight_set(uint8_t level) {
  34. // F-row
  35. if (level & F_ROW_MASK) {
  36. gpio_write_pin_high(B1);
  37. } else {
  38. gpio_write_pin_low(B1);
  39. }
  40. // WASD
  41. if (level & WASD_MASK) {
  42. gpio_write_pin_low(B2);
  43. gpio_write_pin_low(B3);
  44. gpio_write_pin_low(B4);
  45. gpio_write_pin_low(D7);
  46. } else {
  47. gpio_write_pin_high(B2);
  48. gpio_write_pin_high(B3);
  49. gpio_write_pin_high(B4);
  50. gpio_write_pin_high(D7);
  51. }
  52. }