From e783cb06f7f412f8c7fa9aa6acf800b34efb21f3 Mon Sep 17 00:00:00 2001 From: Chris Lewis Date: Sat, 28 Jul 2018 15:54:08 +1000 Subject: [PATCH] Re-arrange typing_speed definitions (Fixes #5) (#6) * Re-arrange variable definitions to avoid including quantum.h from rgblight.c * Fix a compilation error when trying to run make test:all --- quantum/quantum.c | 5 +++-- quantum/quantum.h | 3 --- quantum/rgblight.c | 7 +++---- quantum/rgblight.h | 4 ++++ 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/quantum/quantum.c b/quantum/quantum.c index 30a7beba403d..ff59bc0c41d7 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -187,14 +187,15 @@ static uint16_t scs_timer[2] = {0, 0}; */ static bool grave_esc_was_shifted = false; -uint8_t typing_speed = 0; bool process_record_quantum(keyrecord_t *record) { /* This gets the keycode from the key pressed */ keypos_t key = record->event.key; uint16_t keycode; - if (typing_speed < TYPING_SPEED_MAX_VALUE) typing_speed += 1; + #ifdef RGBLIGHT_ENABLE + if (typing_speed < TYPING_SPEED_MAX_VALUE) typing_speed += 1; + #endif #if !defined(NO_ACTION_LAYER) && defined(PREVENT_STUCK_MODIFIERS) /* TODO: Use store_or_get_action() or a similar function. */ diff --git a/quantum/quantum.h b/quantum/quantum.h index 1837caddbb84..0675a90ac3fa 100644 --- a/quantum/quantum.h +++ b/quantum/quantum.h @@ -55,9 +55,6 @@ #include "send_string_keycodes.h" extern uint32_t default_layer_state; -//Used in rgblight.c to match RGB animation to typing speed -extern uint8_t typing_speed; -#define TYPING_SPEED_MAX_VALUE 100 #ifndef NO_ACTION_LAYER extern uint32_t layer_state; diff --git a/quantum/rgblight.c b/quantum/rgblight.c index fda64855d1d3..88a21d0aff73 100644 --- a/quantum/rgblight.c +++ b/quantum/rgblight.c @@ -24,15 +24,13 @@ #include "rgblight.h" #include "debug.h" #include "led_tables.h" -#include "quantum.h" #ifndef RGBLIGHT_LIMIT_VAL #define RGBLIGHT_LIMIT_VAL 255 #endif -//These conflict with a chained include that comes from including quantum.h -// #define MIN(a,b) (((a)<(b))?(a):(b)) -// #define MAX(a,b) (((a)>(b))?(a):(b)) +#define MIN(a,b) (((a)<(b))?(a):(b)) +#define MAX(a,b) (((a)>(b))?(a):(b)) __attribute__ ((weak)) const uint8_t RGBLED_BREATHING_INTERVALS[] PROGMEM = {30, 20, 10, 5}; @@ -569,6 +567,7 @@ void rgblight_show_solid_color(uint8_t r, uint8_t g, uint8_t b) { rgblight_setrgb(r, g, b); } +uint8_t typing_speed = 0; void typing_speed_decay_task() { static uint16_t decay_timer = 0; diff --git a/quantum/rgblight.h b/quantum/rgblight.h index ecc1ff60589f..5b954312992f 100644 --- a/quantum/rgblight.h +++ b/quantum/rgblight.h @@ -89,6 +89,10 @@ extern const uint8_t RGBLED_SNAKE_INTERVALS[3] PROGMEM; extern const uint8_t RGBLED_KNIGHT_INTERVALS[3] PROGMEM; extern const uint16_t RGBLED_RGBTEST_INTERVALS[1] PROGMEM; +//Used in rgblight.c and quantum.c to match RGB animation to typing speed +extern uint8_t typing_speed; +#define TYPING_SPEED_MAX_VALUE 100 + typedef union { uint32_t raw; struct {