aboutsummaryrefslogtreecommitdiff
path: root/quantum/rgb_matrix.h
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/rgb_matrix.h')
-rw-r--r--quantum/rgb_matrix.h135
1 files changed, 135 insertions, 0 deletions
diff --git a/quantum/rgb_matrix.h b/quantum/rgb_matrix.h
new file mode 100644
index 000000000..ef93c6d5c
--- /dev/null
+++ b/quantum/rgb_matrix.h
@@ -0,0 +1,135 @@
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
27typedef struct Point {
28 uint8_t x;
29 uint8_t y;
30} __attribute__((packed)) Point;
31
32typedef 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
45extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL];
46
47typedef struct
48{
49 HSV color;
50 uint8_t index;
51} rgb_indicator;
52
53typedef 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 };
62} rgb_config_t;
63
64enum rgb_matrix_effects {
65 RGB_MATRIX_SOLID_COLOR = 1,
66 RGB_MATRIX_SOLID_REACTIVE,
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_SPLASH,
80 RGB_MATRIX_MULTISPLASH,
81 RGB_MATRIX_SOLID_SPLASH,
82 RGB_MATRIX_SOLID_MULTISPLASH,
83#endif
84 RGB_MATRIX_EFFECT_MAX
85};
86
87void rgb_matrix_set_color( int index, uint8_t red, uint8_t green, uint8_t blue );
88
89// This runs after another backlight effect and replaces
90// colors already set
91void rgb_matrix_indicators(void);
92void rgb_matrix_indicators_kb(void);
93void rgb_matrix_indicators_user(void);
94
95void rgb_matrix_single_LED_test(void);
96
97void rgb_matrix_init_drivers(void);
98
99void rgb_matrix_set_suspend_state(bool state);
100void rgb_matrix_set_indicator_state(uint8_t state);
101
102
103void rgb_matrix_task(void);
104
105// This should not be called from an interrupt
106// (eg. from a timer interrupt).
107// Call this while idle (in between matrix scans).
108// If the buffer is dirty, it will update the driver with the buffer.
109void rgb_matrix_update_pwm_buffers(void);
110
111bool process_rgb_matrix(uint16_t keycode, keyrecord_t *record);
112
113void rgb_matrix_increase(void);
114void rgb_matrix_decrease(void);
115
116// void *backlight_get_key_color_eeprom_address(uint8_t led);
117// void backlight_get_key_color( uint8_t led, HSV *hsv );
118// void backlight_set_key_color( uint8_t row, uint8_t column, HSV hsv );
119
120void rgb_matrix_test_led( uint8_t index, bool red, bool green, bool blue );
121uint32_t rgb_matrix_get_tick(void);
122
123void rgblight_toggle(void);
124void rgblight_step(void);
125void rgblight_step_reverse(void);
126void rgblight_increase_hue(void);
127void rgblight_decrease_hue(void);
128void rgblight_increase_sat(void);
129void rgblight_decrease_sat(void);
130void rgblight_increase_val(void);
131void rgblight_decrease_val(void);
132void rgblight_mode(uint8_t mode);
133uint32_t rgblight_get_mode(void);
134
135#endif