|
|
@ -33,8 +33,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
|
|
#include "config.h" |
|
|
|
#include "config.h" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef DEBOUNCING_DELAY |
|
|
|
#ifndef DEBOUNCE |
|
|
|
# define DEBOUNCING_DELAY 5 |
|
|
|
# define DEBOUNCE 5 |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
#define print_matrix_header() print("\nr/c 01234567\n") |
|
|
|
#define print_matrix_header() print("\nr/c 01234567\n") |
|
|
@ -49,14 +49,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
|
|
static const uint8_t row_pins [NUM_ROW_PINS] = MATRIX_ROW_PINS ; |
|
|
|
static const uint8_t row_pins [NUM_ROW_PINS] = MATRIX_ROW_PINS ; |
|
|
|
static const uint8_t col_pins [NUM_ROW_PINS] = MATRIX_COL_PINS ; |
|
|
|
static const uint8_t col_pins [NUM_ROW_PINS] = MATRIX_COL_PINS ; |
|
|
|
|
|
|
|
|
|
|
|
#if ( DEBOUNCING_DELAY > 0 ) |
|
|
|
#if ( DEBOUNCE > 0 ) |
|
|
|
static uint16_t debouncing_time ; |
|
|
|
static uint16_t debouncing_time ; |
|
|
|
static bool debouncing = false ; |
|
|
|
static bool debouncing = false ; |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
static uint8_t matrix [MATRIX_ROWS] = {0}; |
|
|
|
static uint8_t matrix [MATRIX_ROWS] = {0}; |
|
|
|
|
|
|
|
|
|
|
|
#if ( DEBOUNCING_DELAY > 0 ) |
|
|
|
#if ( DEBOUNCE > 0 ) |
|
|
|
static uint8_t matrix_debounce [MATRIX_ROWS] = {0}; |
|
|
|
static uint8_t matrix_debounce [MATRIX_ROWS] = {0}; |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
@ -237,7 +237,7 @@ void matrix_init(void) { |
|
|
|
// initialize matrix state: all keys off
|
|
|
|
// initialize matrix state: all keys off
|
|
|
|
for (uint8_t i = 0; i < MATRIX_ROWS; i++) { |
|
|
|
for (uint8_t i = 0; i < MATRIX_ROWS; i++) { |
|
|
|
matrix[i] = 0; |
|
|
|
matrix[i] = 0; |
|
|
|
# if (DEBOUNCING_DELAY > 0) |
|
|
|
# if (DEBOUNCE > 0) |
|
|
|
matrix_debounce [i] = 0; |
|
|
|
matrix_debounce [i] = 0; |
|
|
|
# endif |
|
|
|
# endif |
|
|
|
} |
|
|
|
} |
|
|
@ -247,7 +247,7 @@ void matrix_init(void) { |
|
|
|
|
|
|
|
|
|
|
|
uint8_t matrix_scan(void) {
|
|
|
|
uint8_t matrix_scan(void) {
|
|
|
|
for ( uint8_t current_row = 0; current_row < MATRIX_ROWS; ++current_row ) { |
|
|
|
for ( uint8_t current_row = 0; current_row < MATRIX_ROWS; ++current_row ) { |
|
|
|
# if (DEBOUNCING_DELAY > 0) |
|
|
|
# if (DEBOUNCE > 0) |
|
|
|
bool matrix_changed = matrix_read(matrix_debounce, current_row); |
|
|
|
bool matrix_changed = matrix_read(matrix_debounce, current_row); |
|
|
|
|
|
|
|
|
|
|
|
if (matrix_changed) { |
|
|
|
if (matrix_changed) { |
|
|
@ -260,8 +260,8 @@ uint8_t matrix_scan(void) { |
|
|
|
# endif |
|
|
|
# endif |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
# if (DEBOUNCING_DELAY > 0) |
|
|
|
# if (DEBOUNCE > 0) |
|
|
|
if (debouncing && (timer_elapsed(debouncing_time) > DEBOUNCING_DELAY)) { |
|
|
|
if (debouncing && (timer_elapsed(debouncing_time) > DEBOUNCE)) { |
|
|
|
for (uint8_t i = 0; i < MATRIX_ROWS; i++) { |
|
|
|
for (uint8_t i = 0; i < MATRIX_ROWS; i++) { |
|
|
|
matrix[i] = matrix_debounce[i]; |
|
|
|
matrix[i] = matrix_debounce[i]; |
|
|
|
} |
|
|
|
} |
|
|
|