logo

qmk_firmware

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

meridian.c (2166B)


  1. /*
  2. Copyright 2020 Holten Campbell
  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 "quantum.h"
  15. //Initialize B12 for in-switch caps lock
  16. void keyboard_pre_init_kb(void){
  17. gpio_set_pin_output(B12);
  18. keyboard_pre_init_user();
  19. }
  20. //Initialize all RGB indicators to 'off'
  21. __attribute__((weak))
  22. void keyboard_post_init_user(void) {
  23. rgblight_setrgb_at(0, 0, 0, 0); // [..., 0] = top LED
  24. rgblight_setrgb_at(0, 0, 0, 1); // [..., 1] = middle LED
  25. rgblight_setrgb_at(0, 0, 0, 2); // [..., 2] = bottom LED
  26. }
  27. //Indicator light function
  28. bool led_update_kb(led_t led_state) {
  29. bool res = led_update_user(led_state);
  30. if (res) {
  31. // gpio_write_pin(B12, !led_state.caps_lock); //Un-comment this line to enable in-switch capslock indicator
  32. if (led_state.caps_lock) {
  33. rgblight_setrgb_at(0, 255, 0, 0); //green
  34. } else {
  35. rgblight_setrgb_at(0, 0, 0, 0);
  36. }
  37. if (led_state.num_lock) {
  38. rgblight_setrgb_at(0, 0, 255, 1); //blue
  39. } else {
  40. rgblight_setrgb_at(0, 0, 0, 1);
  41. }
  42. if (led_state.scroll_lock) {
  43. rgblight_setrgb_at(255, 0, 0, 2); //red
  44. } else {
  45. rgblight_setrgb_at(0, 0, 0, 2);
  46. }
  47. }
  48. return res;
  49. }
  50. //Below is an exmaple of layer indication using one of the RGB indicatiors. As configured, uses the bottom indicator (2) to light up red when layer 1 is in use.
  51. /*
  52. layer_state_t layer_state_set_kb(layer_state_t state) {
  53. if (get_highest_layer(state) == 1) {
  54. rgblight_setrgb_at(255, 0, 0, 2);
  55. } else {
  56. rgblight_setrgb_at(0, 0, 0, 2);
  57. }
  58. return state;
  59. }
  60. */