Skip to content

Commit

Permalink
Re-arrange typing_speed definitions (Fixes qmk#5) (qmk#6)
Browse files Browse the repository at this point in the history
* Re-arrange variable definitions to avoid including quantum.h from rgblight.c

* Fix a compilation error when trying to run make test:all
  • Loading branch information
chrislewisdev committed Aug 23, 2018
1 parent b266a92 commit e7fd2bc
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
5 changes: 3 additions & 2 deletions quantum/quantum.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,14 +190,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. */
Expand Down
3 changes: 0 additions & 3 deletions quantum/quantum.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@
#include "suspend.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;
Expand Down
7 changes: 3 additions & 4 deletions quantum/rgblight.c
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -570,6 +568,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;

Expand Down
4 changes: 4 additions & 0 deletions quantum/rgblight.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit e7fd2bc

Please sign in to comment.