led_matrix.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /* Copyright 2017 Jason Williams
  2. * Copyright 2017 Jack Humbert
  3. * Copyright 2018 Yiancar
  4. * Copyright 2019 Clueboard
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #pragma once
  20. #include "led_matrix_types.h"
  21. #ifndef BACKLIGHT_ENABLE
  22. # error You must define BACKLIGHT_ENABLE with LED_MATRIX_ENABLE
  23. #endif
  24. enum led_matrix_effects {
  25. LED_MATRIX_UNIFORM_BRIGHTNESS = 1,
  26. // All new effects go above this line
  27. LED_MATRIX_EFFECT_MAX
  28. };
  29. void led_matrix_set_index_value(int index, uint8_t value);
  30. void led_matrix_set_index_value_all(uint8_t value);
  31. // This runs after another backlight effect and replaces
  32. // colors already set
  33. void led_matrix_indicators(void);
  34. void led_matrix_indicators_kb(void);
  35. void led_matrix_indicators_user(void);
  36. void led_matrix_init(void);
  37. void led_matrix_setup_drivers(void);
  38. void led_matrix_set_suspend_state(bool state);
  39. void led_matrix_set_indicator_state(uint8_t state);
  40. void led_matrix_task(void);
  41. // This should not be called from an interrupt
  42. // (eg. from a timer interrupt).
  43. // Call this while idle (in between matrix scans).
  44. // If the buffer is dirty, it will update the driver with the buffer.
  45. void led_matrix_update_pwm_buffers(void);
  46. bool process_led_matrix(uint16_t keycode, keyrecord_t *record);
  47. uint32_t led_matrix_get_tick(void);
  48. void led_matrix_toggle(void);
  49. void led_matrix_enable(void);
  50. void led_matrix_enable_noeeprom(void);
  51. void led_matrix_disable(void);
  52. void led_matrix_disable_noeeprom(void);
  53. void led_matrix_step(void);
  54. void led_matrix_step_reverse(void);
  55. void led_matrix_increase_val(void);
  56. void led_matrix_decrease_val(void);
  57. void led_matrix_increase_speed(void);
  58. void led_matrix_decrease_speed(void);
  59. void led_matrix_mode(uint8_t mode, bool eeprom_write);
  60. void led_matrix_mode_noeeprom(uint8_t mode);
  61. uint8_t led_matrix_get_mode(void);
  62. void led_matrix_set_value(uint8_t mode);
  63. void led_matrix_set_value_noeeprom(uint8_t mode);
  64. typedef struct {
  65. /* Perform any initialisation required for the other driver functions to work. */
  66. void (*init)(void);
  67. /* Set the brightness of a single LED in the buffer. */
  68. void (*set_value)(int index, uint8_t value);
  69. /* Set the brightness of all LEDS on the keyboard in the buffer. */
  70. void (*set_value_all)(uint8_t value);
  71. /* Flush any buffered changes to the hardware. */
  72. void (*flush)(void);
  73. } led_matrix_driver_t;
  74. extern const led_matrix_driver_t led_matrix_driver;
  75. extern led_eeconfig_t led_matrix_eeconfig;
  76. extern led_config_t g_led_config;