rgb_matrix.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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. } zeal_indicator;
  45. typedef struct
  46. {
  47. bool enabled:1; // |
  48. bool use_split_left_shift:1; // |
  49. bool use_split_right_shift:1; // |
  50. bool use_7u_spacebar:1; // |
  51. bool use_iso_enter:1; // |
  52. bool disable_when_usb_suspended:1; // |
  53. bool __pad6:1; // |
  54. bool __pad7:1; // 1 byte
  55. uint8_t disable_after_timeout; // 1 byte
  56. uint8_t brightness; // 1 byte
  57. uint8_t effect; // 1 byte
  58. HSV color_1; // 3 bytes
  59. HSV color_2; // 3 bytes
  60. zeal_indicator caps_lock_indicator; // 4 bytes
  61. zeal_indicator layer_1_indicator; // 4 bytes
  62. zeal_indicator layer_2_indicator; // 4 bytes
  63. zeal_indicator layer_3_indicator; // 4 bytes
  64. uint16_t alphas_mods[5]; // 10 bytes
  65. } rgb_matrix_config; // = 36 bytes
  66. #define EEPROM_BACKLIGHT_CONFIG_ADDR ((void*)35)
  67. // rgb_matrix_config uses 36 bytes
  68. // 35+36=71
  69. #define EEPROM_BACKLIGHT_KEY_COLOR_ADDR ((void*)71)
  70. void backlight_effect_single_LED_test(void);
  71. void backlight_config_set_alphas_mods( uint16_t *value );
  72. void backlight_config_load(void);
  73. void backlight_config_save(void);
  74. void backlight_init_drivers(void);
  75. void backlight_timer_init(void);
  76. void backlight_timer_enable(void);
  77. void backlight_timer_disable(void);
  78. void backlight_set_suspend_state(bool state);
  79. void backlight_set_indicator_state(uint8_t state);
  80. void backlight_rgb_task(void);
  81. // This should not be called from an interrupt
  82. // (eg. from a timer interrupt).
  83. // Call this while idle (in between matrix scans).
  84. // If the buffer is dirty, it will update the driver with the buffer.
  85. void backlight_update_pwm_buffers(void);
  86. void backlight_set_key_hit(uint8_t row, uint8_t col);
  87. void backlight_unset_key_hit(uint8_t row, uint8_t col);
  88. void backlight_effect_increase(void);
  89. void backlight_effect_decrease(void);
  90. void backlight_brightness_increase(void);
  91. void backlight_brightness_decrease(void);
  92. void backlight_color_1_hue_increase(void);
  93. void backlight_color_1_hue_decrease(void);
  94. void backlight_color_1_sat_increase(void);
  95. void backlight_color_1_sat_decrease(void);
  96. void backlight_color_2_hue_increase(void);
  97. void backlight_color_2_hue_decrease(void);
  98. void backlight_color_2_sat_increase(void);
  99. void backlight_color_2_sat_decrease(void);
  100. void *backlight_get_key_color_eeprom_address(uint8_t led);
  101. void backlight_get_key_color( uint8_t led, HSV *hsv );
  102. void backlight_set_key_color( uint8_t row, uint8_t column, HSV hsv );
  103. void backlight_test_led( uint8_t index, bool red, bool green, bool blue );
  104. uint32_t backlight_get_tick(void);
  105. void backlight_debug_led(bool state);
  106. void rgblight_toggle(void);
  107. void rgblight_step(void);
  108. void rgblight_step_reverse(void);
  109. void rgblight_increase_hue(void);
  110. void rgblight_decrease_hue(void);
  111. void rgblight_increase_sat(void);
  112. void rgblight_decrease_sat(void);
  113. void rgblight_increase_val(void);
  114. void rgblight_decrease_val(void);
  115. void rgblight_mode(uint8_t mode);
  116. uint32_t rgblight_get_mode(void);
  117. #endif