Introduce a helper macro to compute the keymap size

When one adds or removes a layer from a keymap, the keymap size has to
be adjusted in the call to `Keyboardio.setup()`. This is easy to forget,
so as a helper, introduce `KEYMAP_SIZE`, a macro that automatically
computes the size at compile time.

This way, one does not need to remember to update the size anywhere.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
pull/54/head
Gergely Nagy 8 years ago
parent 08acf2ef17
commit b7c9287d0f

@ -19,7 +19,6 @@
uint8_t primary_keymap = 0; uint8_t primary_keymap = 0;
uint8_t temporary_keymap = 0; uint8_t temporary_keymap = 0;
#define KEYMAPS 3
#define NUMPAD_KEYMAP 2 #define NUMPAD_KEYMAP 2
#define KEYMAP_LIST KEYMAP_QWERTY KEYMAP_GENERIC_FN2 KEYMAP_NUMPAD #define KEYMAP_LIST KEYMAP_QWERTY KEYMAP_GENERIC_FN2 KEYMAP_NUMPAD
@ -42,7 +41,7 @@ static LEDChaseEffect chaseEffect;
static LEDNumlock numLockEffect (NUMPAD_KEYMAP); static LEDNumlock numLockEffect (NUMPAD_KEYMAP);
void setup() { void setup() {
Keyboardio.setup(KEYMAPS); Keyboardio.setup(KEYMAP_SIZE);
bootAnimation(); bootAnimation();
} }

@ -33,6 +33,8 @@ extern uint8_t temporary_keymap;
#define VERSION "locally-built" #define VERSION "locally-built"
#endif #endif
#define KEYMAP_SIZE (sizeof(keymaps) / ROWS / COLS / sizeof(Key))
class Keyboardio_ { class Keyboardio_ {
public: public:
Keyboardio_(void); Keyboardio_(void);

Loading…
Cancel
Save