Replaced all occurences of ROWS*COLS with KeyboardHardware.numKeys()

Signed-off-by: Florian Fleissner <florian.fleissner@inpartik.de>
pull/640/head
Florian Fleissner 6 years ago committed by Jesse Vincent
parent 42afb7d2bd
commit 359ac67391

@ -111,7 +111,7 @@ void Layer_::updateLiveCompositeKeymap(byte row, byte col) {
} }
void Layer_::updateActiveLayers(void) { 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 row = 0; row < ROWS; row++) {
for (byte col = 0; col < COLS; col++) { for (byte col = 0; col < COLS; col++) {
int8_t layer = top_active_layer_; int8_t layer = top_active_layer_;

@ -56,10 +56,10 @@ EventHandlerResult EEPROMKeymapProgrammer::onKeyswitchEvent(Key &mapped_key, byt
if (state_ == WAIT_FOR_KEY) { if (state_ == WAIT_FOR_KEY) {
if (keyToggledOn(key_state)) { 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 (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(); nextState();
} }
return EventHandlerResult::EVENT_CONSUMED; return EventHandlerResult::EVENT_CONSUMED;

@ -44,7 +44,7 @@ void EEPROMKeymap::setup(uint8_t max) {
void EEPROMKeymap::max_layers(uint8_t max) { void EEPROMKeymap::max_layers(uint8_t max) {
max_layers_ = 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) { 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_) if (layer >= max_layers_)
return Key_NoKey; 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.flags = EEPROM.read(keymap_base_ + pos);
key.keyCode = EEPROM.read(keymap_base_ + pos + 1); key.keyCode = EEPROM.read(keymap_base_ + pos + 1);
@ -134,7 +134,7 @@ EventHandlerResult EEPROMKeymap::onFocusEvent(const char *command) {
} else { } else {
uint16_t i = 0; uint16_t i = 0;
while (!::Focus.isEOL() && (i < ROWS * COLS * max_layers_)) { while (!::Focus.isEOL() && (i < (uint16_t)KeyboardHardware.numKeys() * max_layers_)) {
Key k; Key k;
::Focus.read(k); ::Focus.read(k);

@ -98,7 +98,7 @@ EventHandlerResult FingerPainter::onFocusEvent(const char *command) {
return EventHandlerResult::OK; return EventHandlerResult::OK;
if (sub_command == CLEAR) { 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); EEPROM.update(color_base_ + i, 0);
} }
return EventHandlerResult::OK; return EventHandlerResult::OK;

@ -28,16 +28,16 @@ uint16_t LEDPaletteTheme::reserveThemes(uint8_t max_themes) {
if (!palette_base_) if (!palette_base_)
palette_base_ = ::EEPROMSettings.requestSlice(16 * sizeof(cRGB)); 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) { void LEDPaletteTheme::updateHandler(uint16_t theme_base, uint8_t theme) {
if (!Kaleidoscope.has_leds) if (!Kaleidoscope.has_leds)
return; 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); cRGB color = lookupColorAtPosition(map_base, pos);
::LEDControl.setCrgbAt(pos, color); ::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) if (!Kaleidoscope.has_leds)
return; 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); uint16_t pos = KeyboardHardware.getLedIndex(row, col);
cRGB color = lookupColorAtPosition(map_base, pos); cRGB color = lookupColorAtPosition(map_base, pos);
@ -151,7 +151,7 @@ EventHandlerResult LEDPaletteTheme::themeFocusEvent(const char *command,
if (strcmp_P(command, expected_command) != 0) if (strcmp_P(command, expected_command) != 0)
return EventHandlerResult::OK; return EventHandlerResult::OK;
uint16_t max_index = (max_themes * ROWS * COLS) / 2; uint16_t max_index = (max_themes * KeyboardHardware.numKeys()) / 2;
if (::Focus.isEOL()) { if (::Focus.isEOL()) {
for (uint16_t pos = 0; pos < max_index; pos++) { for (uint16_t pos = 0; pos < max_index; pos++) {

@ -31,7 +31,7 @@ uint16_t WavepoolEffect::idle_timeout = 5000; // 5 seconds
int16_t WavepoolEffect::ripple_hue = WavepoolEffect::rainbow_hue; // automatic hue int16_t WavepoolEffect::ripple_hue = WavepoolEffect::rainbow_hue; // automatic hue
// map native keyboard coordinates (16x4) into geometric space (14x5) // 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, 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, 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, 28, 29, 30, 31, 32, 33, 48, 61, 64, 49, 36, 37, 38, 39, 40, 41,

@ -66,7 +66,7 @@ class WavepoolEffect : public Plugin,
uint8_t frames_since_event_; uint8_t frames_since_event_;
int8_t surface_[2][WP_WID * WP_HGT]; int8_t surface_[2][WP_WID * WP_HGT];
uint8_t page_; 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); void raindrop(uint8_t x, uint8_t y, int8_t *page);
uint8_t wp_rand(); uint8_t wp_rand();

@ -24,8 +24,6 @@
// Maximum length of the pending queue // Maximum length of the pending queue
#define QUKEYS_QUEUE_MAX 8 #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 // Boolean values for storing qukey state
#define QUKEY_STATE_PRIMARY false #define QUKEY_STATE_PRIMARY false

Loading…
Cancel
Save