#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
#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
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");
}
}
{
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;
}
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++) {
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);
* `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.