]> git.donarmstrong.com Git - qmk_firmware.git/blob - quantum/rgb_matrix.h
adds timeout to avr i2c
[qmk_firmware.git] / quantum / rgb_matrix.h
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
18 #ifndef RGB_MATRIX_H
19 #define RGB_MATRIX_H
20
21 #include <stdint.h>
22 #include <stdbool.h>
23 #include "color.h"
24 #include "is31fl3731.h"
25 #include "quantum.h"
26
27 typedef struct Point {
28         uint8_t x;
29         uint8_t y;
30 } __attribute__((packed)) Point;
31
32 typedef struct rgb_led {
33         union {
34                 uint8_t raw;
35                 struct {
36                         uint8_t row:4; // 16 max
37                         uint8_t col:4; // 16 max
38                 };
39         } matrix_co;
40         Point point;
41         uint8_t modifier:1;
42 } __attribute__((packed)) rgb_led;
43
44
45 extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL];
46
47 typedef struct
48 {
49         HSV color;
50         uint8_t index;
51 } rgb_indicator;
52
53 typedef union {
54   uint32_t raw;
55   struct {
56     bool     enable  :1;
57     uint8_t  mode    :6;
58     uint16_t hue     :9;
59     uint8_t  sat     :8;
60     uint8_t  val     :8;
61     uint8_t  speed   :8;//EECONFIG needs to be increased to support this
62   };
63 } rgb_config_t;
64
65 enum rgb_matrix_effects {
66         RGB_MATRIX_SOLID_COLOR = 1,
67     RGB_MATRIX_ALPHAS_MODS,
68     RGB_MATRIX_DUAL_BEACON,
69     RGB_MATRIX_GRADIENT_UP_DOWN,
70     RGB_MATRIX_RAINDROPS,
71     RGB_MATRIX_CYCLE_ALL,
72     RGB_MATRIX_CYCLE_LEFT_RIGHT,
73     RGB_MATRIX_CYCLE_UP_DOWN,
74     RGB_MATRIX_RAINBOW_BEACON,
75     RGB_MATRIX_RAINBOW_PINWHEELS,
76     RGB_MATRIX_RAINBOW_MOVING_CHEVRON,
77     RGB_MATRIX_JELLYBEAN_RAINDROPS,
78 #ifdef RGB_MATRIX_KEYPRESSES
79     RGB_MATRIX_SOLID_REACTIVE,
80     RGB_MATRIX_SPLASH,
81     RGB_MATRIX_MULTISPLASH,
82     RGB_MATRIX_SOLID_SPLASH,
83     RGB_MATRIX_SOLID_MULTISPLASH,
84 #endif
85     RGB_MATRIX_EFFECT_MAX
86 };
87
88 void rgb_matrix_set_color( int index, uint8_t red, uint8_t green, uint8_t blue );
89
90 // This runs after another backlight effect and replaces
91 // colors already set
92 void rgb_matrix_indicators(void);
93 void rgb_matrix_indicators_kb(void);
94 void rgb_matrix_indicators_user(void);
95
96 void rgb_matrix_single_LED_test(void);
97
98 void rgb_matrix_init(void);
99 void rgb_matrix_setup_drivers(void);
100
101 void rgb_matrix_set_suspend_state(bool state);
102 void rgb_matrix_set_indicator_state(uint8_t state);
103
104
105 void rgb_matrix_task(void);
106
107 // This should not be called from an interrupt
108 // (eg. from a timer interrupt).
109 // Call this while idle (in between matrix scans).
110 // If the buffer is dirty, it will update the driver with the buffer.
111 void rgb_matrix_update_pwm_buffers(void);
112
113 bool process_rgb_matrix(uint16_t keycode, keyrecord_t *record);
114
115 void rgb_matrix_increase(void);
116 void rgb_matrix_decrease(void);
117
118 // void *backlight_get_key_color_eeprom_address(uint8_t led);
119 // void backlight_get_key_color( uint8_t led, HSV *hsv );
120 // void backlight_set_key_color( uint8_t row, uint8_t column, HSV hsv );
121
122 void rgb_matrix_test_led( uint8_t index, bool red, bool green, bool blue );
123 uint32_t rgb_matrix_get_tick(void);
124
125 void rgblight_toggle(void);
126 void rgblight_step(void);
127 void rgblight_step_reverse(void);
128 void rgblight_increase_hue(void);
129 void rgblight_decrease_hue(void);
130 void rgblight_increase_sat(void);
131 void rgblight_decrease_sat(void);
132 void rgblight_increase_val(void);
133 void rgblight_decrease_val(void);
134 void rgblight_increase_speed(void);
135 void rgblight_decrease_speed(void);
136 void rgblight_mode(uint8_t mode);
137 uint32_t rgblight_get_mode(void);
138
139 #endif