Merge pull request #860 from keyboardio/wip/reduce-macros

Remove a couple macros that didn't really reduce implementation complexity
pull/861/head
Gergely Nagy 5 years ago committed by GitHub
commit 25272629ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -111,7 +111,10 @@ class RaiseLEDDriver : public kaleidoscope::driver::led::Base<RaiseLEDDriverProp
}; };
struct RaiseKeyScannerProps : public kaleidoscope::driver::keyscanner::BaseProps { struct RaiseKeyScannerProps : public kaleidoscope::driver::keyscanner::BaseProps {
KEYSCANNER_PROPS(5, 16); static constexpr uint8_t matrix_rows = 5;
static constexpr uint8_t matrix_columns = 16;
typedef MatrixAddr<matrix_rows, matrix_columns> KeyAddr;
static constexpr uint8_t left_columns = 8; static constexpr uint8_t left_columns = 8;
static constexpr uint8_t right_columns = matrix_columns - left_columns; static constexpr uint8_t right_columns = matrix_columns - left_columns;
}; };

@ -48,7 +48,10 @@ namespace ez {
struct ErgoDoxProps : public kaleidoscope::device::ATmega32U4KeyboardProps { struct ErgoDoxProps : public kaleidoscope::device::ATmega32U4KeyboardProps {
struct KeyScannerProps : kaleidoscope::driver::keyscanner::BaseProps { struct KeyScannerProps : kaleidoscope::driver::keyscanner::BaseProps {
KEYSCANNER_PROPS(14, 6); static constexpr uint8_t matrix_rows = 14;
static constexpr uint8_t matrix_columns = 6;
typedef MatrixAddr<matrix_rows, matrix_columns> KeyAddr;
}; };
typedef kaleidoscope::driver::bootloader::avr::HalfKay Bootloader; typedef kaleidoscope::driver::bootloader::avr::HalfKay Bootloader;
static constexpr const char *short_name = "ErgoDox-EZ"; static constexpr const char *short_name = "ErgoDox-EZ";

@ -73,7 +73,9 @@ class Model01LEDDriver;
#endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD #endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD
struct Model01KeyScannerProps : public kaleidoscope::driver::keyscanner::BaseProps { struct Model01KeyScannerProps : public kaleidoscope::driver::keyscanner::BaseProps {
KEYSCANNER_PROPS(4, 16); static constexpr uint8_t matrix_rows = 4;
static constexpr uint8_t matrix_columns = 16;
typedef MatrixAddr<matrix_rows, matrix_columns> KeyAddr;
}; };
#ifndef KALEIDOSCOPE_VIRTUAL_BUILD #ifndef KALEIDOSCOPE_VIRTUAL_BUILD

@ -34,16 +34,22 @@
#ifndef KALEIDOSCOPE_VIRTUAL_BUILD #ifndef KALEIDOSCOPE_VIRTUAL_BUILD
#define ATMEGA_KEYSCANNER_PROPS(ROW_PINS_, COL_PINS_) \ #define ATMEGA_KEYSCANNER_PROPS(ROW_PINS_, COL_PINS_) \
KEYSCANNER_PROPS(NUM_ARGS(ROW_PINS_), NUM_ARGS(COL_PINS_)); \ static constexpr uint8_t matrix_rows = NUM_ARGS(ROW_PINS_); \
static constexpr uint8_t matrix_columns = NUM_ARGS(COL_PINS_); \
typedef MatrixAddr<matrix_rows, matrix_columns> KeyAddr; \
\
static constexpr uint8_t matrix_row_pins[matrix_rows] = ROW_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_col_pins[matrix_columns] = COL_PINS_;
#else // ifndef KALEIDOSCOPE_VIRTUAL_BUILD #else // ifndef KALEIDOSCOPE_VIRTUAL_BUILD
#define ATMEGA_KEYSCANNER_PROPS(ROW_PINS_, COL_PINS_) \ #define ATMEGA_KEYSCANNER_PROPS(ROW_PINS_, COL_PINS_) \
KEYSCANNER_PROPS(NUM_ARGS(ROW_PINS_), NUM_ARGS(COL_PINS_)); static constexpr uint8_t matrix_rows = NUM_ARGS(ROW_PINS_); \
static constexpr uint8_t matrix_columns = NUM_ARGS(COL_PINS_); \
typedef MatrixAddr<matrix_rows, matrix_columns> KeyAddr;
#endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD #endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD
#define ATMEGA_KEYSCANNER_BOILERPLATE \ #define ATMEGA_KEYSCANNER_BOILERPLATE \
KEYSCANNER_PROPS_BOILERPLATE(kaleidoscope::Device::KeyScannerProps); \ const uint8_t kaleidoscope::Device::KeyScannerProps::matrix_rows; \
const uint8_t kaleidoscope::Device::KeyScannerProps::matrix_columns; \
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<> \

@ -22,15 +22,6 @@
#include "kaleidoscope/key_defs.h" #include "kaleidoscope/key_defs.h"
#include "kaleidoscope/MatrixAddr.h" #include "kaleidoscope/MatrixAddr.h"
#define KEYSCANNER_PROPS(ROWS_, COLS_) \
static constexpr uint8_t matrix_rows = ROWS_; \
static constexpr uint8_t matrix_columns = COLS_; \
typedef MatrixAddr<matrix_rows, matrix_columns> KeyAddr;
#define KEYSCANNER_PROPS_BOILERPLATE(BOARD) \
const uint8_t BOARD::matrix_rows; \
const uint8_t BOARD::matrix_columns;
namespace kaleidoscope { namespace kaleidoscope {
namespace driver { namespace driver {
namespace keyscanner { namespace keyscanner {
@ -38,7 +29,6 @@ namespace keyscanner {
struct BaseProps { struct BaseProps {
static constexpr uint8_t matrix_rows = 0; static constexpr uint8_t matrix_rows = 0;
static constexpr uint8_t matrix_columns = 0; static constexpr uint8_t matrix_columns = 0;
typedef MatrixAddr<matrix_rows, matrix_columns> KeyAddr; typedef MatrixAddr<matrix_rows, matrix_columns> KeyAddr;
}; };

Loading…
Cancel
Save