From 74b7c3a4fb25010457b0813bd4a179c9b74dbd17 Mon Sep 17 00:00:00 2001 From: Ryan Caltabiano Date: Tue, 26 Mar 2019 21:21:03 -0500 Subject: [PATCH] Combined the keypresses || keyreleases define checks into a single define so I stop forgetting it where necessary --- quantum/quantum.c | 2 +- quantum/rgb_matrix.c | 24 +++++++++---------- quantum/rgb_matrix.h | 8 +++++-- .../solid_reactive_anim.h | 4 ++-- .../solid_reactive_simple_anim.h | 4 ++-- .../rgb_matrix_animations/solid_splash_anim.h | 4 ++-- quantum/rgb_matrix_animations/splash_anim.h | 4 ++-- quantum/rgb_matrix_types.h | 4 ++-- 8 files changed, 29 insertions(+), 25 deletions(-) diff --git a/quantum/quantum.c b/quantum/quantum.c index 606c764a891..8c928441c5a 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -274,7 +274,7 @@ bool process_record_quantum(keyrecord_t *record) { #ifdef HAPTIC_ENABLE process_haptic(keycode, record) && #endif //HAPTIC_ENABLE - #if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_KEYPRESSES) + #if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_KEYREACTIVE_ENABLED) process_rgb_matrix(keycode, record) && #endif process_record_kb(keycode, record) && diff --git a/quantum/rgb_matrix.c b/quantum/rgb_matrix.c index 16ca7e179c1..0728e2431fe 100644 --- a/quantum/rgb_matrix.c +++ b/quantum/rgb_matrix.c @@ -85,10 +85,10 @@ rgb_config_t rgb_matrix_config; rgb_counters_t g_rgb_counters; static uint32_t rgb_counters_buffer; -#if defined(RGB_MATRIX_KEYPRESSES) || defined(RGB_MATRIX_KEYRELEASES) +#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED last_hit_t g_last_hit_tracker; static last_hit_t last_hit_buffer; -#endif // defined(RGB_MATRIX_KEYPRESSES) || defined(RGB_MATRIX_KEYRELEASES) +#endif // RGB_MATRIX_KEYREACTIVE_ENABLED uint32_t eeconfig_read_rgb_matrix(void) { return eeprom_read_dword(EECONFIG_RGB_MATRIX); @@ -150,7 +150,7 @@ void rgb_matrix_set_color_all( uint8_t red, uint8_t green, uint8_t blue ) { } bool process_rgb_matrix(uint16_t keycode, keyrecord_t *record) { -#if defined(RGB_MATRIX_KEYPRESSES) || defined(RGB_MATRIX_KEYRELEASES) +#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED uint8_t led[LED_HITS_TO_REMEMBER]; uint8_t led_count = 0; @@ -182,7 +182,7 @@ bool process_rgb_matrix(uint16_t keycode, keyrecord_t *record) { last_hit_buffer.tick[index] = 0; last_hit_buffer.count++; } -#endif // defined(RGB_MATRIX_KEYPRESSES) || defined(RGB_MATRIX_KEYRELEASES) +#endif // RGB_MATRIX_KEYREACTIVE_ENABLED return true; } @@ -241,7 +241,7 @@ static void rgb_task_timers(void) { } // Update double buffer last hit timers -#if defined(RGB_MATRIX_KEYPRESSES) || defined(RGB_MATRIX_KEYRELEASES) +#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED uint8_t count = last_hit_buffer.count; for (uint8_t i = 0; i < count; ++i) { if (UINT16_MAX - deltaTime < last_hit_buffer.tick[i]) { @@ -250,7 +250,7 @@ static void rgb_task_timers(void) { } last_hit_buffer.tick[i] += deltaTime; } -#endif // defined(RGB_MATRIX_KEYPRESSES) || defined(RGB_MATRIX_KEYRELEASES) +#endif // RGB_MATRIX_KEYREACTIVE_ENABLED } static void rgb_task_sync(void) { @@ -265,9 +265,9 @@ static void rgb_task_start(void) { // update double buffers g_rgb_counters.tick = rgb_counters_buffer; -#if defined(RGB_MATRIX_KEYPRESSES) || defined(RGB_MATRIX_KEYRELEASES) +#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED g_last_hit_tracker = last_hit_buffer; -#endif // defined(RGB_MATRIX_KEYPRESSES) || defined(RGB_MATRIX_KEYRELEASES) +#endif // RGB_MATRIX_KEYREACTIVE_ENABLED // next task rgb_task_state = RENDERING; @@ -352,7 +352,7 @@ static void rgb_task_render(uint8_t effect) { rendering = rgb_matrix_digital_rain(&rgb_effect_params); // Max 9ms Avg 8ms | this is expensive, fix it break; #endif // DISABLE_RGB_MATRIX_DIGITAL_RAIN -#if defined(RGB_MATRIX_KEYPRESSES) || defined(RGB_MATRIX_KEYRELEASES) +#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED #ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE case RGB_MATRIX_SOLID_REACTIVE_SIMPLE: rendering = rgb_matrix_solid_reactive_simple(&rgb_effect_params);// Max 4ms Avg 3ms @@ -383,7 +383,7 @@ static void rgb_task_render(uint8_t effect) { rendering = rgb_matrix_solid_multisplash(&rgb_effect_params); // Max 10ms Avg 5ms break; #endif // DISABLE_RGB_MATRIX_SOLID_MULTISPLASH -#endif // defined(RGB_MATRIX_KEYPRESSES) || defined(RGB_MATRIX_KEYRELEASES) +#endif // RGB_MATRIX_KEYREACTIVE_ENABLED // Factory default magic value case UINT8_MAX: { @@ -461,7 +461,7 @@ void rgb_matrix_init(void) { // TODO: put the 1 second startup delay here? -#if defined(RGB_MATRIX_KEYPRESSES) || defined(RGB_MATRIX_KEYRELEASES) +#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED g_last_hit_tracker.count = 0; for (uint8_t i = 0; i < LED_HITS_TO_REMEMBER; ++i) { g_last_hit_tracker.tick[i] = UINT16_MAX; @@ -471,7 +471,7 @@ void rgb_matrix_init(void) { for (uint8_t i = 0; i < LED_HITS_TO_REMEMBER; ++i) { last_hit_buffer.tick[i] = UINT16_MAX; } -#endif +#endif // RGB_MATRIX_KEYREACTIVE_ENABLED if (!eeconfig_is_enabled()) { dprintf("rgb_matrix_init_drivers eeconfig is not enabled.\n"); diff --git a/quantum/rgb_matrix.h b/quantum/rgb_matrix.h index f1d831642ea..76f037f9791 100644 --- a/quantum/rgb_matrix.h +++ b/quantum/rgb_matrix.h @@ -39,6 +39,10 @@ #define RGB_MATRIX_LED_PROCESS_LIMIT (DRIVER_LED_TOTAL + 4) / 5 #endif +#if defined(RGB_MATRIX_KEYPRESSES) || defined(RGB_MATRIX_KEYRELEASES) + #define RGB_MATRIX_KEYREACTIVE_ENABLED +#endif + #if defined(RGB_MATRIX_LED_PROCESS_LIMIT) && RGB_MATRIX_LED_PROCESS_LIMIT > 0 && RGB_MATRIX_LED_PROCESS_LIMIT < DRIVER_LED_TOTAL #define RGB_MATRIX_USE_LIMITS(min, max) uint8_t min = RGB_MATRIX_LED_PROCESS_LIMIT * params->iter; \ uint8_t max = min + RGB_MATRIX_LED_PROCESS_LIMIT; \ @@ -99,7 +103,7 @@ enum rgb_matrix_effects { #ifndef DISABLE_RGB_MATRIX_DIGITAL_RAIN RGB_MATRIX_DIGITAL_RAIN, #endif // DISABLE_RGB_MATRIX_DIGITAL_RAIN -#if defined(RGB_MATRIX_KEYPRESSES) || defined(RGB_MATRIX_KEYRELEASES) +#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED #ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE RGB_MATRIX_SOLID_REACTIVE_SIMPLE, #endif // DISABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE @@ -118,7 +122,7 @@ enum rgb_matrix_effects { #ifndef DISABLE_RGB_MATRIX_SOLID_MULTISPLASH RGB_MATRIX_SOLID_MULTISPLASH, #endif // DISABLE_RGB_MATRIX_SOLID_MULTISPLASH -#endif // defined(RGB_MATRIX_KEYPRESSES) || defined(RGB_MATRIX_KEYRELEASES) +#endif // RGB_MATRIX_KEYREACTIVE_ENABLED RGB_MATRIX_EFFECT_MAX }; diff --git a/quantum/rgb_matrix_animations/solid_reactive_anim.h b/quantum/rgb_matrix_animations/solid_reactive_anim.h index 4a6cc2077db..220e542331a 100644 --- a/quantum/rgb_matrix_animations/solid_reactive_anim.h +++ b/quantum/rgb_matrix_animations/solid_reactive_anim.h @@ -1,5 +1,5 @@ #pragma once -#ifdef RGB_MATRIX_KEYPRESSES +#if defined(RGB_MATRIX_KEYREACTIVE_ENABLED) #ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE extern rgb_config_t rgb_matrix_config; @@ -30,4 +30,4 @@ bool rgb_matrix_solid_reactive(effect_params_t* params) { } #endif // DISABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON -#endif // RGB_MATRIX_KEYPRESSES +#endif // defined(RGB_MATRIX_KEYREACTIVE_ENABLED) diff --git a/quantum/rgb_matrix_animations/solid_reactive_simple_anim.h b/quantum/rgb_matrix_animations/solid_reactive_simple_anim.h index 933b06bc7fc..e84cd693924 100644 --- a/quantum/rgb_matrix_animations/solid_reactive_simple_anim.h +++ b/quantum/rgb_matrix_animations/solid_reactive_simple_anim.h @@ -1,5 +1,5 @@ #pragma once -#ifdef RGB_MATRIX_KEYPRESSES +#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED #ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE extern rgb_config_t rgb_matrix_config; @@ -29,4 +29,4 @@ bool rgb_matrix_solid_reactive_simple(effect_params_t* params) { } #endif // DISABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE -#endif // RGB_MATRIX_KEYPRESSES +#endif // RGB_MATRIX_KEYREACTIVE_ENABLED diff --git a/quantum/rgb_matrix_animations/solid_splash_anim.h b/quantum/rgb_matrix_animations/solid_splash_anim.h index e858db4cd9e..82ac055b88d 100644 --- a/quantum/rgb_matrix_animations/solid_splash_anim.h +++ b/quantum/rgb_matrix_animations/solid_splash_anim.h @@ -1,5 +1,5 @@ #pragma once -#ifdef RGB_MATRIX_KEYPRESSES +#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED #if !defined(DISABLE_RGB_MATRIX_SOLID_SPLASH) || !defined(DISABLE_RGB_MATRIX_SOLID_MULTISPLASH) extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; @@ -39,4 +39,4 @@ bool rgb_matrix_solid_splash(effect_params_t* params) { } #endif // !defined(DISABLE_RGB_MATRIX_SPLASH) && !defined(DISABLE_RGB_MATRIX_MULTISPLASH) -#endif // RGB_MATRIX_KEYPRESSES +#endif // RGB_MATRIX_KEYREACTIVE_ENABLED diff --git a/quantum/rgb_matrix_animations/splash_anim.h b/quantum/rgb_matrix_animations/splash_anim.h index 783778fd85b..829d30eef51 100644 --- a/quantum/rgb_matrix_animations/splash_anim.h +++ b/quantum/rgb_matrix_animations/splash_anim.h @@ -1,5 +1,5 @@ #pragma once -#ifdef RGB_MATRIX_KEYPRESSES +#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED #if !defined(DISABLE_RGB_MATRIX_SPLASH) || !defined(DISABLE_RGB_MATRIX_MULTISPLASH) extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; @@ -41,4 +41,4 @@ bool rgb_matrix_splash(effect_params_t* params) { } #endif // !defined(DISABLE_RGB_MATRIX_SPLASH) || !defined(DISABLE_RGB_MATRIX_MULTISPLASH) -#endif // RGB_MATRIX_KEYPRESSES +#endif // RGB_MATRIX_KEYREACTIVE_ENABLED diff --git a/quantum/rgb_matrix_types.h b/quantum/rgb_matrix_types.h index ab98b89d7d2..540bac71969 100644 --- a/quantum/rgb_matrix_types.h +++ b/quantum/rgb_matrix_types.h @@ -18,7 +18,7 @@ #define LED_HITS_TO_REMEMBER 8 #endif // LED_HITS_TO_REMEMBER -#if defined(RGB_MATRIX_KEYPRESSES) || defined(RGB_MATRIX_KEYRELEASES) +#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED typedef struct PACKED { uint8_t count; uint8_t x[LED_HITS_TO_REMEMBER]; @@ -26,7 +26,7 @@ typedef struct PACKED { uint8_t index[LED_HITS_TO_REMEMBER]; uint16_t tick[LED_HITS_TO_REMEMBER]; } last_hit_t; -#endif // defined(RGB_MATRIX_KEYPRESSES) || defined(RGB_MATRIX_KEYRELEASES) +#endif // RGB_MATRIX_KEYREACTIVE_ENABLED typedef enum rgb_task_states { STARTING,