1 /* Copyright 2017 Jason Williams
2 * Copyright 2017 Jack Humbert
3 * Copyright 2018 Yiancar
4 * Copyright 2019 Clueboard
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.
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.
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/>.
24 typedef struct Point {
27 } __attribute__((packed)) Point;
29 typedef struct led_matrix {
33 uint8_t row:4; // 16 max
34 uint8_t col:4; // 16 max
39 } __attribute__((packed)) led_matrix;
41 extern const led_matrix g_leds[DRIVER_LED_TOTAL];
53 uint8_t hue :8; // Unused by led_matrix
54 uint8_t sat :8; // Unused by led_matrix
56 uint8_t speed :8;//EECONFIG needs to be increased to support this
60 enum led_matrix_effects {
61 LED_MATRIX_UNIFORM_BRIGHTNESS = 1,
62 // All new effects go above this line
66 void led_matrix_set_index_value(int index, uint8_t value);
67 void led_matrix_set_index_value_all(uint8_t value);
69 // This runs after another backlight effect and replaces
71 void led_matrix_indicators(void);
72 void led_matrix_indicators_kb(void);
73 void led_matrix_indicators_user(void);
75 void led_matrix_init(void);
76 void led_matrix_setup_drivers(void);
78 void led_matrix_set_suspend_state(bool state);
79 void led_matrix_set_indicator_state(uint8_t state);
81 void led_matrix_task(void);
83 // This should not be called from an interrupt
84 // (eg. from a timer interrupt).
85 // Call this while idle (in between matrix scans).
86 // If the buffer is dirty, it will update the driver with the buffer.
87 void led_matrix_update_pwm_buffers(void);
89 bool process_led_matrix(uint16_t keycode, keyrecord_t *record);
91 uint32_t led_matrix_get_tick(void);
93 void led_matrix_toggle(void);
94 void led_matrix_enable(void);
95 void led_matrix_enable_noeeprom(void);
96 void led_matrix_disable(void);
97 void led_matrix_disable_noeeprom(void);
98 void led_matrix_step(void);
99 void led_matrix_step_reverse(void);
100 void led_matrix_increase_val(void);
101 void led_matrix_decrease_val(void);
102 void led_matrix_increase_speed(void);
103 void led_matrix_decrease_speed(void);
104 void led_matrix_mode(uint8_t mode, bool eeprom_write);
105 void led_matrix_mode_noeeprom(uint8_t mode);
106 uint8_t led_matrix_get_mode(void);
107 void led_matrix_set_value(uint8_t mode, bool eeprom_write);
109 #ifndef BACKLIGHT_ENABLE
110 #define backlight_toggle() backlight_matrix_toggle()
111 #define backlight_enable() backlight_matrix_enable()
112 #define backlight_enable_noeeprom() backlight_matrix_enable_noeeprom()
113 #define backlight_disable() backlight_matrix_disable()
114 #define backlight_disable_noeeprom() backlight_matrix_disable_noeeprom()
115 #define backlight_step() backlight_matrix_step()
116 #define backlight_set_value(val) backlight_matrix_set_value(val)
117 #define backlight_set_value_noeeprom(val) backlight_matrix_set_value_noeeprom(val)
118 #define backlight_step_reverse() backlight_matrix_step_reverse()
119 #define backlight_increase_val() backlight_matrix_increase_val()
120 #define backlight_decrease_val() backlight_matrix_decrease_val()
121 #define backlight_increase_speed() backlight_matrix_increase_speed()
122 #define backlight_decrease_speed() backlight_matrix_decrease_speed()
123 #define backlight_mode(mode) backlight_matrix_mode(mode)
124 #define backlight_mode_noeeprom(mode) backlight_matrix_mode_noeeprom(mode)
125 #define backlight_get_mode() backlight_matrix_get_mode()
129 /* Perform any initialisation required for the other driver functions to work. */
132 /* Set the brightness of a single LED in the buffer. */
133 void (*set_value)(int index, uint8_t value);
134 /* Set the brightness of all LEDS on the keyboard in the buffer. */
135 void (*set_value_all)(uint8_t value);
136 /* Flush any buffered changes to the hardware. */
138 } led_matrix_driver_t;
140 extern const led_matrix_driver_t led_matrix_driver;