rgb_backlight.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /* Copyright 2017 Jason Williams (Wilba)
  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. #pragma once
  17. #if RGB_BACKLIGHT_ENABLED
  18. #else
  19. #error rgb_backlight.h included when RGB_BACKLIGHT_ENABLED == 0
  20. #endif // RGB_BACKLIGHT_ENABLED
  21. #include <stdint.h>
  22. #include <stdbool.h>
  23. #include "quantum/color.h"
  24. typedef struct PACKED
  25. {
  26. uint8_t h;
  27. uint8_t s;
  28. } HS;
  29. typedef struct
  30. {
  31. HS color;
  32. uint8_t index;
  33. } backlight_config_indicator;
  34. typedef struct
  35. {
  36. bool use_split_backspace:1; // |
  37. bool use_split_left_shift:1; // |
  38. bool use_split_right_shift:1; // |
  39. bool use_7u_spacebar:1; // |
  40. bool use_iso_enter:1; // |
  41. bool disable_when_usb_suspended:1; // |
  42. bool disable_hhkb_blocker_leds:1; // |
  43. bool __pad7:1; // 1 byte
  44. uint8_t disable_after_timeout; // 1 byte
  45. uint8_t brightness; // 1 byte
  46. uint8_t effect; // 1 byte
  47. uint8_t effect_speed; // 1 byte
  48. HS color_1; // 2 bytes
  49. HS color_2; // 2 bytes
  50. backlight_config_indicator caps_lock_indicator; // 3 bytes
  51. backlight_config_indicator layer_1_indicator; // 3 bytes
  52. backlight_config_indicator layer_2_indicator; // 3 bytes
  53. backlight_config_indicator layer_3_indicator; // 3 bytes
  54. uint16_t alphas_mods[5]; // 10 bytes
  55. #if defined(RGB_BACKLIGHT_M6_B)
  56. HS custom_color[6]; // 12 bytes
  57. #endif
  58. } backlight_config; // = 31 bytes (M6-B = 43 bytes)
  59. void backlight_config_load(void);
  60. void backlight_config_save(void);
  61. void backlight_config_set_value( uint8_t *data );
  62. void backlight_config_get_value( uint8_t *data );
  63. void backlight_init_drivers(void);
  64. void backlight_timer_init(void);
  65. void backlight_timer_enable(void);
  66. void backlight_timer_disable(void);
  67. void backlight_set_suspend_state(bool state);
  68. void backlight_set_indicator_state(uint8_t state);
  69. // This should not be called from an interrupt
  70. // (eg. from a timer interrupt).
  71. // Call this while idle (in between matrix scans).
  72. // If the buffer is dirty, it will update the driver with the buffer.
  73. void backlight_update_pwm_buffers(void);
  74. // Handle backlight specific keycodes
  75. bool process_record_backlight(uint16_t keycode, keyrecord_t *record);
  76. void backlight_set_key_hit(uint8_t row, uint8_t col);
  77. void backlight_effect_increase(void);
  78. void backlight_effect_decrease(void);
  79. void backlight_effect_speed_increase(void);
  80. void backlight_effect_speed_decrease(void);
  81. void backlight_brightness_increase(void);
  82. void backlight_brightness_decrease(void);
  83. void backlight_color_1_hue_increase(void);
  84. void backlight_color_1_hue_decrease(void);
  85. void backlight_color_1_sat_increase(void);
  86. void backlight_color_1_sat_decrease(void);
  87. void backlight_color_2_hue_increase(void);
  88. void backlight_color_2_hue_decrease(void);
  89. void backlight_color_2_sat_increase(void);
  90. void backlight_color_2_sat_decrease(void);
  91. void backlight_test_led( uint8_t index, bool red, bool green, bool blue );
  92. void backlight_debug_led(bool state);