v2.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /* Copyright 2017 MechMerlin <mechmerlin@gmail.com>
  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 "v2.h"
  17. #include "indicator_leds.h"
  18. enum BACKLIGHT_AREAS {
  19. BACKLIGHT_ALPHA = 0b0000001,
  20. BACKLIGHT_EXTRA = 0b0000010,
  21. BACKLIGHT_MODNUM = 0b0000100,
  22. BACKLIGHT_FROW = 0b0001000,
  23. BACKLIGHT_RGB = 0b0010000,
  24. BACKLIGHT_SWITCH = 0b0001111
  25. };
  26. uint8_t backlight_rgb_r = 255;
  27. uint8_t backlight_rgb_g = 0;
  28. uint8_t backlight_rgb_b = 0;
  29. void backlight_set(uint8_t level) {
  30. /*
  31. * DISABLE for now -> this causes issues with initial rgb setup
  32. */
  33. /*
  34. level & BACKLIGHT_ALPHA ? (PORTB |= 0b00000010) : (PORTB &= ~0b00000010);
  35. level & BACKLIGHT_EXTRA ? (PORTB |= 0b00000100) : (PORTB &= ~0b00000100);
  36. level & BACKLIGHT_MODNUM ? (PORTB |= 0b00001000) : (PORTB &= ~0b00001000);
  37. level & BACKLIGHT_FROW ? (PORTE |= 0b01000000) : (PORTE &= ~0b01000000);
  38. level & BACKLIGHT_RGB ? backlight_toggle_rgb(true) : backlight_toggle_rgb(false);
  39. */
  40. }
  41. // Port from backlight_update_state
  42. void led_set_kb(uint8_t usb_led) {
  43. bool status[8] = {
  44. host_keyboard_leds() & (1<<USB_LED_SCROLL_LOCK), /* LED 3 */
  45. host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK), /* LED 2 */
  46. host_keyboard_leds() & (1<<USB_LED_NUM_LOCK), /* LED 1 */
  47. layer_state & (1<<2), /* LED 6 */
  48. layer_state & (1<<1), /* LED 5 */
  49. layer_state & (1<<0) ? 0: 1, /* LED 4 */
  50. layer_state & (1<<5), /* LED 8 */
  51. layer_state & (1<<4) /* LED 7 */
  52. };
  53. indicator_leds_set(status);
  54. }
  55. bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
  56. return process_record_user(keycode, record);
  57. }