From 359ac67391ca01b4297ffea50ff9d564c0e11491 Mon Sep 17 00:00:00 2001 From: Florian Fleissner Date: Thu, 4 Apr 2019 12:37:39 +0200 Subject: [PATCH] Replaced all occurences of ROWS*COLS with KeyboardHardware.numKeys() Signed-off-by: Florian Fleissner --- src/kaleidoscope/layers.cpp | 2 +- src/kaleidoscope/plugin/EEPROM-Keymap-Programmer.cpp | 4 ++-- src/kaleidoscope/plugin/EEPROM-Keymap.cpp | 6 +++--- src/kaleidoscope/plugin/FingerPainter.cpp | 2 +- src/kaleidoscope/plugin/LED-Palette-Theme.cpp | 10 +++++----- src/kaleidoscope/plugin/LED-Wavepool.cpp | 2 +- src/kaleidoscope/plugin/LED-Wavepool.h | 2 +- src/kaleidoscope/plugin/Qukeys.h | 2 -- 8 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/kaleidoscope/layers.cpp b/src/kaleidoscope/layers.cpp index 99e59070..5a8e755f 100644 --- a/src/kaleidoscope/layers.cpp +++ b/src/kaleidoscope/layers.cpp @@ -111,7 +111,7 @@ void Layer_::updateLiveCompositeKeymap(byte row, byte col) { } void Layer_::updateActiveLayers(void) { - memset(active_layers_, 0, ROWS * COLS); + memset(active_layers_, 0, KeyboardHardware.numKeys()); for (byte row = 0; row < ROWS; row++) { for (byte col = 0; col < COLS; col++) { int8_t layer = top_active_layer_; diff --git a/src/kaleidoscope/plugin/EEPROM-Keymap-Programmer.cpp b/src/kaleidoscope/plugin/EEPROM-Keymap-Programmer.cpp index 956c6bb8..7540aa7f 100644 --- a/src/kaleidoscope/plugin/EEPROM-Keymap-Programmer.cpp +++ b/src/kaleidoscope/plugin/EEPROM-Keymap-Programmer.cpp @@ -56,10 +56,10 @@ EventHandlerResult EEPROMKeymapProgrammer::onKeyswitchEvent(Key &mapped_key, byt if (state_ == WAIT_FOR_KEY) { if (keyToggledOn(key_state)) { - update_position_ = Layer.top() * ROWS * COLS + row * COLS + col; + update_position_ = Layer.top() * KeyboardHardware.numKeys() + row * COLS + col; } if (keyToggledOff(key_state)) { - if ((uint16_t)(Layer.top() * ROWS * COLS + row * COLS + col) == update_position_) + if ((uint16_t)(Layer.top() * KeyboardHardware.numKeys() + row * COLS + col) == update_position_) nextState(); } return EventHandlerResult::EVENT_CONSUMED; diff --git a/src/kaleidoscope/plugin/EEPROM-Keymap.cpp b/src/kaleidoscope/plugin/EEPROM-Keymap.cpp index 5b2c2e5f..de3205ed 100644 --- a/src/kaleidoscope/plugin/EEPROM-Keymap.cpp +++ b/src/kaleidoscope/plugin/EEPROM-Keymap.cpp @@ -44,7 +44,7 @@ void EEPROMKeymap::setup(uint8_t max) { void EEPROMKeymap::max_layers(uint8_t max) { max_layers_ = max; - keymap_base_ = ::EEPROMSettings.requestSlice(max_layers_ * ROWS * COLS * 2); + keymap_base_ = ::EEPROMSettings.requestSlice(max_layers_ * KeyboardHardware.numKeys() * 2); } Key EEPROMKeymap::getKey(uint8_t layer, byte row, byte col) { @@ -53,7 +53,7 @@ Key EEPROMKeymap::getKey(uint8_t layer, byte row, byte col) { if (layer >= max_layers_) return Key_NoKey; - uint16_t pos = ((layer * ROWS * COLS) + (row * COLS) + col) * 2; + uint16_t pos = ((layer * KeyboardHardware.numKeys()) + (row * COLS) + col) * 2; key.flags = EEPROM.read(keymap_base_ + pos); key.keyCode = EEPROM.read(keymap_base_ + pos + 1); @@ -134,7 +134,7 @@ EventHandlerResult EEPROMKeymap::onFocusEvent(const char *command) { } else { uint16_t i = 0; - while (!::Focus.isEOL() && (i < ROWS * COLS * max_layers_)) { + while (!::Focus.isEOL() && (i < (uint16_t)KeyboardHardware.numKeys() * max_layers_)) { Key k; ::Focus.read(k); diff --git a/src/kaleidoscope/plugin/FingerPainter.cpp b/src/kaleidoscope/plugin/FingerPainter.cpp index 622d131d..bc83014e 100644 --- a/src/kaleidoscope/plugin/FingerPainter.cpp +++ b/src/kaleidoscope/plugin/FingerPainter.cpp @@ -98,7 +98,7 @@ EventHandlerResult FingerPainter::onFocusEvent(const char *command) { return EventHandlerResult::OK; if (sub_command == CLEAR) { - for (uint16_t i = 0; i < ROWS * COLS / 2; i++) { + for (uint16_t i = 0; i < KeyboardHardware.numKeys() / 2; i++) { EEPROM.update(color_base_ + i, 0); } return EventHandlerResult::OK; diff --git a/src/kaleidoscope/plugin/LED-Palette-Theme.cpp b/src/kaleidoscope/plugin/LED-Palette-Theme.cpp index 2a85fbb6..34c08d93 100644 --- a/src/kaleidoscope/plugin/LED-Palette-Theme.cpp +++ b/src/kaleidoscope/plugin/LED-Palette-Theme.cpp @@ -28,16 +28,16 @@ uint16_t LEDPaletteTheme::reserveThemes(uint8_t max_themes) { if (!palette_base_) palette_base_ = ::EEPROMSettings.requestSlice(16 * sizeof(cRGB)); - return ::EEPROMSettings.requestSlice(max_themes * ROWS * COLS / 2); + return ::EEPROMSettings.requestSlice(max_themes * KeyboardHardware.numKeys() / 2); } void LEDPaletteTheme::updateHandler(uint16_t theme_base, uint8_t theme) { if (!Kaleidoscope.has_leds) return; - uint16_t map_base = theme_base + (theme * ROWS * COLS / 2); + uint16_t map_base = theme_base + (theme * KeyboardHardware.numKeys() / 2); - for (uint16_t pos = 0; pos < ROWS * COLS; pos++) { + for (uint16_t pos = 0; pos < KeyboardHardware.numKeys(); pos++) { cRGB color = lookupColorAtPosition(map_base, pos); ::LEDControl.setCrgbAt(pos, color); } @@ -47,7 +47,7 @@ void LEDPaletteTheme::refreshAt(uint16_t theme_base, uint8_t theme, byte row, by if (!Kaleidoscope.has_leds) return; - uint16_t map_base = theme_base + (theme * ROWS * COLS / 2); + uint16_t map_base = theme_base + (theme * KeyboardHardware.numKeys() / 2); uint16_t pos = KeyboardHardware.getLedIndex(row, col); cRGB color = lookupColorAtPosition(map_base, pos); @@ -151,7 +151,7 @@ EventHandlerResult LEDPaletteTheme::themeFocusEvent(const char *command, if (strcmp_P(command, expected_command) != 0) return EventHandlerResult::OK; - uint16_t max_index = (max_themes * ROWS * COLS) / 2; + uint16_t max_index = (max_themes * KeyboardHardware.numKeys()) / 2; if (::Focus.isEOL()) { for (uint16_t pos = 0; pos < max_index; pos++) { diff --git a/src/kaleidoscope/plugin/LED-Wavepool.cpp b/src/kaleidoscope/plugin/LED-Wavepool.cpp index ed53d061..099b175f 100644 --- a/src/kaleidoscope/plugin/LED-Wavepool.cpp +++ b/src/kaleidoscope/plugin/LED-Wavepool.cpp @@ -31,7 +31,7 @@ uint16_t WavepoolEffect::idle_timeout = 5000; // 5 seconds int16_t WavepoolEffect::ripple_hue = WavepoolEffect::rainbow_hue; // automatic hue // map native keyboard coordinates (16x4) into geometric space (14x5) -PROGMEM const uint8_t WavepoolEffect::TransientLEDMode::rc2pos[ROWS * COLS] = { +PROGMEM const uint8_t WavepoolEffect::TransientLEDMode::rc2pos[KeyboardHardware.numKeys()] = { 0, 1, 2, 3, 4, 5, 6, 59, 66, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 34, 60, 65, 35, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 48, 61, 64, 49, 36, 37, 38, 39, 40, 41, diff --git a/src/kaleidoscope/plugin/LED-Wavepool.h b/src/kaleidoscope/plugin/LED-Wavepool.h index 0799f3d3..e5877171 100644 --- a/src/kaleidoscope/plugin/LED-Wavepool.h +++ b/src/kaleidoscope/plugin/LED-Wavepool.h @@ -66,7 +66,7 @@ class WavepoolEffect : public Plugin, uint8_t frames_since_event_; int8_t surface_[2][WP_WID * WP_HGT]; uint8_t page_; - static PROGMEM const uint8_t rc2pos[ROWS * COLS]; + static PROGMEM const uint8_t rc2pos[KeyboardHardware.numKeys()]; void raindrop(uint8_t x, uint8_t y, int8_t *page); uint8_t wp_rand(); diff --git a/src/kaleidoscope/plugin/Qukeys.h b/src/kaleidoscope/plugin/Qukeys.h index 7965db0c..e60e6b52 100644 --- a/src/kaleidoscope/plugin/Qukeys.h +++ b/src/kaleidoscope/plugin/Qukeys.h @@ -24,8 +24,6 @@ // Maximum length of the pending queue #define QUKEYS_QUEUE_MAX 8 -// Total number of keys on the keyboard (assuming full grid) -#define TOTAL_KEYS ROWS * COLS // Boolean values for storing qukey state #define QUKEY_STATE_PRIMARY false