Merge pull request #815 from keyboardio/atmega/un-interrupt-keyscanner

driver::keyscanner::ATmega: Revert scanning during the interrupt
pull/764/head
Jesse Vincent 5 years ago committed by GitHub
commit 9417e0bc31
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -47,16 +47,16 @@
constexpr uint8_t kaleidoscope::Device::KeyScannerProps::matrix_row_pins[matrix_rows]; \ constexpr uint8_t kaleidoscope::Device::KeyScannerProps::matrix_row_pins[matrix_rows]; \
constexpr uint8_t kaleidoscope::Device::KeyScannerProps::matrix_col_pins[matrix_columns]; \ constexpr uint8_t kaleidoscope::Device::KeyScannerProps::matrix_col_pins[matrix_columns]; \
template<> \ template<> \
volatile uint16_t kaleidoscope::Device::KeyScanner::previousKeyState_[kaleidoscope::Device::KeyScannerProps::matrix_rows] = {}; \ uint16_t kaleidoscope::Device::KeyScanner::previousKeyState_[kaleidoscope::Device::KeyScannerProps::matrix_rows] = {}; \
template<> \ template<> \
volatile uint16_t kaleidoscope::Device::KeyScanner::keyState_[kaleidoscope::Device::KeyScannerProps::matrix_rows] = {}; \ uint16_t kaleidoscope::Device::KeyScanner::keyState_[kaleidoscope::Device::KeyScannerProps::matrix_rows] = {}; \
template<> \ template<> \
uint16_t kaleidoscope::Device::KeyScanner::masks_[kaleidoscope::Device::KeyScannerProps::matrix_rows] = {}; \ uint16_t kaleidoscope::Device::KeyScanner::masks_[kaleidoscope::Device::KeyScannerProps::matrix_rows] = {}; \
template<> \ template<> \
uint8_t kaleidoscope::Device::KeyScanner::debounce_matrix_[kaleidoscope::Device::KeyScannerProps::matrix_rows][kaleidoscope::Device::KeyScannerProps::matrix_columns] = {}; \ uint8_t kaleidoscope::Device::KeyScanner::debounce_matrix_[kaleidoscope::Device::KeyScannerProps::matrix_rows][kaleidoscope::Device::KeyScannerProps::matrix_columns] = {}; \
\ \
ISR(TIMER1_OVF_vect) { \ ISR(TIMER1_OVF_vect) { \
Runtime.device().readMatrix(); \ Runtime.device().keyScanner().do_scan_ = true; \
} }
namespace kaleidoscope { namespace kaleidoscope {
@ -130,6 +130,10 @@ class ATmega: public kaleidoscope::driver::keyscanner::Base<_KeyScannerProps> {
} }
void scanMatrix() { void scanMatrix() {
if (do_scan_) {
do_scan_ = false;
readMatrix();
}
actOnMatrixScan(); actOnMatrixScan();
} }
@ -192,10 +196,12 @@ class ATmega: public kaleidoscope::driver::keyscanner::Base<_KeyScannerProps> {
key_addr.col()); key_addr.col());
} }
bool do_scan_;
private: private:
typedef _KeyScannerProps KeyScannerProps_; typedef _KeyScannerProps KeyScannerProps_;
static volatile uint16_t previousKeyState_[_KeyScannerProps::matrix_rows]; static uint16_t previousKeyState_[_KeyScannerProps::matrix_rows];
static volatile uint16_t keyState_[_KeyScannerProps::matrix_rows]; static uint16_t keyState_[_KeyScannerProps::matrix_rows];
static uint16_t masks_[_KeyScannerProps::matrix_rows]; static uint16_t masks_[_KeyScannerProps::matrix_rows];
static uint8_t debounce_matrix_[_KeyScannerProps::matrix_rows][_KeyScannerProps::matrix_columns]; static uint8_t debounce_matrix_[_KeyScannerProps::matrix_rows][_KeyScannerProps::matrix_columns];

Loading…
Cancel
Save