|
|
@ -26,12 +26,20 @@ namespace device {
|
|
|
|
namespace gd32 {
|
|
|
|
namespace gd32 {
|
|
|
|
namespace eval {
|
|
|
|
namespace eval {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static HardwareTimer timer;
|
|
|
|
|
|
|
|
|
|
|
|
KeyScanner::col_state_t KeyScanner::matrix_state_[KeyScannerProps::matrix_columns];
|
|
|
|
KeyScanner::col_state_t KeyScanner::matrix_state_[KeyScannerProps::matrix_columns];
|
|
|
|
|
|
|
|
bool KeyScanner::do_scan;
|
|
|
|
|
|
|
|
|
|
|
|
const uint8_t KeyScannerProps::matrix_rows;
|
|
|
|
const uint8_t KeyScannerProps::matrix_rows;
|
|
|
|
const uint8_t KeyScannerProps::matrix_columns;
|
|
|
|
const uint8_t KeyScannerProps::matrix_columns;
|
|
|
|
constexpr uint8_t KeyScannerProps::matrix_row_pins[matrix_rows];
|
|
|
|
constexpr uint8_t KeyScannerProps::matrix_row_pins[matrix_rows];
|
|
|
|
constexpr uint8_t KeyScannerProps::matrix_col_pins[matrix_columns];
|
|
|
|
constexpr uint8_t KeyScannerProps::matrix_col_pins[matrix_columns];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static scan_irq() {
|
|
|
|
|
|
|
|
KeyScanner::do_scan = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void KeyScanner::setup() {
|
|
|
|
void KeyScanner::setup() {
|
|
|
|
for (uint8_t i = 0; i < Props_::matrix_columns; i++) {
|
|
|
|
for (uint8_t i = 0; i < Props_::matrix_columns; i++) {
|
|
|
|
pinMode(Props_::matrix_row_pins[i], INPUT_PULLUP);
|
|
|
|
pinMode(Props_::matrix_row_pins[i], INPUT_PULLUP);
|
|
|
@ -40,10 +48,17 @@ void KeyScanner::setup() {
|
|
|
|
for (uint8_t i = 0; i < Props_::matrix_rows; i++) {
|
|
|
|
for (uint8_t i = 0; i < Props_::matrix_rows; i++) {
|
|
|
|
pinMode(Props_::matrix_row_pins[i], INPUT);
|
|
|
|
pinMode(Props_::matrix_row_pins[i], INPUT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
timer.setPeriodTime(5, FORMAT_MS);
|
|
|
|
|
|
|
|
timer.attachInterrupt(scan_irq);
|
|
|
|
|
|
|
|
timer.start();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void KeyScanner::scanMatrix() {
|
|
|
|
void KeyScanner::scanMatrix() {
|
|
|
|
|
|
|
|
if (do_scan) {
|
|
|
|
|
|
|
|
do_scan = false;
|
|
|
|
readMatrix();
|
|
|
|
readMatrix();
|
|
|
|
|
|
|
|
}
|
|
|
|
actOnMatrixScan();
|
|
|
|
actOnMatrixScan();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|