hardware::ATMegaKeyboard: Abstract away the data declarations

Signed-off-by: Gergely Nagy <algernon@keyboard.io>
pull/461/head
Gergely Nagy 6 years ago
parent 2326663640
commit 1643829f9a
No known key found for this signature in database
GPG Key ID: AC1E90BAC433F68F

@ -23,6 +23,7 @@
namespace kaleidoscope { namespace kaleidoscope {
namespace hardware { namespace hardware {
bool ATMegaKeyboard::do_scan_;
uint8_t ATMegaKeyboard::debounce = 3; uint8_t ATMegaKeyboard::debounce = 3;
void ATMegaKeyboard::setup(void) { void ATMegaKeyboard::setup(void) {
@ -137,8 +138,6 @@ bool ATMegaKeyboard::isKeyMasked(byte row, byte col) {
return bitRead(KeyboardHardware.masks_[row], col); return bitRead(KeyboardHardware.masks_[row], col);
} }
bool ATMegaKeyboard::do_scan_;
uint16_t ATMegaKeyboard::readCols() { uint16_t ATMegaKeyboard::readCols() {
uint16_t results = 0x00 ; uint16_t results = 0x00 ;
for (uint8_t i = 0; i < KeyboardHardware.matrix_columns; i++) { for (uint8_t i = 0; i < KeyboardHardware.matrix_columns; i++) {

@ -49,6 +49,20 @@ struct cRGB {
static uint16_t masks_[matrix_rows]; \ static uint16_t masks_[matrix_rows]; \
static uint8_t debounce_matrix_[matrix_rows][matrix_columns]; static uint8_t debounce_matrix_[matrix_rows][matrix_columns];
#define ATMEGA_KEYBOARD_DATA(BOARD) \
const int8_t BOARD::matrix_rows; \
const int8_t BOARD::matrix_columns; \
constexpr uint8_t BOARD::matrix_row_pins[matrix_rows]; \
constexpr uint8_t BOARD::matrix_col_pins[matrix_columns]; \
uint16_t BOARD::previousKeyState_[matrix_rows]; \
uint16_t BOARD::keyState_[matrix_rows]; \
uint16_t BOARD::masks_[matrix_rows]; \
uint8_t BOARD::debounce_matrix_[matrix_rows][matrix_columns]; \
\
ISR(TIMER1_OVF_vect) { \
BOARD::do_scan_ = true; \
}
namespace kaleidoscope { namespace kaleidoscope {
namespace hardware { namespace hardware {
class ATMegaKeyboard { class ATMegaKeyboard {

@ -24,19 +24,9 @@ namespace kaleidoscope {
namespace hardware { namespace hardware {
namespace olkb { namespace olkb {
const int8_t Planck::matrix_rows; ATMEGA_KEYBOARD_DATA(Planck);
const int8_t Planck::matrix_columns;
constexpr uint8_t Planck::matrix_row_pins[matrix_rows];
constexpr uint8_t Planck::matrix_col_pins[matrix_columns];
constexpr int8_t Planck::led_count; constexpr int8_t Planck::led_count;
uint16_t Planck::previousKeyState_[matrix_rows];
uint16_t Planck::keyState_[matrix_rows];
uint16_t Planck::masks_[matrix_rows];
uint8_t Planck::debounce_matrix_[matrix_rows][matrix_columns];
ISR(TIMER1_OVF_vect) {
Planck::do_scan_ = true;
}
} }
} }
} }

@ -33,19 +33,8 @@ namespace kaleidoscope {
namespace hardware { namespace hardware {
namespace technomancy { namespace technomancy {
const int8_t Atreus::matrix_rows; ATMEGA_KEYBOARD_DATA(Atreus);
const int8_t Atreus::matrix_columns;
constexpr uint8_t Atreus::matrix_row_pins[matrix_rows];
constexpr uint8_t Atreus::matrix_col_pins[matrix_columns];
constexpr int8_t Atreus::led_count; constexpr int8_t Atreus::led_count;
uint16_t Atreus::previousKeyState_[matrix_rows];
uint16_t Atreus::keyState_[matrix_rows];
uint16_t Atreus::masks_[matrix_rows];
uint8_t Atreus::debounce_matrix_[matrix_rows][matrix_columns];
ISR(TIMER1_OVF_vect) {
Atreus::do_scan_ = true;
}
// Atreus-specific stuff // Atreus-specific stuff

Loading…
Cancel
Save