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.
example_keyboards
IBNobody 8 years ago
parent 05ceef2350
commit 17170ba76d

@ -33,6 +33,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */
#define DEBOUNCING_DELAY 5
#define MATRIX_MASKED
/* define if matrix has ghost (lacks anti-ghosting diodes) */
//#define MATRIX_HAS_GHOST

@ -142,6 +142,17 @@ enum keyboard_macros {
#define ________________ _______, _______
#define XXXXXXXXXXXXXXXX XXXXXXX, XXXXXXX
const matrix_row_t matrix_mask[MATRIX_ROWS] =
{
// 1098765432109876543210987654321
0b0000000001111111101111011111111,
0b0000000001111111111111111111111,
0b0000000001111111111111111111111,
0b0000000001111111111111111111111,
0b0000000001010111111111111111111,
0b0000000001111101111111101011111,
};
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] =
{
/* LAYER = LAYER_QWERTY

@ -26,6 +26,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "util.h"
#include "matrix.h"
#ifdef MATRIX_MASKED
extern const matrix_row_t matrix_mask[];
#endif
/* Set 0 if debouncing isn't needed */
#ifndef DEBOUNCING_DELAY
@ -218,15 +222,34 @@ bool matrix_is_on(uint8_t row, uint8_t col)
inline
matrix_row_t matrix_get_row(uint8_t row)
{
// Matrix mask lets you disable switches in the returned matrix data. For example, if you have a
// switch blocker installed and the switch is always pressed.
#ifdef MATRIX_MASKED
return matrix[row] & matrix_mask[row];
#else
return matrix[row];
#endif
}
void matrix_print(void)
{
#if (MATRIX_COLS <= 8)
print("\nr/c 01234567\n");
#elif (MATRIX_COLS <= 16)
print("\nr/c 0123456789ABCDEF\n");
#elif (MATRIX_COLS <= 32)
print("\nr/c 0123456789ABCDEF0123456789ABCDEF\n");
#endif
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
phex(row); print(": ");
pbin_reverse16(matrix_get_row(row));
#if (MATRIX_COLS <= 8)
print_bin_reverse8(matrix_get_row(row));
#elif (MATRIX_COLS <= 16)
print_bin_reverse16(matrix_get_row(row));
#elif (MATRIX_COLS <= 32)
print_bin_reverse32(matrix_get_row(row));
#endif
print("\n");
}
}
@ -235,7 +258,13 @@ uint8_t matrix_key_count(void)
{
uint8_t count = 0;
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
#if (MATRIX_COLS <= 8)
count += bitpop(matrix[i]);
#elif (MATRIX_COLS <= 16)
count += bitpop16(matrix[i]);
#elif (MATRIX_COLS <= 32)
count += bitpop32(matrix[i]);
#endif
}
return count;
}
@ -259,7 +288,7 @@ static matrix_row_t read_cols(void)
matrix_row_t result = 0;
#if DIODE_DIRECTION == COL2ROW
for(int x = 0; x < MATRIX_COLS; x++) {
for(int x = 0; x < MATRIX_COLS; x++) {
int pin = col_pins[x];
#else
for(int x = 0; x < MATRIX_ROWS; x++) {
@ -273,10 +302,10 @@ static matrix_row_t read_cols(void)
static void unselect_rows(void)
{
#if DIODE_DIRECTION == COL2ROW
for(int x = 0; x < MATRIX_ROWS; x++) {
for(int x = 0; x < MATRIX_ROWS; x++) {
int pin = row_pins[x];
#else
for(int x = 0; x < MATRIX_COLS; x++) {
for(int x = 0; x < MATRIX_COLS; x++) {
int pin = col_pins[x];
#endif
_SFR_IO8((pin >> 4) + 1) &= ~_BV(pin & 0xF);

@ -241,6 +241,7 @@ You can also add extra options at the end of the make command line, after the ta
* `make COLOR=false` - turns off color output
* `make SILENT=true` - turns off output besides errors/warnings
* `make VERBOSE=true` - outputs all of the gcc stuff (not interesting, unless you need to debug)
* `make EXTRAFLAGS=-E` - Preprocess the code without doing any compiling (useful if you are trying to debug #define commands)
The 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.

@ -379,11 +379,11 @@ static bool command_common(uint8_t code)
debug_enable = !debug_enable;
if (debug_enable) {
print("\ndebug: on\n");
debug_matrix = true;
debug_keyboard = true;
debug_mouse = true;
} else {
print("\ndebug: off\n");
debug_matrix = false;
debug_keyboard = false;
debug_mouse = false;
}
break;

Loading…
Cancel
Save