aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIBNobody <ibnobody@gmail.com>2016-10-23 23:00:43 -0500
committerIBNobody <ibnobody@gmail.com>2016-10-23 23:00:43 -0500
commit17170ba76d3c94edcf1ab263520238fdb0384774 (patch)
tree4b80ab5544e6f53464068210278f0405bd596c41
parent05ceef2350dbd72f696d70b8a2567d048fa147dc (diff)
downloadqmk_firmware-17170ba76d3c94edcf1ab263520238fdb0384774.tar.gz
qmk_firmware-17170ba76d3c94edcf1ab263520238fdb0384774.zip
Fixed some large keyboard bugs
Fixed some bugs relating to keyboards with more than 16 columns. Also added the ability to mask off keyboard matrix bits.
-rw-r--r--keyboards/vision_division/config.h2
-rw-r--r--keyboards/vision_division/keymaps/default/keymap.c11
-rw-r--r--quantum/matrix.c37
-rw-r--r--readme.md1
-rw-r--r--tmk_core/common/command.c6
5 files changed, 50 insertions, 7 deletions
diff --git a/keyboards/vision_division/config.h b/keyboards/vision_division/config.h
index 1f8466a54..93c960671 100644
--- a/keyboards/vision_division/config.h
+++ b/keyboards/vision_division/config.h
@@ -33,6 +33,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
33/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ 33/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */
34#define DEBOUNCING_DELAY 5 34#define DEBOUNCING_DELAY 5
35 35
36#define MATRIX_MASKED
37
36/* define if matrix has ghost (lacks anti-ghosting diodes) */ 38/* define if matrix has ghost (lacks anti-ghosting diodes) */
37//#define MATRIX_HAS_GHOST 39//#define MATRIX_HAS_GHOST
38 40
diff --git a/keyboards/vision_division/keymaps/default/keymap.c b/keyboards/vision_division/keymaps/default/keymap.c
index 8622ee521..3282761c0 100644
--- a/keyboards/vision_division/keymaps/default/keymap.c
+++ b/keyboards/vision_division/keymaps/default/keymap.c
@@ -142,6 +142,17 @@ enum keyboard_macros {
142#define ________________ _______, _______ 142#define ________________ _______, _______
143#define XXXXXXXXXXXXXXXX XXXXXXX, XXXXXXX 143#define XXXXXXXXXXXXXXXX XXXXXXX, XXXXXXX
144 144
145const matrix_row_t matrix_mask[MATRIX_ROWS] =
146{
147// 1098765432109876543210987654321
148 0b0000000001111111101111011111111,
149 0b0000000001111111111111111111111,
150 0b0000000001111111111111111111111,
151 0b0000000001111111111111111111111,
152 0b0000000001010111111111111111111,
153 0b0000000001111101111111101011111,
154};
155
145const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = 156const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] =
146{ 157{
147/* LAYER = LAYER_QWERTY 158/* LAYER = LAYER_QWERTY
diff --git a/quantum/matrix.c b/quantum/matrix.c
index 3174e0739..ac81794e5 100644
--- a/quantum/matrix.c
+++ b/quantum/matrix.c
@@ -26,6 +26,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
26#include "util.h" 26#include "util.h"
27#include "matrix.h" 27#include "matrix.h"
28 28
29#ifdef MATRIX_MASKED
30extern const matrix_row_t matrix_mask[];
31#endif
32
29/* Set 0 if debouncing isn't needed */ 33/* Set 0 if debouncing isn't needed */
30 34
31#ifndef DEBOUNCING_DELAY 35#ifndef DEBOUNCING_DELAY
@@ -218,15 +222,34 @@ bool matrix_is_on(uint8_t row, uint8_t col)
218inline 222inline
219matrix_row_t matrix_get_row(uint8_t row) 223matrix_row_t matrix_get_row(uint8_t row)
220{ 224{
225 // Matrix mask lets you disable switches in the returned matrix data. For example, if you have a
226 // switch blocker installed and the switch is always pressed.
227#ifdef MATRIX_MASKED
228 return matrix[row] & matrix_mask[row];
229#else
221 return matrix[row]; 230 return matrix[row];
231#endif
222} 232}
223 233
224void matrix_print(void) 234void matrix_print(void)
225{ 235{
236#if (MATRIX_COLS <= 8)
237 print("\nr/c 01234567\n");
238#elif (MATRIX_COLS <= 16)
226 print("\nr/c 0123456789ABCDEF\n"); 239 print("\nr/c 0123456789ABCDEF\n");
240#elif (MATRIX_COLS <= 32)
241 print("\nr/c 0123456789ABCDEF0123456789ABCDEF\n");
242#endif
243
227 for (uint8_t row = 0; row < MATRIX_ROWS; row++) { 244 for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
228 phex(row); print(": "); 245 phex(row); print(": ");
229 pbin_reverse16(matrix_get_row(row)); 246#if (MATRIX_COLS <= 8)
247 print_bin_reverse8(matrix_get_row(row));
248#elif (MATRIX_COLS <= 16)
249 print_bin_reverse16(matrix_get_row(row));
250#elif (MATRIX_COLS <= 32)
251 print_bin_reverse32(matrix_get_row(row));
252#endif
230 print("\n"); 253 print("\n");
231 } 254 }
232} 255}
@@ -235,7 +258,13 @@ uint8_t matrix_key_count(void)
235{ 258{
236 uint8_t count = 0; 259 uint8_t count = 0;
237 for (uint8_t i = 0; i < MATRIX_ROWS; i++) { 260 for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
261#if (MATRIX_COLS <= 8)
262 count += bitpop(matrix[i]);
263#elif (MATRIX_COLS <= 16)
238 count += bitpop16(matrix[i]); 264 count += bitpop16(matrix[i]);
265#elif (MATRIX_COLS <= 32)
266 count += bitpop32(matrix[i]);
267#endif
239 } 268 }
240 return count; 269 return count;
241} 270}
@@ -259,7 +288,7 @@ static matrix_row_t read_cols(void)
259 matrix_row_t result = 0; 288 matrix_row_t result = 0;
260 289
261#if DIODE_DIRECTION == COL2ROW 290#if DIODE_DIRECTION == COL2ROW
262 for(int x = 0; x < MATRIX_COLS; x++) { 291 for(int x = 0; x < MATRIX_COLS; x++) {
263 int pin = col_pins[x]; 292 int pin = col_pins[x];
264#else 293#else
265 for(int x = 0; x < MATRIX_ROWS; x++) { 294 for(int x = 0; x < MATRIX_ROWS; x++) {
@@ -273,10 +302,10 @@ static matrix_row_t read_cols(void)
273static void unselect_rows(void) 302static void unselect_rows(void)
274{ 303{
275#if DIODE_DIRECTION == COL2ROW 304#if DIODE_DIRECTION == COL2ROW
276 for(int x = 0; x < MATRIX_ROWS; x++) { 305 for(int x = 0; x < MATRIX_ROWS; x++) {
277 int pin = row_pins[x]; 306 int pin = row_pins[x];
278#else 307#else
279 for(int x = 0; x < MATRIX_COLS; x++) { 308 for(int x = 0; x < MATRIX_COLS; x++) {
280 int pin = col_pins[x]; 309 int pin = col_pins[x];
281#endif 310#endif
282 _SFR_IO8((pin >> 4) + 1) &= ~_BV(pin & 0xF); 311 _SFR_IO8((pin >> 4) + 1) &= ~_BV(pin & 0xF);
diff --git a/readme.md b/readme.md
index 62d479ff1..c460933a7 100644
--- a/readme.md
+++ b/readme.md
@@ -241,6 +241,7 @@ You can also add extra options at the end of the make command line, after the ta
241* `make COLOR=false` - turns off color output 241* `make COLOR=false` - turns off color output
242* `make SILENT=true` - turns off output besides errors/warnings 242* `make SILENT=true` - turns off output besides errors/warnings
243* `make VERBOSE=true` - outputs all of the gcc stuff (not interesting, unless you need to debug) 243* `make VERBOSE=true` - outputs all of the gcc stuff (not interesting, unless you need to debug)
244* `make EXTRAFLAGS=-E` - Preprocess the code without doing any compiling (useful if you are trying to debug #define commands)
244 245
245The make command itself also has some additional options, type `make --help` for more information. The most useful is probably `-jx`, which specifies that you want to compile using more than one CPU, the `x` represents the number of CPUs that you want to use. Setting that can greatly reduce the compile times, especially if you are compiling many keyboards/keymaps. I usually set it to one less than the number of CPUs that I have, so that I have some left for doing other things while it's compiling. Note that not all operating systems and make versions supports that option. 246The make command itself also has some additional options, type `make --help` for more information. The most useful is probably `-jx`, which specifies that you want to compile using more than one CPU, the `x` represents the number of CPUs that you want to use. Setting that can greatly reduce the compile times, especially if you are compiling many keyboards/keymaps. I usually set it to one less than the number of CPUs that I have, so that I have some left for doing other things while it's compiling. Note that not all operating systems and make versions supports that option.
246 247
diff --git a/tmk_core/common/command.c b/tmk_core/common/command.c
index f3e1bf623..5f29bc0b4 100644
--- a/tmk_core/common/command.c
+++ b/tmk_core/common/command.c
@@ -379,11 +379,11 @@ static bool command_common(uint8_t code)
379 debug_enable = !debug_enable; 379 debug_enable = !debug_enable;
380 if (debug_enable) { 380 if (debug_enable) {
381 print("\ndebug: on\n"); 381 print("\ndebug: on\n");
382 debug_matrix = true;
383 debug_keyboard = true;
384 debug_mouse = true;
385 } else { 382 } else {
386 print("\ndebug: off\n"); 383 print("\ndebug: off\n");
384 debug_matrix = false;
385 debug_keyboard = false;
386 debug_mouse = false;
387 } 387 }
388 break; 388 break;
389 389