Skip to content

Commit 51a682b

Browse files
authored
Merge branch 'master' into feature/ws2812_matrix
2 parents 7f3d1b6 + 09d1ff9 commit 51a682b

File tree

5 files changed

+82
-98
lines changed

5 files changed

+82
-98
lines changed

changelog.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1-
04-12-2019 - Add AltGr/RALT support to Send String #4046
2-
04-12-2019 - Port DIRECT_PINS from split_common/matrix.c to matrix.c (qmk#5091)
3-
04-16-2019 - Add support for WS2812 based RGB Matrix
1+
04-12-2019 - Add AltGr/RALT support to Send String (qmk#4046)
2+
04-12-2019 - Port DIRECT_PINS from split_common/matrix.c to matrix.c (qmk#5091)
3+
04-12-2019 - Enhancement for Eager debouncing (and Ergodox EZ host sleep fix) (qmk#5621)
4+
04-16-2019 - Fix logic for Combo feature (qmk#5610)
5+
04-16-2019 - Fix info.json for Ergodox EZ
6+
04-16-2019 - Add support for WS2812 based RGB Matrix

keyboards/ergodox_ez/info.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
"keyboard_name": "ErgoDox EZ",
33
"url": "ergodox-ez.com",
44
"maintainer": "erez",
5-
"width": 19.5,
6-
"height": 9.375,
5+
"width": 17,
6+
"height": 8,
77

88
"layouts": {
99
"LAYOUT_ergodox": {

quantum/debounce/eager_pk.c

+38-51
Original file line numberDiff line numberDiff line change
@@ -24,63 +24,61 @@ No further inputs are accepted until DEBOUNCE milliseconds have occurred.
2424
#include <stdlib.h>
2525

2626
#ifndef DEBOUNCE
27-
#define DEBOUNCE 5
27+
# define DEBOUNCE 5
2828
#endif
2929

30-
3130
#if (MATRIX_COLS <= 8)
32-
# define ROW_SHIFTER ((uint8_t)1)
31+
# define ROW_SHIFTER ((uint8_t)1)
3332
#elif (MATRIX_COLS <= 16)
34-
# define ROW_SHIFTER ((uint16_t)1)
33+
# define ROW_SHIFTER ((uint16_t)1)
3534
#elif (MATRIX_COLS <= 32)
36-
# define ROW_SHIFTER ((uint32_t)1)
35+
# define ROW_SHIFTER ((uint32_t)1)
3736
#endif
3837

39-
40-
4138
#define debounce_counter_t uint8_t
4239

4340
static debounce_counter_t *debounce_counters;
41+
static bool counters_need_update;
4442

4543
#define DEBOUNCE_ELAPSED 251
4644
#define MAX_DEBOUNCE (DEBOUNCE_ELAPSED - 1)
4745

4846
void update_debounce_counters(uint8_t num_rows, uint8_t current_time);
4947
void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, uint8_t current_time);
5048

51-
//we use num_rows rather than MATRIX_ROWS to support split keyboards
52-
void debounce_init(uint8_t num_rows)
53-
{
54-
debounce_counters = (debounce_counter_t*)malloc(num_rows*MATRIX_COLS * sizeof(debounce_counter_t));
55-
int i = 0;
56-
for (uint8_t r = 0; r < num_rows; r++)
57-
{
58-
for (uint8_t c = 0; c < MATRIX_COLS; c++)
59-
{
49+
// we use num_rows rather than MATRIX_ROWS to support split keyboards
50+
void debounce_init(uint8_t num_rows) {
51+
debounce_counters = (debounce_counter_t *)malloc(num_rows * MATRIX_COLS * sizeof(debounce_counter_t));
52+
int i = 0;
53+
for (uint8_t r = 0; r < num_rows; r++) {
54+
for (uint8_t c = 0; c < MATRIX_COLS; c++) {
6055
debounce_counters[i++] = DEBOUNCE_ELAPSED;
6156
}
6257
}
6358
}
6459

65-
void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed)
66-
{
60+
void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed) {
6761
uint8_t current_time = timer_read() % MAX_DEBOUNCE;
68-
update_debounce_counters(num_rows, current_time);
69-
transfer_matrix_values(raw, cooked, num_rows, current_time);
62+
if (counters_need_update) {
63+
update_debounce_counters(num_rows, current_time);
64+
}
65+
66+
if (changed) {
67+
transfer_matrix_values(raw, cooked, num_rows, current_time);
68+
}
7069
}
7170

72-
//If the current time is > debounce counter, set the counter to enable input.
73-
void update_debounce_counters(uint8_t num_rows, uint8_t current_time)
74-
{
71+
// If the current time is > debounce counter, set the counter to enable input.
72+
void update_debounce_counters(uint8_t num_rows, uint8_t current_time) {
73+
counters_need_update = false;
7574
debounce_counter_t *debounce_pointer = debounce_counters;
76-
for (uint8_t row = 0; row < num_rows; row++)
77-
{
78-
for (uint8_t col = 0; col < MATRIX_COLS; col++)
79-
{
80-
if (*debounce_pointer != DEBOUNCE_ELAPSED)
81-
{
75+
for (uint8_t row = 0; row < num_rows; row++) {
76+
for (uint8_t col = 0; col < MATRIX_COLS; col++) {
77+
if (*debounce_pointer != DEBOUNCE_ELAPSED) {
8278
if (TIMER_DIFF(current_time, *debounce_pointer, MAX_DEBOUNCE) >= DEBOUNCE) {
8379
*debounce_pointer = DEBOUNCE_ELAPSED;
80+
} else {
81+
counters_need_update = true;
8482
}
8583
}
8684
debounce_pointer++;
@@ -89,33 +87,22 @@ void update_debounce_counters(uint8_t num_rows, uint8_t current_time)
8987
}
9088

9189
// upload from raw_matrix to final matrix;
92-
void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, uint8_t current_time)
93-
{
90+
void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, uint8_t current_time) {
9491
debounce_counter_t *debounce_pointer = debounce_counters;
95-
for (uint8_t row = 0; row < num_rows; row++)
96-
{
97-
matrix_row_t existing_row = cooked[row];
98-
matrix_row_t raw_row = raw[row];
99-
100-
for (uint8_t col = 0; col < MATRIX_COLS; col++)
101-
{
92+
for (uint8_t row = 0; row < num_rows; row++) {
93+
matrix_row_t delta = raw[row] ^ cooked[row];
94+
matrix_row_t existing_row = cooked[row];
95+
for (uint8_t col = 0; col < MATRIX_COLS; col++) {
10296
matrix_row_t col_mask = (ROW_SHIFTER << col);
103-
bool final_value = raw_row & col_mask;
104-
bool existing_value = existing_row & col_mask;
105-
if (*debounce_pointer == DEBOUNCE_ELAPSED &&
106-
(existing_value != final_value))
107-
{
108-
*debounce_pointer = current_time;
109-
existing_row ^= col_mask; //flip the bit.
97+
if ((delta & col_mask) && *debounce_pointer == DEBOUNCE_ELAPSED) {
98+
*debounce_pointer = current_time;
99+
counters_need_update = true;
100+
existing_row ^= col_mask; // flip the bit.
110101
}
111102
debounce_pointer++;
112103
}
113104
cooked[row] = existing_row;
114-
}
115-
}
116-
117-
bool debounce_active(void)
118-
{
119-
return true;
105+
}
120106
}
121107

108+
bool debounce_active(void) { return true; }

quantum/debounce/eager_pr.c

+34-40
Original file line numberDiff line numberDiff line change
@@ -24,77 +24,71 @@ No further inputs are accepted until DEBOUNCE milliseconds have occurred.
2424
#include <stdlib.h>
2525

2626
#ifndef DEBOUNCE
27-
#define DEBOUNCE 5
27+
# define DEBOUNCE 5
2828
#endif
2929

30-
3130
#define debounce_counter_t uint8_t
3231

3332
static debounce_counter_t *debounce_counters;
33+
static bool counters_need_update;
3434

3535
#define DEBOUNCE_ELAPSED 251
3636
#define MAX_DEBOUNCE (DEBOUNCE_ELAPSED - 1)
3737

3838
void update_debounce_counters(uint8_t num_rows, uint8_t current_time);
3939
void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, uint8_t current_time);
4040

41-
//we use num_rows rather than MATRIX_ROWS to support split keyboards
42-
void debounce_init(uint8_t num_rows)
43-
{
44-
debounce_counters = (debounce_counter_t*)malloc(num_rows*sizeof(debounce_counter_t));
45-
for (uint8_t r = 0; r < num_rows; r++)
46-
{
41+
// we use num_rows rather than MATRIX_ROWS to support split keyboards
42+
void debounce_init(uint8_t num_rows) {
43+
debounce_counters = (debounce_counter_t *)malloc(num_rows * sizeof(debounce_counter_t));
44+
for (uint8_t r = 0; r < num_rows; r++) {
4745
debounce_counters[r] = DEBOUNCE_ELAPSED;
4846
}
4947
}
5048

51-
void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed)
52-
{
49+
void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed) {
5350
uint8_t current_time = timer_read() % MAX_DEBOUNCE;
54-
update_debounce_counters(num_rows, current_time);
55-
transfer_matrix_values(raw, cooked, num_rows, current_time);
51+
if (counters_need_update) {
52+
update_debounce_counters(num_rows, current_time);
53+
}
54+
55+
if (changed) {
56+
transfer_matrix_values(raw, cooked, num_rows, current_time);
57+
}
5658
}
5759

58-
//If the current time is > debounce counter, set the counter to enable input.
59-
void update_debounce_counters(uint8_t num_rows, uint8_t current_time)
60-
{
60+
// If the current time is > debounce counter, set the counter to enable input.
61+
void update_debounce_counters(uint8_t num_rows, uint8_t current_time) {
62+
counters_need_update = false;
6163
debounce_counter_t *debounce_pointer = debounce_counters;
62-
for (uint8_t row = 0; row < num_rows; row++)
63-
{
64-
if (*debounce_pointer != DEBOUNCE_ELAPSED)
65-
{
64+
for (uint8_t row = 0; row < num_rows; row++) {
65+
if (*debounce_pointer != DEBOUNCE_ELAPSED) {
6666
if (TIMER_DIFF(current_time, *debounce_pointer, MAX_DEBOUNCE) >= DEBOUNCE) {
6767
*debounce_pointer = DEBOUNCE_ELAPSED;
68+
} else {
69+
counters_need_update = true;
6870
}
6971
}
7072
debounce_pointer++;
7173
}
7274
}
7375

7476
// upload from raw_matrix to final matrix;
75-
void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, uint8_t current_time)
76-
{
77+
void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, uint8_t current_time) {
7778
debounce_counter_t *debounce_pointer = debounce_counters;
78-
for (uint8_t row = 0; row < num_rows; row++)
79-
{
80-
matrix_row_t existing_row = cooked[row];
81-
matrix_row_t raw_row = raw[row];
82-
83-
//determine new value basd on debounce pointer + raw value
84-
if (*debounce_pointer == DEBOUNCE_ELAPSED &&
85-
(existing_row != raw_row))
86-
{
87-
*debounce_pointer = current_time;
88-
existing_row = raw_row;
79+
for (uint8_t row = 0; row < num_rows; row++) {
80+
matrix_row_t existing_row = cooked[row];
81+
matrix_row_t raw_row = raw[row];
82+
83+
// determine new value basd on debounce pointer + raw value
84+
if (*debounce_pointer == DEBOUNCE_ELAPSED && (existing_row != raw_row)) {
85+
*debounce_pointer = current_time;
86+
cooked[row] = raw_row;
87+
counters_need_update = true;
8988
}
90-
cooked[row] = existing_row;
91-
92-
debounce_pointer++;
93-
}
94-
}
9589

96-
bool debounce_active(void)
97-
{
98-
return true;
90+
debounce_pointer++;
91+
}
9992
}
10093

94+
bool debounce_active(void) { return true; }

quantum/process_keycode/process_combo.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,13 @@ static bool process_single_combo(combo_t *combo, uint16_t keycode,
126126
bool process_combo(uint16_t keycode, keyrecord_t *record) {
127127
bool is_combo_key = false;
128128
drop_buffer = false;
129-
bool no_combo_keys_pressed = false;
129+
bool no_combo_keys_pressed = true;
130130

131131
for (current_combo_index = 0; current_combo_index < COMBO_COUNT;
132132
++current_combo_index) {
133133
combo_t *combo = &key_combos[current_combo_index];
134134
is_combo_key |= process_single_combo(combo, keycode, record);
135-
no_combo_keys_pressed |= NO_COMBO_KEYS_ARE_DOWN;
135+
no_combo_keys_pressed = no_combo_keys_pressed && NO_COMBO_KEYS_ARE_DOWN;
136136
}
137137

138138
if (drop_buffer) {

0 commit comments

Comments
 (0)