rgb_matrix.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /* Copyright 2017 Jason Williams
  2. * Copyright 2017 Jack Humbert
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #ifndef RGB_MATRIX_H
  18. #define RGB_MATRIX_H
  19. #include <stdint.h>
  20. #include <stdbool.h>
  21. #include "color.h"
  22. #include "is31fl3731.h"
  23. #include "quantum.h"
  24. typedef struct Point {
  25. uint8_t x;
  26. uint8_t y;
  27. } __attribute__((packed)) Point;
  28. typedef struct rgb_led {
  29. union {
  30. uint8_t raw;
  31. struct {
  32. uint8_t row:4; // 16 max
  33. uint8_t col:4; // 16 max
  34. };
  35. } matrix_co;
  36. Point point;
  37. uint8_t modifier:1;
  38. } __attribute__((packed)) rgb_led;
  39. extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL];
  40. typedef struct
  41. {
  42. HSV color;
  43. uint8_t index;
  44. } rgb_indicator;
  45. typedef union {
  46. uint32_t raw;
  47. struct {
  48. bool enable :1;
  49. uint8_t mode :6;
  50. uint16_t hue :9;
  51. uint8_t sat :8;
  52. uint8_t val :8;
  53. uint8_t speed :8;//EECONFIG needs to be increased to support this
  54. };
  55. } rgb_config_t;
  56. enum rgb_matrix_effects {
  57. RGB_MATRIX_SOLID_COLOR = 1,
  58. RGB_MATRIX_ALPHAS_MODS,
  59. RGB_MATRIX_DUAL_BEACON,
  60. RGB_MATRIX_GRADIENT_UP_DOWN,
  61. RGB_MATRIX_RAINDROPS,
  62. RGB_MATRIX_CYCLE_ALL,
  63. RGB_MATRIX_CYCLE_LEFT_RIGHT,
  64. RGB_MATRIX_CYCLE_UP_DOWN,
  65. RGB_MATRIX_RAINBOW_BEACON,
  66. RGB_MATRIX_RAINBOW_PINWHEELS,
  67. RGB_MATRIX_RAINBOW_MOVING_CHEVRON,
  68. RGB_MATRIX_JELLYBEAN_RAINDROPS,
  69. #ifdef RGB_MATRIX_KEYPRESSES
  70. RGB_MATRIX_SOLID_REACTIVE,
  71. RGB_MATRIX_SPLASH,
  72. RGB_MATRIX_MULTISPLASH,
  73. RGB_MATRIX_SOLID_SPLASH,
  74. RGB_MATRIX_SOLID_MULTISPLASH,
  75. #endif
  76. RGB_MATRIX_EFFECT_MAX
  77. };
  78. void rgb_matrix_set_color( int index, uint8_t red, uint8_t green, uint8_t blue );
  79. // This runs after another backlight effect and replaces
  80. // colors already set
  81. void rgb_matrix_indicators(void);
  82. void rgb_matrix_indicators_kb(void);
  83. void rgb_matrix_indicators_user(void);
  84. void rgb_matrix_single_LED_test(void);
  85. void rgb_matrix_init(void);
  86. void rgb_matrix_setup_drivers(void);
  87. void rgb_matrix_set_suspend_state(bool state);
  88. void rgb_matrix_set_indicator_state(uint8_t state);
  89. void rgb_matrix_task(void);
  90. // This should not be called from an interrupt
  91. // (eg. from a timer interrupt).
  92. // Call this while idle (in between matrix scans).
  93. // If the buffer is dirty, it will update the driver with the buffer.
  94. void rgb_matrix_update_pwm_buffers(void);
  95. bool process_rgb_matrix(uint16_t keycode, keyrecord_t *record);
  96. void rgb_matrix_increase(void);
  97. void rgb_matrix_decrease(void);
  98. // void *backlight_get_key_color_eeprom_address(uint8_t led);
  99. // void backlight_get_key_color( uint8_t led, HSV *hsv );
  100. // void backlight_set_key_color( uint8_t row, uint8_t column, HSV hsv );
  101. void rgb_matrix_test_led( uint8_t index, bool red, bool green, bool blue );
  102. uint32_t rgb_matrix_get_tick(void);
  103. void rgblight_toggle(void);
  104. void rgblight_step(void);
  105. void rgblight_step_reverse(void);
  106. void rgblight_increase_hue(void);
  107. void rgblight_decrease_hue(void);
  108. void rgblight_increase_sat(void);
  109. void rgblight_decrease_sat(void);
  110. void rgblight_increase_val(void);
  111. void rgblight_decrease_val(void);
  112. void rgblight_increase_speed(void);
  113. void rgblight_decrease_speed(void);
  114. void rgblight_mode(uint8_t mode);
  115. uint32_t rgblight_get_mode(void);
  116. #endif