logo

qmk_firmware

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

hbcp.c (2302B)


  1. /* Copyright 2019 Josh Hinnebusch
  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. // Indicator color definitions
  18. #ifndef HSV_CAPS
  19. #define HSV_CAPS 0, 0, 120 // Define caps lock color (H, S, V)
  20. #endif
  21. #ifndef HSV_NLCK
  22. #define HSV_NLCK 0, 0, 120 // Define num lock color (H, S, V)
  23. #endif
  24. #ifndef HSV_SCRL
  25. #define HSV_SCRL 0, 0, 120 // Define scroll lock color (H, S, V)
  26. #endif
  27. #ifndef HSV_BLACK
  28. #define HSV_BLACK 0, 0, 0 // Define 'black' color, more like 'LED off' (H, S, V)
  29. #endif
  30. // #define HSV_custom_color H, S, V
  31. #ifdef RGBLIGHT_ENABLE
  32. bool led_update_kb(led_t led_state) {
  33. bool res = led_update_user(led_state);
  34. if (res) {
  35. if (led_state.caps_lock) {
  36. rgblight_sethsv_at(HSV_CAPS, 0);
  37. } else {
  38. rgblight_sethsv_at(HSV_BLACK, 0);
  39. }
  40. if (led_state.num_lock) {
  41. rgblight_sethsv_at(HSV_NLCK, 1);
  42. } else {
  43. rgblight_sethsv_at(HSV_BLACK, 1);
  44. }
  45. if (led_state.scroll_lock) {
  46. rgblight_sethsv_at(HSV_SCRL, 2);
  47. } else {
  48. rgblight_sethsv_at(HSV_BLACK, 2);
  49. }
  50. }
  51. return false;
  52. }
  53. __attribute__ ((weak))
  54. void keyboard_post_init_user(void) {
  55. rgblight_set_effect_range(3, RGBLIGHT_LED_COUNT-3);
  56. led_t led_state = {
  57. .caps_lock = true,
  58. .num_lock = true,
  59. .scroll_lock = true
  60. };
  61. led_update_kb(led_state);
  62. wait_ms(300);
  63. led_update_kb((led_t){0});
  64. }
  65. __attribute__ ((weak))
  66. void hbcp_sethsv_range(uint8_t hue, uint8_t sat, uint8_t val, uint8_t start, uint8_t end) {
  67. for (uint8_t i = start; i < end; i++) {
  68. rgblight_sethsv_at(hue, sat, val, i);
  69. }
  70. }
  71. #endif