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

@ -38,17 +38,31 @@ struct cRGB {
#define ROW_PIN_LIST(...) __VA_ARGS__
#define COL_PIN_LIST(...) __VA_ARGS__
#define ATMEGA_KEYBOARD_CONFIG( ROW_PINS_, COL_PINS_) \
#define ATMEGA_KEYBOARD_CONFIG(ROW_PINS_, COL_PINS_) \
static const int8_t matrix_rows = NUM_ARGS(ROW_PINS_); \
static const int8_t matrix_columns = NUM_ARGS(COL_PINS_); \
static constexpr uint8_t matrix_row_pins[matrix_rows] = ROW_PINS_ ; \
static constexpr uint8_t matrix_col_pins[matrix_columns] = COL_PINS_ ;\
static constexpr uint8_t matrix_row_pins[matrix_rows] = ROW_PINS_; \
static constexpr uint8_t matrix_col_pins[matrix_columns] = COL_PINS_; \
\
static uint16_t previousKeyState_[matrix_rows]; \
static uint16_t keyState_[matrix_rows]; \
static uint16_t masks_[matrix_rows]; \
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 hardware {
class ATMegaKeyboard {

@ -24,19 +24,9 @@ namespace kaleidoscope {
namespace hardware {
namespace olkb {
const int8_t Planck::matrix_rows;
const int8_t Planck::matrix_columns;
constexpr uint8_t Planck::matrix_row_pins[matrix_rows];
constexpr uint8_t Planck::matrix_col_pins[matrix_columns];
ATMEGA_KEYBOARD_DATA(Planck);
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 technomancy {
const int8_t Atreus::matrix_rows;
const int8_t Atreus::matrix_columns;
constexpr uint8_t Atreus::matrix_row_pins[matrix_rows];
constexpr uint8_t Atreus::matrix_col_pins[matrix_columns];
ATMEGA_KEYBOARD_DATA(Atreus);
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

Loading…
Cancel
Save