diff options
| author | Ryan <fauxpark@gmail.com> | 2021-03-08 16:55:00 +1100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-03-08 16:55:00 +1100 |
| commit | 9155b59e1a496b64f7aa576e6e4cb84fd0a9607b (patch) | |
| tree | f9960c672a5521d24217fffb2321ee1b978b7f8b /quantum | |
| parent | b0069c5c05dac2c910d51ef7f3bf4133721a9c49 (diff) | |
| download | qmk_firmware-9155b59e1a496b64f7aa576e6e4cb84fd0a9607b.tar.gz qmk_firmware-9155b59e1a496b64f7aa576e6e4cb84fd0a9607b.zip | |
LED Matrix: decouple from Backlight (#12054)
Diffstat (limited to 'quantum')
| -rw-r--r-- | quantum/led_matrix.c | 8 | ||||
| -rw-r--r-- | quantum/led_matrix.h | 4 | ||||
| -rw-r--r-- | quantum/process_keycode/process_backlight.c | 29 | ||||
| -rw-r--r-- | quantum/quantum.c | 9 | ||||
| -rw-r--r-- | quantum/quantum.h | 12 |
5 files changed, 38 insertions, 24 deletions
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; } | |||
| 135 | void led_matrix_all_off(void) { led_matrix_set_index_value_all(0); } | 131 | void led_matrix_all_off(void) { led_matrix_set_index_value_all(0); } |
| 136 | 132 | ||
| 137 | // Uniform brightness | 133 | // Uniform brightness |
| 138 | void led_matrix_uniform_brightness(void) { led_matrix_set_index_value_all(LED_MATRIX_MAXIMUM_BRIGHTNESS / BACKLIGHT_LEVELS * led_matrix_eeconfig.val); } | 134 | void led_matrix_uniform_brightness(void) { led_matrix_set_index_value_all(led_matrix_eeconfig.val); } |
| 139 | 135 | ||
| 140 | void led_matrix_custom(void) {} | 136 | void 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 | |||
| 348 | void 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 | |||
| 28 | enum led_matrix_effects { | 24 | enum 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 | ||
| 21 | bool process_backlight(uint16_t keycode, keyrecord_t *record) { | 25 | bool 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 | ||
