aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan <fauxpark@gmail.com>2021-03-08 16:55:00 +1100
committerGitHub <noreply@github.com>2021-03-08 16:55:00 +1100
commit9155b59e1a496b64f7aa576e6e4cb84fd0a9607b (patch)
treef9960c672a5521d24217fffb2321ee1b978b7f8b
parentb0069c5c05dac2c910d51ef7f3bf4133721a9c49 (diff)
downloadqmk_firmware-9155b59e1a496b64f7aa576e6e4cb84fd0a9607b.tar.gz
qmk_firmware-9155b59e1a496b64f7aa576e6e4cb84fd0a9607b.zip
LED Matrix: decouple from Backlight (#12054)
-rw-r--r--common_features.mk5
-rw-r--r--quantum/led_matrix.c8
-rw-r--r--quantum/led_matrix.h4
-rw-r--r--quantum/process_keycode/process_backlight.c29
-rw-r--r--quantum/quantum.c9
-rw-r--r--quantum/quantum.h12
-rw-r--r--tmk_core/common/eeconfig.h5
7 files changed, 45 insertions, 27 deletions
diff --git a/common_features.mk b/common_features.mk
index bdde278b9..fdc481fd2 100644
--- a/common_features.mk
+++ b/common_features.mk
@@ -223,11 +223,10 @@ VALID_LED_MATRIX_TYPES := IS31FL3731 custom
223 223
224ifeq ($(strip $(LED_MATRIX_ENABLE)), yes) 224ifeq ($(strip $(LED_MATRIX_ENABLE)), yes)
225 ifeq ($(filter $(LED_MATRIX_DRIVER),$(VALID_LED_MATRIX_TYPES)),) 225 ifeq ($(filter $(LED_MATRIX_DRIVER),$(VALID_LED_MATRIX_TYPES)),)
226 $(error LED_MATRIX_DRIVER="$(LED_MATRIX_DRIVER)" is not a valid matrix type) 226 $(error "$(LED_MATRIX_DRIVER)" is not a valid matrix type)
227 else 227 else
228 BACKLIGHT_ENABLE = yes
229 BACKLIGHT_DRIVER = custom
230 OPT_DEFS += -DLED_MATRIX_ENABLE 228 OPT_DEFS += -DLED_MATRIX_ENABLE
229 SRC += $(QUANTUM_DIR)/process_keycode/process_backlight.c
231 SRC += $(QUANTUM_DIR)/led_matrix.c 230 SRC += $(QUANTUM_DIR)/led_matrix.c
232 SRC += $(QUANTUM_DIR)/led_matrix_drivers.c 231 SRC += $(QUANTUM_DIR)/led_matrix_drivers.c
233 endif 232 endif
diff --git a/quantum/led_matrix.c b/quantum/led_matrix.c
index 4f1f06c7a..39bccdd58 100644
--- a/quantum/led_matrix.c
+++ b/quantum/led_matrix.c
@@ -45,10 +45,6 @@ led_eeconfig_t led_matrix_eeconfig;
45# define LED_DISABLE_WHEN_USB_SUSPENDED false 45# define LED_DISABLE_WHEN_USB_SUSPENDED false
46#endif 46#endif
47 47
48#ifndef EECONFIG_LED_MATRIX
49# define EECONFIG_LED_MATRIX EECONFIG_RGBLIGHT
50#endif
51
52#if !defined(LED_MATRIX_MAXIMUM_BRIGHTNESS) || LED_MATRIX_MAXIMUM_BRIGHTNESS > 255 48#if !defined(LED_MATRIX_MAXIMUM_BRIGHTNESS) || LED_MATRIX_MAXIMUM_BRIGHTNESS > 255
53# define LED_MATRIX_MAXIMUM_BRIGHTNESS 255 49# define LED_MATRIX_MAXIMUM_BRIGHTNESS 255
54#endif 50#endif
@@ -135,7 +131,7 @@ void led_matrix_set_suspend_state(bool state) { g_suspend_state = state; }
135void led_matrix_all_off(void) { led_matrix_set_index_value_all(0); } 131void led_matrix_all_off(void) { led_matrix_set_index_value_all(0); }
136 132
137// Uniform brightness 133// Uniform brightness
138void led_matrix_uniform_brightness(void) { led_matrix_set_index_value_all(LED_MATRIX_MAXIMUM_BRIGHTNESS / BACKLIGHT_LEVELS * led_matrix_eeconfig.val); } 134void led_matrix_uniform_brightness(void) { led_matrix_set_index_value_all(led_matrix_eeconfig.val); }
139 135
140void led_matrix_custom(void) {} 136void led_matrix_custom(void) {}
141 137
@@ -344,5 +340,3 @@ void led_matrix_set_value(uint8_t val) {
344 led_matrix_set_value_noeeprom(val); 340 led_matrix_set_value_noeeprom(val);
345 eeconfig_update_led_matrix(led_matrix_eeconfig.raw); 341 eeconfig_update_led_matrix(led_matrix_eeconfig.raw);
346} 342}
347
348void backlight_set(uint8_t val) { led_matrix_set_value(val); }
diff --git a/quantum/led_matrix.h b/quantum/led_matrix.h
index 85bae43c1..0817d1357 100644
--- a/quantum/led_matrix.h
+++ b/quantum/led_matrix.h
@@ -21,10 +21,6 @@
21 21
22#include "led_matrix_types.h" 22#include "led_matrix_types.h"
23 23
24#ifndef BACKLIGHT_ENABLE
25# error You must define BACKLIGHT_ENABLE with LED_MATRIX_ENABLE
26#endif
27
28enum led_matrix_effects { 24enum led_matrix_effects {
29 LED_MATRIX_UNIFORM_BRIGHTNESS = 1, 25 LED_MATRIX_UNIFORM_BRIGHTNESS = 1,
30 // All new effects go above this line 26 // All new effects go above this line
diff --git a/quantum/process_keycode/process_backlight.c b/quantum/process_keycode/process_backlight.c
index 4d12f6813..8b70339a5 100644
--- a/quantum/process_keycode/process_backlight.c
+++ b/quantum/process_keycode/process_backlight.c
@@ -16,11 +16,35 @@
16 16
17#include "process_backlight.h" 17#include "process_backlight.h"
18 18
19#include "backlight.h" 19#ifdef LED_MATRIX_ENABLE
20# include "led_matrix.h"
21#else
22# include "backlight.h"
23#endif
20 24
21bool process_backlight(uint16_t keycode, keyrecord_t *record) { 25bool process_backlight(uint16_t keycode, keyrecord_t *record) {
22 if (record->event.pressed) { 26 if (record->event.pressed) {
23 switch (keycode) { 27 switch (keycode) {
28#ifdef LED_MATRIX_ENABLE
29 case BL_ON:
30 led_matrix_enable();
31 return false;
32 case BL_OFF:
33 led_matrix_disable();
34 return false;
35 case BL_DEC:
36 led_matrix_decrease_val();
37 return false;
38 case BL_INC:
39 led_matrix_increase_val();
40 return false;
41 case BL_TOGG:
42 led_matrix_toggle();
43 return false;
44 case BL_STEP:
45 led_matrix_step();
46 return false;
47#else
24 case BL_ON: 48 case BL_ON:
25 backlight_level(BACKLIGHT_LEVELS); 49 backlight_level(BACKLIGHT_LEVELS);
26 return false; 50 return false;
@@ -39,10 +63,11 @@ bool process_backlight(uint16_t keycode, keyrecord_t *record) {
39 case BL_STEP: 63 case BL_STEP:
40 backlight_step(); 64 backlight_step();
41 return false; 65 return false;
42#ifdef BACKLIGHT_BREATHING 66# ifdef BACKLIGHT_BREATHING
43 case BL_BRTG: 67 case BL_BRTG:
44 backlight_toggle_breathing(); 68 backlight_toggle_breathing();
45 return false; 69 return false;
70# endif
46#endif 71#endif
47 } 72 }
48 } 73 }
diff --git a/quantum/quantum.c b/quantum/quantum.c
index 78601ce6b..59d95f2f5 100644
--- a/quantum/quantum.c
+++ b/quantum/quantum.c
@@ -234,7 +234,7 @@ bool process_record_quantum(keyrecord_t *record) {
234#ifdef AUDIO_ENABLE 234#ifdef AUDIO_ENABLE
235 process_audio(keycode, record) && 235 process_audio(keycode, record) &&
236#endif 236#endif
237#ifdef BACKLIGHT_ENABLE 237#if defined(BACKLIGHT_ENABLE) || defined(LED_MATRIX_ENABLE)
238 process_backlight(keycode, record) && 238 process_backlight(keycode, record) &&
239#endif 239#endif
240#ifdef STENO_ENABLE 240#ifdef STENO_ENABLE
@@ -387,15 +387,14 @@ void matrix_init_quantum() {
387 led_init_ports(); 387 led_init_ports();
388#endif 388#endif
389#ifdef BACKLIGHT_ENABLE 389#ifdef BACKLIGHT_ENABLE
390# ifdef LED_MATRIX_ENABLE
391 led_matrix_init();
392# else
393 backlight_init_ports(); 390 backlight_init_ports();
394# endif
395#endif 391#endif
396#ifdef AUDIO_ENABLE 392#ifdef AUDIO_ENABLE
397 audio_init(); 393 audio_init();
398#endif 394#endif
395#ifdef LED_MATRIX_ENABLE
396 led_matrix_init();
397#endif
399#ifdef RGB_MATRIX_ENABLE 398#ifdef RGB_MATRIX_ENABLE
400 rgb_matrix_init(); 399 rgb_matrix_init();
401#endif 400#endif
diff --git a/quantum/quantum.h b/quantum/quantum.h
index 070bd0131..7c2dcaa82 100644
--- a/quantum/quantum.h
+++ b/quantum/quantum.h
@@ -30,11 +30,11 @@
30#include "keymap.h" 30#include "keymap.h"
31 31
32#ifdef BACKLIGHT_ENABLE 32#ifdef BACKLIGHT_ENABLE
33# ifdef LED_MATRIX_ENABLE 33# include "backlight.h"
34# include "led_matrix.h" 34#endif
35# else 35
36# include "backlight.h" 36#ifdef LED_MATRIX_ENABLE
37# endif 37# include "led_matrix.h"
38#endif 38#endif
39 39
40#if defined(RGBLIGHT_ENABLE) 40#if defined(RGBLIGHT_ENABLE)
@@ -98,7 +98,7 @@ extern layer_state_t layer_state;
98# include "process_music.h" 98# include "process_music.h"
99#endif 99#endif
100 100
101#ifdef BACKLIGHT_ENABLE 101#if defined(BACKLIGHT_ENABLE) || defined(LED_MATRIX_ENABLE)
102# include "process_backlight.h" 102# include "process_backlight.h"
103#endif 103#endif
104 104
diff --git a/tmk_core/common/eeconfig.h b/tmk_core/common/eeconfig.h
index 39bc51d5d..9e18fd4e1 100644
--- a/tmk_core/common/eeconfig.h
+++ b/tmk_core/common/eeconfig.h
@@ -43,9 +43,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
43#define EECONFIG_VELOCIKEY (uint8_t *)23 43#define EECONFIG_VELOCIKEY (uint8_t *)23
44 44
45#define EECONFIG_HAPTIC (uint32_t *)24 45#define EECONFIG_HAPTIC (uint32_t *)24
46
47// Mutually exclusive
48#define EECONFIG_LED_MATRIX (uint32_t *)28
46#define EECONFIG_RGB_MATRIX (uint32_t *)28 49#define EECONFIG_RGB_MATRIX (uint32_t *)28
47// Speed & Flags 50// Speed & Flags
51#define EECONFIG_LED_MATRIX_EXTENDED (uint16_t *)32
48#define EECONFIG_RGB_MATRIX_EXTENDED (uint16_t *)32 52#define EECONFIG_RGB_MATRIX_EXTENDED (uint16_t *)32
53
49// TODO: Combine these into a single word and single block of EEPROM 54// TODO: Combine these into a single word and single block of EEPROM
50#define EECONFIG_KEYMAP_UPPER_BYTE (uint8_t *)34 55#define EECONFIG_KEYMAP_UPPER_BYTE (uint8_t *)34
51// Size of EEPROM being used, other code can refer to this for available EEPROM 56// Size of EEPROM being used, other code can refer to this for available EEPROM