diff --git a/src/kaleidoscope/device/dygma/Defy.cpp b/src/kaleidoscope/device/dygma/Defy.cpp deleted file mode 100644 index 5e047a1..0000000 --- a/src/kaleidoscope/device/dygma/Defy.cpp +++ /dev/null @@ -1,570 +0,0 @@ -/* -*- mode: c++ -*- - * kaleidoscope::device::dygma::Defy -- Kaleidoscope device plugin for Dygma Defy - * Copyright (C) 2017-2020 Keyboard.io, Inc - * Copyright (C) 2017-2020 Dygma Lab S.L. - * - * This program is free software: you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software - * Foundation, version 3. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License along with - * this program. If not, see . - */ - -#ifdef ARDUINO_NRF5_DEFY - -#include "kaleidoscope/Runtime.h" -#include -#include -#include -#include - -#include "kaleidoscope/util/crc16.h" -#include "kaleidoscope/driver/color/GammaCorrection.h" -#include "kaleidoscope/driver/keyscanner/Base_Impl.h" - -#define I2C_CLOCK_KHZ 200 -#define I2C_FLASH_CLOCK_KHZ 100 // flashing doesn't work reliably at higher clock speeds - -#define SIDE_POWER 1 // side power switch pa10 - -#define LAYOUT_ISO 0 -#define LAYOUT_ANSI 1 - -namespace kaleidoscope { -namespace device { -namespace dygma { - -/********* DefyHands *********/ - -struct DefyHands { - static Defy::Hand leftHand; - static Defy::Hand rightHand; - - static void setup(); - static void initializeSides(); - - static uint8_t layout; - - static void setSidePower(bool power); - static bool getSidePower() { return side_power_; } - - static void keyscanInterval(uint16_t interval); - static uint16_t keyscanInterval() { return keyscan_interval_; } - - static String getChipID(); - - static void ledBrightnessCorrection(uint8_t brightness); - static uint8_t ledBrightnessCorrection() { - return led_brightness_correction_; - } - - private: - static uint16_t keyscan_interval_; - static uint8_t led_brightness_correction_; - static bool side_power_; - static uint16_t settings_base_; - static uint16_t settings_brightness_; - static constexpr uint8_t iso_only_led_ = 19; -}; - -Defy::Hand DefyHands::leftHand(0); -Defy::Hand DefyHands::rightHand(1); -uint8_t DefyHands::layout; -bool DefyHands::side_power_; -uint16_t DefyHands::settings_base_; -uint16_t DefyHands::settings_brightness_; -uint8_t DefyHands::led_brightness_correction_ = 255; -uint16_t DefyHands::keyscan_interval_ = 50; - -void DefyHands::setSidePower(bool power) { - digitalWrite(SIDE_POWER, power ? HIGH : LOW); - side_power_ = power; -} - -void DefyHands::setup() { - settings_base_ = ::EEPROMSettings.requestSlice(sizeof(keyscan_interval_)); - settings_brightness_ = - ::EEPROMSettings.requestSlice(sizeof(led_brightness_correction_)); - - // If keyscan is max, assume that EEPROM is uninitialized, and store the - // defaults. - uint16_t interval; - Runtime.storage().get(settings_base_, interval); - if (interval == 0xffff) { - Runtime.storage().put(settings_base_, keyscan_interval_); - Runtime.storage().commit(); - } - Runtime.storage().get(settings_base_, keyscan_interval_); - - uint8_t brightness; - Runtime.storage().get(settings_brightness_, brightness); - if (brightness == 0xff) { - Runtime.storage().put(settings_brightness_, led_brightness_correction_); - Runtime.storage().commit(); - } - Runtime.storage().get(settings_brightness_, led_brightness_correction_); -} - -void DefyHands::keyscanInterval(uint16_t interval) { - leftHand.setKeyscanInterval(interval); - rightHand.setKeyscanInterval(interval); - keyscan_interval_ = interval; - Runtime.storage().put(settings_base_, keyscan_interval_); - Runtime.storage().commit(); -} - -void DefyHands::ledBrightnessCorrection(uint8_t brightness) { - leftHand.setBrightness(brightness); - rightHand.setBrightness(brightness); - led_brightness_correction_ = brightness; - Runtime.storage().put(settings_brightness_, led_brightness_correction_); - Runtime.storage().commit(); -} - -String DefyHands::getChipID() { - uint32_t pdwUniqueID[4]; - pdwUniqueID[0] = *(volatile uint32_t*)(0x0080A00C); - pdwUniqueID[1] = *(volatile uint32_t*)(0x0080A040); - pdwUniqueID[2] = *(volatile uint32_t*)(0x0080A044); - pdwUniqueID[3] = *(volatile uint32_t*)(0x0080A048); - char buf[33]; - snprintf(buf, sizeof(buf), "%8x%8x%8x%8x", - pdwUniqueID[0], pdwUniqueID[1], pdwUniqueID[2], pdwUniqueID[3]); - return String(buf); -} - -void DefyHands::initializeSides() { - // key scan interval from eeprom - leftHand.setKeyscanInterval(keyscan_interval_); - rightHand.setKeyscanInterval(keyscan_interval_); - - // led brightness from eeprom - leftHand.setBrightness(led_brightness_correction_); - rightHand.setBrightness(led_brightness_correction_); - - // get ANSI/ISO at every side replug - uint8_t l_layout = leftHand.readLayout(); - uint8_t r_layout = rightHand.readLayout(); - - // setup layout variable, this will affect led mapping - defaults to ISO if - // nothing reported - // FIXME - if (l_layout == 1 || r_layout == 1) - layout = 1; - else - layout = 0; - - /* - * if the neuron starts up with no sides connected, it will assume ISO. This - * turns on an extra LED (hardware LED 19 on left side). If an ANSI left is - * then plugged in, the keyboard will switch to ANSI, but LED 19 can't get - * wiped because the ANSI LED map doesn't include this LED. It will be driven - * from the SLED1735's memory with the same colour as before, which causes - * weird looking colours to come on on other seemingly unrelated keys. So: on - * a replug, set LED 19 to off to be safe. - */ - leftHand.led_data.leds[iso_only_led_] = {0, 0, 0}; - - // get activated LED plugin to refresh - ::LEDControl.refreshAll(); -} - -/********* LED Driver *********/ - -bool DefyLEDDriver::isLEDChangedNeuron; -uint8_t DefyLEDDriver::isLEDChangedLeft[LED_BANKS]; -uint8_t DefyLEDDriver::isLEDChangedRight[LED_BANKS]; -cRGB DefyLEDDriver::neuronLED; -constexpr uint8_t DefyLEDDriver::led_map[][DefyLEDDriverProps::led_count + 1]; - -constexpr uint8_t DefyLEDDriverProps::key_led_map[]; - -void DefyLEDDriver::setBrightness(uint8_t brightness) { - DefyHands::ledBrightnessCorrection(brightness); - for (uint8_t i = 0; i < LED_BANKS; i++) { - isLEDChangedLeft[i] = true; - isLEDChangedRight[i] = true; - } -} - -uint8_t DefyLEDDriver::getBrightness() { - return DefyHands::ledBrightnessCorrection(); -} - -void DefyLEDDriver::syncLeds() { - // left and right sides - for (uint8_t i = 0; i < LED_BANKS; i++) { - // only send the banks that have changed - try to improve jitter performance - if (isLEDChangedLeft[i]) { - DefyHands::leftHand.sendLEDBank(i); - isLEDChangedLeft[i] = false; - } - if (isLEDChangedRight[i]) { - DefyHands::rightHand.sendLEDBank(i); - isLEDChangedRight[i] = false; - } - } - - if (isLEDChangedNeuron) { - updateNeuronLED(); - isLEDChangedNeuron = false; - } -} - -void DefyLEDDriver::updateNeuronLED() { - static constexpr struct { - uint8_t r, g, b; - } pins = { 3, 5, 4 }; - auto constexpr gamma8 = kaleidoscope::driver::color::gamma_correction; - - // invert as these are common anode, and make sure we reach 65535 to be able - // to turn fully off. - analogWrite(pins.r, ((256 - pgm_read_byte(&gamma8[neuronLED.r])) << 8) - 1); - analogWrite(pins.g, ((256 - pgm_read_byte(&gamma8[neuronLED.g])) << 8) - 1); - analogWrite(pins.b, ((256 - pgm_read_byte(&gamma8[neuronLED.b])) << 8) - 1); -} - -void DefyLEDDriver::setCrgbAt(uint8_t i, cRGB crgb) { - // prevent reading off the end of the led_map array - if (i >= DefyLEDDriverProps::led_count) return; - - // neuron LED - if (i == DefyLEDDriverProps::led_count - 1) { - isLEDChangedNeuron |= !(neuronLED.r == crgb.r && neuronLED.g == crgb.g && - neuronLED.b == crgb.b); - neuronLED = crgb; - return; - } - - // get the SLED index - uint8_t sled_num = led_map[DefyHands::layout][i]; - if (sled_num < LEDS_PER_HAND) { - cRGB oldColor = DefyHands::leftHand.led_data.leds[sled_num]; - DefyHands::leftHand.led_data.leds[sled_num] = crgb; - isLEDChangedLeft[uint8_t(sled_num / 8)] |= - !(oldColor.r == crgb.r && oldColor.g == crgb.g && oldColor.b == crgb.b); - } else if (sled_num < 2 * LEDS_PER_HAND) { - cRGB oldColor = - DefyHands::rightHand.led_data.leds[sled_num - LEDS_PER_HAND]; - DefyHands::rightHand.led_data.leds[sled_num - LEDS_PER_HAND] = crgb; - isLEDChangedRight[uint8_t((sled_num - LEDS_PER_HAND) / 8)] |= - !(oldColor.r == crgb.r && oldColor.g == crgb.g && oldColor.b == crgb.b); - } else { - // TODO(anyone): - // how do we want to handle debugging assertions about crazy user - // code that would overwrite other memory? - } -} - -cRGB DefyLEDDriver::getCrgbAt(uint8_t i) { - if (i >= DefyLEDDriverProps::led_count) return {0, 0, 0}; - - uint8_t sled_num = led_map[DefyHands::layout][i]; - if (sled_num < LEDS_PER_HAND) { - return DefyHands::leftHand.led_data.leds[sled_num]; - } else if (sled_num < 2 * LEDS_PER_HAND) { - return DefyHands::rightHand.led_data.leds[sled_num - LEDS_PER_HAND]; - } else { - return {0, 0, 0}; - } -} - -void DefyLEDDriver::setup() { - pinMode(SIDE_POWER, OUTPUT); - DefyHands::setSidePower(false); - - // arduino zero analogWrite(255) isn't fully on as its actually working with a - // 16bit counter and the mapping is a bit shift. - // so change to 16 bit resolution to avoid the mapping and do the mapping - // ourselves in updateHubleLED() to ensure LEDs can be set fully off - analogWriteResolution(16); - updateNeuronLED(); - - delay(10); - DefyHands::setSidePower(true); - delay(500); // wait for sides to power up and finish bootloader -} - -/********* Key scanner *********/ - -Defy::keydata_t DefyKeyScanner::leftHandState; -Defy::keydata_t DefyKeyScanner::rightHandState; -Defy::keydata_t DefyKeyScanner::previousLeftHandState; -Defy::keydata_t DefyKeyScanner::previousRightHandState; -Defy::keydata_t DefyKeyScanner::leftHandMask; -Defy::keydata_t DefyKeyScanner::rightHandMask; -bool DefyKeyScanner::lastLeftOnline; -bool DefyKeyScanner::lastRightOnline; - -void DefyKeyScanner::readMatrix() { - previousLeftHandState = leftHandState; - previousRightHandState = rightHandState; - - if (DefyHands::leftHand.readKeys()) { - leftHandState = DefyHands::leftHand.getKeyData(); - // if ANSI, then swap r3c0 and r3c1 to match the PCB - if (DefyHands::layout == LAYOUT_ANSI) { - // only swap if bits are different - if ((leftHandState.rows[3] & (1 << 0)) ^ - leftHandState.rows[3] & (1 << 1)) { - leftHandState.rows[3] ^= (1 << 0); // flip the bit - leftHandState.rows[3] ^= (1 << 1); // flip the bit - } - } - } - - if (DefyHands::rightHand.readKeys()) { - rightHandState = DefyHands::rightHand.getKeyData(); - // if ANSI, then swap r1c0 and r2c0 to match the PCB - if (DefyHands::layout == LAYOUT_ANSI) { - if ((rightHandState.rows[1] & (1 << 0)) ^ - rightHandState.rows[2] & (1 << 0)) { - rightHandState.rows[1] ^= (1 << 0); - rightHandState.rows[2] ^= (1 << 0); - } - } - } - - // if a side has just been replugged, initialise it - if ((DefyHands::leftHand.online && !lastLeftOnline) || - (DefyHands::rightHand.online && !lastRightOnline)) - DefyHands::initializeSides(); - - // if a side has just been unplugged, wipe its state - if (!DefyHands::leftHand.online && lastLeftOnline) leftHandState.all = 0; - - if (!DefyHands::rightHand.online && lastRightOnline) rightHandState.all = 0; - - // store previous state of whether the sides are plugged in - lastLeftOnline = DefyHands::leftHand.online; - lastRightOnline = DefyHands::rightHand.online; -} - -void DefyKeyScanner::actOnMatrixScan() { - for (byte row = 0; row < Props_::matrix_rows; row++) { - for (byte col = 0; col < Props_::left_columns; col++) { - uint8_t keynum = (row * Props_::left_columns) + col; - uint8_t keyState; - - // left - keyState = (bitRead(previousLeftHandState.all, keynum) << 0) | - (bitRead(leftHandState.all, keynum) << 1); - if (keyState) - ThisType::handleKeyswitchEvent(Key_NoKey, KeyAddr(row, col), keyState); - - // right - keyState = (bitRead(previousRightHandState.all, keynum) << 0) | - (bitRead(rightHandState.all, keynum) << 1); - if (keyState) - ThisType::handleKeyswitchEvent( - Key_NoKey, KeyAddr(row, (Props_::matrix_columns - 1) - col), - keyState); - } - } -} - -void DefyKeyScanner::scanMatrix() { - readMatrix(); - actOnMatrixScan(); -} - -void DefyKeyScanner::maskKey(KeyAddr key_addr) { - if (!key_addr.isValid()) return; - - auto row = key_addr.row(); - auto col = key_addr.col(); - - if (col >= Props_::left_columns) { - rightHandMask.rows[row] |= - 1 << (Props_::right_columns - (col - Props_::left_columns)); - } else { - leftHandMask.rows[row] |= 1 << (Props_::right_columns - col); - } -} - -void DefyKeyScanner::unMaskKey(KeyAddr key_addr) { - if (!key_addr.isValid()) return; - - auto row = key_addr.row(); - auto col = key_addr.col(); - - if (col >= Props_::left_columns) { - rightHandMask.rows[row] &= - ~(1 << (Props_::right_columns - (col - Props_::left_columns))); - } else { - leftHandMask.rows[row] &= ~(1 << (Props_::right_columns - col)); - } -} - -bool DefyKeyScanner::isKeyMasked(KeyAddr key_addr) { - if (!key_addr.isValid()) return false; - - auto row = key_addr.row(); - auto col = key_addr.col(); - - if (col >= 8) { - return rightHandMask.rows[row] & (1 << (7 - (col - 8))); - } else { - return leftHandMask.rows[row] & (1 << (7 - col)); - } -} - -void DefyKeyScanner::maskHeldKeys() { - memcpy(leftHandMask.rows, leftHandState.rows, sizeof(leftHandMask)); - memcpy(rightHandMask.rows, rightHandState.rows, sizeof(rightHandMask)); -} - -bool DefyKeyScanner::isKeyswitchPressed(KeyAddr key_addr) { - auto row = key_addr.row(); - auto col = key_addr.col(); - - if (col >= Props_::left_columns) { - return (bitRead(rightHandState.rows[row], - (Props_::matrix_columns - 1) - col) != 0); - } else { - return (bitRead(leftHandState.rows[row], col) != 0); - } -} - -bool DefyKeyScanner::wasKeyswitchPressed(KeyAddr key_addr) { - auto row = key_addr.row(); - auto col = key_addr.col(); - - if (col >= Props_::left_columns) { - return (bitRead(previousRightHandState.rows[row], - (Props_::matrix_columns - 1) - col) != 0); - } else { - return (bitRead(previousLeftHandState.rows[row], col) != 0); - } -} - -uint8_t DefyKeyScanner::pressedKeyswitchCount() { - return __builtin_popcountll(leftHandState.all) + - __builtin_popcountll(rightHandState.all); -} - -uint8_t DefyKeyScanner::previousPressedKeyswitchCount() { - return __builtin_popcountll(previousLeftHandState.all) + - __builtin_popcountll(previousRightHandState.all); -} - -void DefyKeyScanner::setKeyscanInterval(uint8_t interval) { - DefyHands::leftHand.setKeyscanInterval(interval); - DefyHands::rightHand.setKeyscanInterval(interval); -} - -void DefyKeyScanner::setup() { - static constexpr uint8_t keyscanner_pins[] = { - 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 30, - 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42}; - for (int i = 0; i < sizeof(keyscanner_pins); i++) { - pinMode(keyscanner_pins[i], OUTPUT); - digitalWrite(keyscanner_pins[i], LOW); - } -} - -void DefyKeyScanner::reset() { - leftHandState.all = 0; - rightHandState.all = 0; - Runtime.hid().keyboard().releaseAllKeys(); - Runtime.hid().keyboard().sendReport(); -} - -/********* Hardware plugin *********/ -void Defy::setup() { - DefyHands::setup(); - KeyScanner::setup(); - LEDDriver::setup(); - - // initialise Wire of scanner - have to do this here to avoid problem with - // static object intialisation ordering - Wire.begin(); - Wire.setClock(I2C_CLOCK_KHZ * 1000); - - DefyHands::initializeSides(); -} - -void Defy::side::prepareForFlash() { - Wire.end(); - - setPower(LOW); - // also turn off i2c pins to stop attiny from getting enough current through - // i2c to stay on - pinMode(SCL, OUTPUT); - pinMode(SDA, OUTPUT); - digitalWrite(SCL, false); - digitalWrite(SDA, false); - - // wipe key states, to prevent accidental key repeats - DefyKeyScanner::reset(); - - setPower(HIGH); - - Wire.begin(); - Wire.setClock(I2C_FLASH_CLOCK_KHZ * 1000); - // wait for side bootloader to be ready - delay(100); -} - -uint8_t Defy::side::getPower() { return DefyHands::getSidePower(); } -void Defy::side::setPower(uint8_t power) { DefyHands::setSidePower(power); } - -uint8_t Defy::side::leftVersion() { - return DefyHands::leftHand.readVersion(); -} -uint8_t Defy::side::rightVersion() { - return DefyHands::rightHand.readVersion(); -} - -uint8_t Defy::side::leftCRCErrors() { - return DefyHands::leftHand.crc_errors(); -} -uint8_t Defy::side::rightCRCErrors() { - return DefyHands::rightHand.crc_errors(); -} - -uint8_t Defy::side::leftSLEDVersion() { - return DefyHands::leftHand.readSLEDVersion(); -} -uint8_t Defy::side::rightSLEDVersion() { - return DefyHands::rightHand.readSLEDVersion(); -} - -uint8_t Defy::side::leftSLEDCurrent() { - return DefyHands::leftHand.readSLEDCurrent(); -} -uint8_t Defy::side::rightSLEDCurrent() { - return DefyHands::rightHand.readSLEDCurrent(); -} -void Defy::side::setSLEDCurrent(uint8_t current) { - DefyHands::rightHand.setSLEDCurrent(current); - DefyHands::leftHand.setSLEDCurrent(current); -} - -Defy::settings::Layout Defy::settings::layout() { - return DefyHands::layout == LAYOUT_ANSI ? Layout::ANSI : Layout::ISO; -} -uint8_t Defy::settings::joint() { return DefyHands::rightHand.readJoint(); } - -uint16_t Defy::settings::keyscanInterval() { - return DefyHands::keyscanInterval(); -} -String Defy::settings::getChipID() { - return DefyHands::getChipID(); -} -void Defy::settings::keyscanInterval(uint16_t interval) { - DefyHands::keyscanInterval(interval); -} - -} // namespace dygma -} // namespace device -} // namespace kaleidoscope - -#endif diff --git a/src/kaleidoscope/device/dygma/Defy.h b/src/kaleidoscope/device/dygma/Defy.h deleted file mode 100644 index 8aae37d..0000000 --- a/src/kaleidoscope/device/dygma/Defy.h +++ /dev/null @@ -1,278 +0,0 @@ -/* -*- mode: c++ -*- - * kaleidoscope::device::dygma::Defy -- Kaleidoscope device plugin for Dygma Defy - * Copyright (C) 2017-2020 Keyboard.io, Inc - * Copyright (C) 2017-2020 Dygma Lab S.L. - * - * This program is free software: you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software - * Foundation, version 3. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License along with - * this program. If not, see . - */ - -#pragma once - -#ifdef ARDUINO_NRF5_DEFY -#include - -#include "kaleidoscope/device/dygma/Defy/Hand.h" - -#define CRGB(r,g,b) (cRGB){b, g, r} - -#include "kaleidoscope/driver/keyscanner/Base.h" -#include "kaleidoscope/driver/led/Base.h" -#include "kaleidoscope/driver/bootloader/samd/Bossac.h" -#include "kaleidoscope/driver/storage/Flash.h" -#include "kaleidoscope/device/Base.h" -#include "kaleidoscope/util/flasher/KeyboardioI2CBootloader.h" - -namespace kaleidoscope { -namespace device { -namespace dygma { - -// LHK = Left Hand Keys -#define LHK 33 - -using kaleidoscope::driver::led::no_led; - -struct DefyLEDDriverProps : public kaleidoscope::driver::led::BaseProps { - static constexpr uint8_t led_count = 132; - static constexpr uint8_t key_led_map[] = { - // ISO & ANSI (ANSI has no LED at 20, but this key can never be pressed so we can have just one map). - 0, 1, 2, 3, 4, 5, 6, no_led, no_led, 6 + LHK, 5 + LHK, 4 + LHK, 3 + LHK, 2 + LHK, 1 + LHK, 0 + LHK, - 7, 8, 9, 10, 11, 12, no_led, no_led, 14 + LHK, 13 + LHK, 12 + LHK, 11 + LHK, 10 + LHK, 9 + LHK, 8 + LHK, 7 + LHK, - 13, 14, 15, 16, 17, 18, no_led, no_led, no_led, 21 + LHK, 20 + LHK, 19 + LHK, 18 + LHK, 17 + LHK, 16 + LHK, 15 + LHK, - 19, 20, 21, 22, 23, 24, 25, no_led, no_led, no_led, 27 + LHK, 26 + LHK, 25 + LHK, 24 + LHK, 23 + LHK, 22 + LHK, - 26, 27, 28, 29, 30, no_led, 31, 32, 35 + LHK, 34 + LHK, 33 + LHK, 32 + LHK, 31 + LHK, 30 + LHK, 29 + LHK, 28 + LHK - }; -}; -#undef LHK - -class DefyLEDDriver : public kaleidoscope::driver::led::Base { - public: - static void setup(); - - static void syncLeds(); - static void setCrgbAt(uint8_t i, cRGB crgb); - static cRGB getCrgbAt(uint8_t i); - static void setBrightness(uint8_t brightness); - static uint8_t getBrightness(); - - static void updateNeuronLED(); - private: - static bool isLEDChangedNeuron; - static uint8_t isLEDChangedLeft[LED_BANKS]; - static uint8_t isLEDChangedRight[LED_BANKS]; - static cRGB neuronLED; - - static constexpr uint8_t lph = LEDS_PER_HAND; - // led_count + 1, to account for the Neuron's LED. The last one is the - // Neuron's LED, never send that to SLED. - static constexpr uint8_t led_map[][DefyLEDDriverProps::led_count + 1] = { - // ISO - { - // left side - 33 keys includes LP - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 68, 69, - - // right side - 36 keys includes LP - 0 + LPH, 1 + LPH, 2 + LPH, 3 + LPH, 4 + LPH, 5 + LPH, 6 + LPH, 7 + LPH, 8 + LPH, 9 + LPH, 10 + LPH, 11 + LPH, 12 + LPH, 13 + LPH, 14 + LPH, 15 + LPH, 16 + LPH, 17 + LPH, 18 + LPH, 19 + LPH, - 20 + LPH, 21 + LPH, 22 + LPH, 23 + LPH, 24 + LPH, 25 + LPH, 26 + LPH, 27 + LPH, 28 + LPH, 29 + LPH, 30 + LPH, 31 + LPH, 32 + LPH, 33 + LPH, 68 + LPH, 69 + LPH, - - // left under glow - 30 - 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, - - // right underglow - 32 - 34 + LPH, 35 + LPH, 36 + LPH, 37 + LPH, 38 + LPH, 39 + LPH, 40 + LPH, 41 + LPH, 42 + LPH, 43 + LPH, 44 + LPH, 45 + LPH, 46 + LPH, 47 + LPH, 48 + LPH, 49 + LPH, 50 + LPH, 51 + LPH, - 52 + LPH, 53 + LPH, 54 + LPH, 55 + LPH, 56 + LPH, 57 + LPH, 58 + LPH, 59 + LPH, 60 + LPH, 61 + LPH, 62 + LPH, 63 + LPH, 64 + LPH, 65 + LPH, 0xff - }, - // ANSI - { - // left side - 32 keys includes LP: key 19 is missing for ANSI layout - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 20, 0xff, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 68, 69, - - // right side - 36 keys includes LP - 0 + LPH, 1 + LPH, 2 + LPH, 3 + LPH, 4 + LPH, 5 + LPH, 6 + LPH, 15 + LPH, 8 + LPH, 9 + LPH, 10 + LPH, 11 + LPH, 12 + LPH, 13 + LPH, 14 + LPH, 7 + LPH, 16 + LPH, 17 + LPH, 18 + LPH, 19 + LPH, - 20 + LPH, 21 + LPH, 22 + LPH, 23 + LPH, 24 + LPH, 25 + LPH, 26 + LPH, 27 + LPH, 28 + LPH, 29 + LPH, 30 + LPH, 31 + LPH, 32 + LPH, 33 + LPH, 68 + LPH, 69 + LPH, - - // left under glow - 30 - 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, - - // right underglow - 32 - 34 + LPH, 35 + LPH, 36 + LPH, 37 + LPH, 38 + LPH, 39 + LPH, 40 + LPH, 41 + LPH, 42 + LPH, 43 + LPH, 44 + LPH, 45 + LPH, 46 + LPH, 47 + LPH, 48 + LPH, 49 + LPH, 50 + LPH, 51 + LPH, - 52 + LPH, 53 + LPH, 54 + LPH, 55 + LPH, 56 + LPH, 57 + LPH, 58 + LPH, 59 + LPH, 60 + LPH, 61 + LPH, 62 + LPH, 63 + LPH, 64 + LPH, 65 + LPH, 0xff - } - }; -}; - -struct DefyKeyScannerProps : public kaleidoscope::driver::keyscanner::BaseProps { - static constexpr uint8_t matrix_rows = 5; - static constexpr uint8_t matrix_columns = 16; - typedef MatrixAddr KeyAddr; - - static constexpr uint8_t left_columns = 8; - static constexpr uint8_t right_columns = matrix_columns - left_columns; -}; - -class DefyKeyScanner : public kaleidoscope::driver::keyscanner::Base { - private: - typedef DefyKeyScanner ThisType; - typedef DefyKeyScannerProps Props_; - public: - static void setup(); - static void scanMatrix(); - static void readMatrix(); - static void actOnMatrixScan(); - - static void maskKey(KeyAddr key_addr); - static void unMaskKey(KeyAddr key_addr); - static bool isKeyMasked(KeyAddr key_addr); - static void maskHeldKeys(); - - static bool isKeyswitchPressed(KeyAddr key_addr); - static uint8_t pressedKeyswitchCount(); - - static bool wasKeyswitchPressed(KeyAddr key_addr); - static uint8_t previousPressedKeyswitchCount(); - - static void setKeyscanInterval(uint8_t interval); - - static void reset(); - - protected: - static Defy::keydata_t leftHandState; - static Defy::keydata_t rightHandState; - static Defy::keydata_t previousLeftHandState; - static Defy::keydata_t previousRightHandState; - - static Defy::keydata_t leftHandMask; - static Defy::keydata_t rightHandMask; - - static bool lastLeftOnline; - static bool lastRightOnline; -}; - -struct DefyStorageProps : public kaleidoscope::driver::storage::FlashProps { - static constexpr uint16_t length = EEPROM_EMULATION_SIZE; -}; - -struct DefySideFlasherProps : public kaleidoscope::util::flasher::BaseProps {}; - -struct DefyProps : kaleidoscope::device::BaseProps { - typedef DefyLEDDriverProps LEDDriverProps; - typedef DefyLEDDriver LEDDriver; - typedef DefyKeyScannerProps KeyScannerProps; - typedef DefyKeyScanner KeyScanner; - typedef DefyStorageProps StorageProps; - typedef kaleidoscope::driver::storage::Flash Storage; - typedef kaleidoscope::driver::bootloader::samd::Bossac BootLoader; - - typedef DefySideFlasherProps SideFlasherProps; - typedef kaleidoscope::util::flasher::KeyboardioI2CBootloader SideFlasher; - static constexpr const char *short_name = "Defy"; -}; - -class Defy: public kaleidoscope::device::Base { - private: - static DefyProps::SideFlasher SideFlasher; - public: - static void setup(); - - auto serialPort() -> decltype(SerialUSB) & { - return SerialUSB; - } - - auto sideFlasher() -> decltype(SideFlasher) & { - return SideFlasher; - } - - struct side { - uint8_t getPower(); - void setPower(uint8_t power); - - uint8_t leftVersion(); - uint8_t rightVersion(); - - uint8_t leftCRCErrors(); - uint8_t rightCRCErrors(); - - uint8_t leftSLEDVersion(); - uint8_t rightSLEDVersion(); - - uint8_t leftSLEDCurrent(); - uint8_t rightSLEDCurrent(); - void setSLEDCurrent(uint8_t current); - - void prepareForFlash(); - - // Side bootloader addresses - static constexpr uint8_t left_boot_address = 0x50; - static constexpr uint8_t right_boot_address = 0x51; - } side; - - struct settings { - enum class Layout { - ISO, - ANSI - }; - Layout layout(); - uint8_t joint(); - - uint16_t keyscanInterval(); - void keyscanInterval(uint16_t interval); - String getChipID(); - } settings; -}; - - -} -} - -typedef kaleidoscope::device::dygma::Defy Device; - -} - -#define PER_KEY_DATA(dflt, \ - r0c0, r0c1, r0c2, r0c3, r0c4, r0c5, r0c6, r0c9, r0c10, r0c11, r0c12, r0c13, r0c14, r0c15, \ - r1c0, r1c1, r1c2, r1c3, r1c4, r1c5, r1c8, r1c9, r1c10, r1c11, r1c12, r1c13, r1c14, r1c15, \ - r2c0, r2c1, r2c2, r2c3, r2c4, r2c5, r2c9, r2c10, r2c11, r2c12, r2c13, r2c14, r2c15, \ - r3c0, r3c1, r3c2, r3c3, r3c4, r3c5, r3c6, r3c10, r3c11, r3c12, r3c13, r3c14, r3c15, \ - r4c0, r4c1, r4c2, r4c3, r4c4, r4c10, r4c11, r4c12, r4c13, r4c14, r4c15, \ - r4c6, r4c7, r4c8, r4c9 \ - ) \ - \ - r0c0, r0c1, r0c2, r0c3, r0c4, r0c5, r0c6, dflt, dflt, r0c9, r0c10, r0c11, r0c12, r0c13, r0c14, r0c15, \ - r1c0, r1c1, r1c2, r1c3, r1c4, r1c5, dflt, dflt, r1c8, r1c9, r1c10, r1c11, r1c12, r1c13, r1c14, r1c15, \ - r2c0, r2c1, r2c2, r2c3, r2c4, r2c5, dflt, dflt, dflt, r2c9, r2c10, r2c11, r2c12, r2c13, r2c14, r2c15, \ - r3c0, r3c1, r3c2, r3c3, r3c4, r3c5, r3c6, dflt, dflt, dflt, r3c10, r3c11, r3c12, r3c13, r3c14, r3c15, \ - r4c0, r4c1, r4c2, r4c3, r4c4, dflt, r4c6, r4c7, r4c8, r4c9, r4c10, r4c11, r4c12, r4c13, r4c14, r4c15 - - -#define PER_KEY_DATA_STACKED(dflt, \ - r0c0, r0c1, r0c2, r0c3, r0c4, r0c5, r0c6, \ - r1c0, r1c1, r1c2, r1c3, r1c4, r1c5, \ - r2c0, r2c1, r2c2, r2c3, r2c4, r2c5, \ - r3c0, r3c1, r3c2, r3c3, r3c4, r3c5, r3c6, \ - r4c0, r4c1, r4c2, r4c3, r4c4, \ - r4c6, r4c7, \ - \ - r0c9, r0c10, r0c11, r0c12, r0c13, r0c14, r0c15, \ - r1c8, r1c9, r1c10, r1c11, r1c12, r1c13, r1c14, r1c15, \ - r2c9, r2c10, r2c11, r2c12, r2c13, r2c14, r2c15, \ - r3c10, r3c11, r3c12, r3c13, r3c14, r3c15, \ - r4c10, r4c11, r4c12, r4c13, r4c14, r4c15, \ - r4c8, r4c9 \ - ) \ - \ - r0c0, r0c1, r0c2, r0c3, r0c4, r0c5, r0c6, dflt, dflt, r0c9, r0c10, r0c11, r0c12, r0c13, r0c14, r0c15, \ - r1c0, r1c1, r1c2, r1c3, r1c4, r1c5, dflt, dflt, r1c8, r1c9, r1c10, r1c11, r1c12, r1c13, r1c14, r1c15, \ - r2c0, r2c1, r2c2, r2c3, r2c4, r2c5, dflt, dflt, dflt, r2c9, r2c10, r2c11, r2c12, r2c13, r2c14, r2c15, \ - r3c0, r3c1, r3c2, r3c3, r3c4, r3c5, r3c6, dflt, dflt, dflt, r3c10, r3c11, r3c12, r3c13, r3c14, r3c15, \ - r4c0, r4c1, r4c2, r4c3, r4c4, dflt, r4c6, r4c7, r4c8, r4c9, r4c10, r4c11, r4c12, r4c13, r4c14, r4c15 - -#endif diff --git a/src/kaleidoscope/device/dygma/Defy_wireless.h b/src/kaleidoscope/device/dygma/Defy_wireless.h index f1b0528..8d4879e 100644 --- a/src/kaleidoscope/device/dygma/Defy_wireless.h +++ b/src/kaleidoscope/device/dygma/Defy_wireless.h @@ -22,7 +22,7 @@ #ifndef __DEFY_WIRELESS_H__ #define __DEFY_WIRELESS_H__ -#include "kaleidoscope/device/dygma/defy_wireless/Hand.h" +#include "kaleidoscope/device/dygma/keyboards/Hand.h" #include "kaleidoscope/driver/bootloader/nrf/NRF.h" #include "Ble_composite_dev.h" @@ -39,12 +39,12 @@ #include "libraries/KeyboardioHID/src/MultiReport/RawHID.h" -#define DEFY_HANDS_DEBUG 1 +#define KEYBOARD_HANDS_DEBUG 1 #define PRINT_KEYSWITCH_EVENT_PARAMETERS 0 -#ifndef DEFY_NEURON_FW_VERSION +#ifndef KEYBOARD_NEURON_FW_VERSION #error "Firmware version is not specified." - #define DEFY_NEURON_FW_VERSION "N/A" + #define KEYBOARD_NEURON_FW_VERSION "N/A" #endif namespace kaleidoscope { @@ -56,7 +56,7 @@ namespace dygma { using kaleidoscope::driver::led::no_led; -struct DefyLEDDriverProps : public kaleidoscope::driver::led::BaseProps { +struct KeyboardLEDDriverProps : public kaleidoscope::driver::led::BaseProps { static constexpr uint8_t underglow_leds = 53; static constexpr uint8_t key_matrix_leds = 35; @@ -89,7 +89,7 @@ struct DefyLEDDriverProps : public kaleidoscope::driver::led::BaseProps { #undef LHK -class DefyLEDDriver : public kaleidoscope::driver::led::Base { +class KeyboardLEDDriver : public kaleidoscope::driver::led::Base { public: static void setup(); @@ -108,10 +108,10 @@ class DefyLEDDriver : public kaleidoscope::driver::led::Base static void setBrightnessUGWireless(uint8_t brightnessUG); static uint8_t getBrightnessUGWireless(); static void updateNeuronLED(); - static constexpr uint8_t underglow_leds = DefyLEDDriverProps::underglow_leds_leftSide; - static constexpr uint8_t key_matrix_left = DefyLEDDriverProps::leds_hand_left; - static constexpr uint8_t key_matrix_right = DefyLEDDriverProps::leds_hand_right; - static constexpr uint8_t underglow_leds_right = DefyLEDDriverProps::underglow_leds_rightSide; + static constexpr uint8_t underglow_leds = KeyboardLEDDriverProps::underglow_leds_leftSide; + static constexpr uint8_t key_matrix_left = KeyboardLEDDriverProps::leds_hand_left; + static constexpr uint8_t key_matrix_right = KeyboardLEDDriverProps::leds_hand_right; + static constexpr uint8_t underglow_leds_right = KeyboardLEDDriverProps::underglow_leds_rightSide; private: static bool isLEDChangedNeuron; static bool leds_enabled_; @@ -123,7 +123,7 @@ class DefyLEDDriver : public kaleidoscope::driver::led::Base // led_count + 1, to account for the Neuron's LED. The last one is the // Neuron's LED, never send that to SLED. // clang-format off - static constexpr uint8_t led_map[DefyLEDDriverProps::led_count] = { + static constexpr uint8_t led_map[KeyboardLEDDriverProps::led_count] = { // left side - 35 keys includes LP 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, @@ -150,7 +150,7 @@ class DefyLEDDriver : public kaleidoscope::driver::led::Base // clang-format on }; -struct DefyKeyScannerProps : public kaleidoscope::driver::keyscanner::BaseProps { +struct KeyboardKeyScannerProps : public kaleidoscope::driver::keyscanner::BaseProps { static constexpr uint8_t matrix_rows = 5; static constexpr uint8_t matrix_columns = 16; typedef MatrixAddr KeyAddr; @@ -159,10 +159,10 @@ struct DefyKeyScannerProps : public kaleidoscope::driver::keyscanner::BaseProps static constexpr uint8_t right_columns = matrix_columns - left_columns; }; -class DefyKeyScanner : public kaleidoscope::driver::keyscanner::Base { +class KeyboardKeyScanner : public kaleidoscope::driver::keyscanner::Base { private: - typedef DefyKeyScanner ThisType; - typedef DefyKeyScannerProps Props_; + typedef KeyboardKeyScanner ThisType; + typedef KeyboardKeyScannerProps Props_; public: static void setup(); @@ -187,35 +187,35 @@ class DefyKeyScanner : public kaleidoscope::driver::keyscanner::Base Storage; - //typedef DefySideFlasherProps SideFlasherProps; + //typedef KeyboardSideFlasherProps SideFlasherProps; //typedef kaleidoscope::util::flasher::KeyboardioI2CBootloader SideFlasher; static constexpr const char *short_name = "defy_wireless"; }; -class DefyNrf : public kaleidoscope::device::Base { +class KeyboardNrf : public kaleidoscope::device::Base { /*private: - static DefyProps::SideFlasher SideFlasher;*/ + static KeyboardProps::SideFlasher SideFlasher;*/ public: static void setup(); @@ -258,7 +258,7 @@ class DefyNrf : public kaleidoscope::device::Base { } // namespace dygma } // namespace device -typedef kaleidoscope::device::dygma::DefyNrf Device; +typedef kaleidoscope::device::dygma::KeyboardNrf Device; } // namespace kaleidoscope diff --git a/src/kaleidoscope/device/dygma/Defy_wireless.cpp b/src/kaleidoscope/device/dygma/KeyboardManager.cpp similarity index 77% rename from src/kaleidoscope/device/dygma/Defy_wireless.cpp rename to src/kaleidoscope/device/dygma/KeyboardManager.cpp index 768c706..74d679f 100644 --- a/src/kaleidoscope/device/dygma/Defy_wireless.cpp +++ b/src/kaleidoscope/device/dygma/KeyboardManager.cpp @@ -35,12 +35,12 @@ #include "Ble_manager.h" #include "Colormap-Defy.h" #include "Communications.h" -#include "Defy_wireless.h" +#include DYGMA_KEYBOARD #include "LED-Palette-Theme-Defy.h" #include "Radio_manager.h" #include "Status_leds.h" #include "Wire.h" // Arduino Wire wrapper for the NRF52 chips -#include "defy_wireless/Focus.h" +#include "keyboards/Focus.h" #include "nrf_gpio.h" #include "Battery.h" @@ -59,12 +59,12 @@ namespace device namespace dygma { -/********* DefyHands *********/ +/********* KeyboardHands *********/ -struct DefyHands +struct KeyboardHands { - static defy_wireless::Hand leftHand; - static defy_wireless::Hand rightHand; + static dygma_keyboards::Hand leftHand; + static dygma_keyboards::Hand rightHand; static void setup(); @@ -126,15 +126,15 @@ struct DefyHands static void setbrightness(const Brightness &data); }; -defy_wireless::Hand DefyHands::leftHand(defy_wireless::Hand::LEFT); -defy_wireless::Hand DefyHands::rightHand(defy_wireless::Hand::RIGHT); -bool DefyHands::side_power_; -uint16_t DefyHands::settings_interval_; -uint16_t DefyHands::settings_base; -DefyHands::Brightness DefyHands::bright; -uint8_t DefyHands::keyscan_interval_ = 15; +dygma_keyboards::Hand KeyboardHands::leftHand(dygma_keyboards::Hand::LEFT); +dygma_keyboards::Hand KeyboardHands::rightHand(dygma_keyboards::Hand::RIGHT); +bool KeyboardHands::side_power_; +uint16_t KeyboardHands::settings_interval_; +uint16_t KeyboardHands::settings_base; +KeyboardHands::Brightness KeyboardHands::bright; +uint8_t KeyboardHands::keyscan_interval_ = 15; -void DefyHands::setSidePower(bool power) +void KeyboardHands::setSidePower(bool power) { // 0 -> reset keyboard side, 1 -> run keyboard side if (power) @@ -178,12 +178,12 @@ auto checkBrightness = [](const Packet &) status_leds.static_green(NEURON_LED_BRIGHTNESS); auto &keyScanner = Runtime.device().keyScanner(); - auto isDefyLeftWired = keyScanner.leftSideWiredConnection(); - auto isDefyRightWired = keyScanner.rightSideWiredConnection(); - ColormapEffectDefy.updateBrigthness(ColormapEffectDefy.no_led_effect, true, isDefyLeftWired && isDefyRightWired && !ble_innited()); + auto isKSLeftWired = keyScanner.leftSideWiredConnection(); + auto isKSRightWired = keyScanner.rightSideWiredConnection(); + ColormapEffectDefy.updateBrigthness(ColormapEffectDefy.no_led_effect, true, isKSLeftWired && isKSRightWired && !ble_innited()); }; -void DefyHands::setup() +void KeyboardHands::setup() { rightHand.init(); leftHand.init(); @@ -240,7 +240,7 @@ void DefyHands::setup() settings_interval_ = ::EEPROMSettings.requestSlice(sizeof(keyscan_interval_)); - settings_base = ::EEPROMSettings.requestSlice(sizeof(DefyHands::Brightness)); + settings_base = ::EEPROMSettings.requestSlice(sizeof(KeyboardHands::Brightness)); // If keyscan is max, assume that EEPROM is uninitialized, and store the defaults. uint16_t interval; Runtime.storage().get(settings_interval_, interval); @@ -251,7 +251,7 @@ void DefyHands::setup() } Runtime.storage().get(settings_interval_, keyscan_interval_); - DefyHands::Brightness brightness; + KeyboardHands::Brightness brightness; Runtime.storage().get(settings_base, brightness); if (brightness.flag != 0) { @@ -265,13 +265,13 @@ void DefyHands::setup() Runtime.storage().get(settings_base, bright); } -void DefyHands::setbrightness(const Brightness &data) +void KeyboardHands::setbrightness(const Brightness &data) { Runtime.storage().put(settings_base, data); Runtime.storage().commit(); } -void DefyHands::keyscanInterval(uint8_t interval) +void KeyboardHands::keyscanInterval(uint8_t interval) { Communications_protocol::Packet p{}; p.header.command = Communications_protocol::KEYSCAN_INTERVAL; @@ -283,40 +283,40 @@ void DefyHands::keyscanInterval(uint8_t interval) Runtime.storage().commit(); } -void DefyHands::ledBrightnessLedDriver(uint8_t brightness) +void KeyboardHands::ledBrightnessLedDriver(uint8_t brightness) { bright.led_brightness_ledDriver_ = brightness; sendPacketBrightness(); setbrightness(bright); } -void DefyHands::ledBrightnessUG(uint8_t brightnessUG) +void KeyboardHands::ledBrightnessUG(uint8_t brightnessUG) { bright.led_brightness_underglow_ = brightnessUG; sendPacketBrightness(); setbrightness(bright); } -void DefyHands::ledBrightnessLedDriverWireless(uint8_t brightness) +void KeyboardHands::ledBrightnessLedDriverWireless(uint8_t brightness) { bright.led_brightness_ledDriver_wireless_ = brightness; sendPacketBrightness(); setbrightness(bright); } -void DefyHands::ledBrightnessUGWireless(uint8_t brightnessUG) +void KeyboardHands::ledBrightnessUGWireless(uint8_t brightnessUG) { bright.led_brightness_underglow_wireless_ = brightnessUG; sendPacketBrightness(); setbrightness(bright); } -void DefyHands::sendPacketBrightness() +void KeyboardHands::sendPacketBrightness() { Packet p{}; checkBrightness(p); } -void DefyHands::getChipID(char *cstring, uint16_t len) +void KeyboardHands::getChipID(char *cstring, uint16_t len) { /* Returns the 64 bit unique device identifier. @@ -329,7 +329,7 @@ void DefyHands::getChipID(char *cstring, uint16_t len) snprintf(cstring, len, "%8lx%8lx", NRF_FICR->DEVICEID[1], NRF_FICR->DEVICEID[0]); } -void DefyHands::get_chip_info(char *cstring, uint16_t len) +void KeyboardHands::get_chip_info(char *cstring, uint16_t len) { /* See: FICR - Factory information configuration registers on pag. 30 of the datasheet. @@ -344,63 +344,63 @@ void DefyHands::get_chip_info(char *cstring, uint16_t len) /********* LED Driver *********/ -bool DefyLEDDriver::isLEDChangedNeuron; -bool DefyLEDDriver::leds_enabled_ = true; -uint8_t DefyLEDDriver::isLEDChangedLeft[LED_BANKS]; -uint8_t DefyLEDDriver::isLEDChangedRight[LED_BANKS]; -cRGB DefyLEDDriver::neuronLED; -constexpr uint8_t DefyLEDDriver::led_map[DefyLEDDriverProps::led_count]; -constexpr uint8_t DefyLEDDriverProps::key_led_map[]; +bool KeyboardLEDDriver::isLEDChangedNeuron; +bool KeyboardLEDDriver::leds_enabled_ = true; +uint8_t KeyboardLEDDriver::isLEDChangedLeft[LED_BANKS]; +uint8_t KeyboardLEDDriver::isLEDChangedRight[LED_BANKS]; +cRGB KeyboardLEDDriver::neuronLED; +constexpr uint8_t KeyboardLEDDriver::led_map[KeyboardLEDDriverProps::led_count]; +constexpr uint8_t KeyboardLEDDriverProps::key_led_map[]; // Wired setters and getters -void DefyLEDDriver::setBrightness(uint8_t brightness) +void KeyboardLEDDriver::setBrightness(uint8_t brightness) { - DefyHands::ledBrightnessLedDriver(brightness); + KeyboardHands::ledBrightnessLedDriver(brightness); } -uint8_t DefyLEDDriver::getBrightness() +uint8_t KeyboardLEDDriver::getBrightness() { - return DefyHands::ledBrightnessLedDriver(); + return KeyboardHands::ledBrightnessLedDriver(); } -void DefyLEDDriver::setBrightnessUG(uint8_t brightnessUG) +void KeyboardLEDDriver::setBrightnessUG(uint8_t brightnessUG) { - DefyHands::ledBrightnessUG(brightnessUG); + KeyboardHands::ledBrightnessUG(brightnessUG); } -uint8_t DefyLEDDriver::getBrightnessUG() +uint8_t KeyboardLEDDriver::getBrightnessUG() { - return DefyHands::ledBrightnessUG(); + return KeyboardHands::ledBrightnessUG(); } // Wireless setters and getters -void DefyLEDDriver::setBrightnessWireless(uint8_t brightness) +void KeyboardLEDDriver::setBrightnessWireless(uint8_t brightness) { - DefyHands::ledBrightnessLedDriverWireless(brightness); + KeyboardHands::ledBrightnessLedDriverWireless(brightness); } -uint8_t DefyLEDDriver::getBrightnessWireless() +uint8_t KeyboardLEDDriver::getBrightnessWireless() { - return DefyHands::ledBrightnessLedDriverWireless(); + return KeyboardHands::ledBrightnessLedDriverWireless(); } -void DefyLEDDriver::setBrightnessUGWireless(uint8_t brightnessUG) +void KeyboardLEDDriver::setBrightnessUGWireless(uint8_t brightnessUG) { - DefyHands::ledBrightnessUGWireless(brightnessUG); + KeyboardHands::ledBrightnessUGWireless(brightnessUG); } -uint8_t DefyLEDDriver::getBrightnessUGWireless() +uint8_t KeyboardLEDDriver::getBrightnessUGWireless() { - return DefyHands::ledBrightnessUGWireless(); + return KeyboardHands::ledBrightnessUGWireless(); } -void DefyLEDDriver::syncLeds() +void KeyboardLEDDriver::syncLeds() { bool is_enabled = ::LEDControl.isEnabled(); if (leds_enabled_ != is_enabled) { leds_enabled_ = is_enabled; - DefyHands::sendPacketBrightness(); + KeyboardHands::sendPacketBrightness(); } if (isLEDChangedNeuron) @@ -416,7 +416,7 @@ void DefyLEDDriver::syncLeds() } } -void DefyLEDDriver::updateNeuronLED() +void KeyboardLEDDriver::updateNeuronLED() { // static constexpr struct // { @@ -430,13 +430,13 @@ void DefyLEDDriver::updateNeuronLED() analogWrite(pins.b, ((256 - pgm_read_byte(&gamma8[neuronLED.b])) << 8) - 1);*/ } -void DefyLEDDriver::setCrgbAt(uint8_t i, cRGB crgb) +void KeyboardLEDDriver::setCrgbAt(uint8_t i, cRGB crgb) { // prevent reading off the end of the led_map array - if (i >= DefyLEDDriverProps::led_count) return; + if (i >= KeyboardLEDDriverProps::led_count) return; // neuron LED - if (i == DefyLEDDriverProps::led_count - 2) + if (i == KeyboardLEDDriverProps::led_count - 2) { isLEDChangedNeuron |= !(neuronLED.r == crgb.r && neuronLED.g == crgb.g && neuronLED.b == crgb.b && neuronLED.w == crgb.w); neuronLED = crgb; @@ -447,14 +447,14 @@ void DefyLEDDriver::setCrgbAt(uint8_t i, cRGB crgb) uint8_t sled_num = led_map[i]; if (sled_num < LEDS_PER_HAND) { - cRGB oldColor = DefyHands::leftHand.led_data.leds[sled_num]; - DefyHands::leftHand.led_data.leds[sled_num] = crgb; + cRGB oldColor = KeyboardHands::leftHand.led_data.leds[sled_num]; + KeyboardHands::leftHand.led_data.leds[sled_num] = crgb; isLEDChangedLeft[uint8_t(sled_num / 8)] |= !(oldColor.r == crgb.r && oldColor.g == crgb.g && oldColor.b == crgb.b && oldColor.w == crgb.w); } else if (sled_num < 2 * LEDS_PER_HAND) { - cRGB oldColor = DefyHands::rightHand.led_data.leds[sled_num - LEDS_PER_HAND]; - DefyHands::rightHand.led_data.leds[sled_num - LEDS_PER_HAND] = crgb; + cRGB oldColor = KeyboardHands::rightHand.led_data.leds[sled_num - LEDS_PER_HAND]; + KeyboardHands::rightHand.led_data.leds[sled_num - LEDS_PER_HAND] = crgb; isLEDChangedRight[uint8_t((sled_num - LEDS_PER_HAND) / 8)] |= !(oldColor.r == crgb.r && oldColor.g == crgb.g && oldColor.b == crgb.b && oldColor.w == crgb.w); } @@ -471,18 +471,18 @@ void DefyLEDDriver::setCrgbAt(uint8_t i, cRGB crgb) // neuronLED = crgb; // } -cRGB DefyLEDDriver::getCrgbAt(uint8_t i) +cRGB KeyboardLEDDriver::getCrgbAt(uint8_t i) { - if (i >= DefyLEDDriverProps::led_count) return {0, 0, 0}; + if (i >= KeyboardLEDDriverProps::led_count) return {0, 0, 0}; uint8_t sled_num = led_map[i]; if (sled_num < LEDS_PER_HAND) { - return DefyHands::leftHand.led_data.leds[sled_num]; + return KeyboardHands::leftHand.led_data.leds[sled_num]; } else if (sled_num < 2 * LEDS_PER_HAND) { - return DefyHands::rightHand.led_data.leds[sled_num - LEDS_PER_HAND]; + return KeyboardHands::rightHand.led_data.leds[sled_num - LEDS_PER_HAND]; } else { @@ -490,7 +490,7 @@ cRGB DefyLEDDriver::getCrgbAt(uint8_t i) } } -void DefyLEDDriver::setup() +void KeyboardLEDDriver::setup() { // arduino zero analogWrite(255) isn't fully on as its actually working with a // 16bit counter and the mapping is a bit shift. @@ -502,36 +502,36 @@ void DefyLEDDriver::setup() /********* Key scanner *********/ -defy_wireless::key_data DefyKeyScanner::leftHandState; -defy_wireless::key_data DefyKeyScanner::rightHandState; -defy_wireless::key_data DefyKeyScanner::previousLeftHandState; -defy_wireless::key_data DefyKeyScanner::previousRightHandState; -defy_wireless::key_data DefyKeyScanner::leftHandMask; -defy_wireless::key_data DefyKeyScanner::rightHandMask; +dygma_keyboards::key_data KeyboardKeyScanner::leftHandState; +dygma_keyboards::key_data KeyboardKeyScanner::rightHandState; +dygma_keyboards::key_data KeyboardKeyScanner::previousLeftHandState; +dygma_keyboards::key_data KeyboardKeyScanner::previousRightHandState; +dygma_keyboards::key_data KeyboardKeyScanner::leftHandMask; +dygma_keyboards::key_data KeyboardKeyScanner::rightHandMask; -void DefyKeyScanner::scanMatrix() +void KeyboardKeyScanner::scanMatrix() { usbConnectionsStateMachine(); readMatrix(); actOnMatrixScan(); } -void DefyKeyScanner::readMatrix() +void KeyboardKeyScanner::readMatrix() { previousLeftHandState = leftHandState; previousRightHandState = rightHandState; - if (DefyHands::leftHand.newKey()) + if (KeyboardHands::leftHand.newKey()) { - leftHandState = DefyHands::leftHand.getKeyData(); + leftHandState = KeyboardHands::leftHand.getKeyData(); } - if (DefyHands::rightHand.newKey()) + if (KeyboardHands::rightHand.newKey()) { - rightHandState = DefyHands::rightHand.getKeyData(); + rightHandState = KeyboardHands::rightHand.getKeyData(); } } -void DefyKeyScanner::actOnMatrixScan() +void KeyboardKeyScanner::actOnMatrixScan() { for (uint8_t row = 0; row < Props_::matrix_rows; row++) { @@ -578,7 +578,7 @@ void DefyKeyScanner::actOnMatrixScan() } } -void DefyKeyScanner::maskKey(KeyAddr key_addr) +void KeyboardKeyScanner::maskKey(KeyAddr key_addr) { if (!key_addr.isValid()) return; @@ -595,7 +595,7 @@ void DefyKeyScanner::maskKey(KeyAddr key_addr) } } -void DefyKeyScanner::unMaskKey(KeyAddr key_addr) +void KeyboardKeyScanner::unMaskKey(KeyAddr key_addr) { if (!key_addr.isValid()) return; @@ -612,7 +612,7 @@ void DefyKeyScanner::unMaskKey(KeyAddr key_addr) } } -bool DefyKeyScanner::isKeyMasked(KeyAddr key_addr) +bool KeyboardKeyScanner::isKeyMasked(KeyAddr key_addr) { if (!key_addr.isValid()) return false; @@ -629,13 +629,13 @@ bool DefyKeyScanner::isKeyMasked(KeyAddr key_addr) } } -void DefyKeyScanner::maskHeldKeys() +void KeyboardKeyScanner::maskHeldKeys() { memcpy(leftHandMask.rows, leftHandState.rows, sizeof(leftHandMask)); memcpy(rightHandMask.rows, rightHandState.rows, sizeof(rightHandMask)); } -bool DefyKeyScanner::isKeyswitchPressed(KeyAddr key_addr) +bool KeyboardKeyScanner::isKeyswitchPressed(KeyAddr key_addr) { auto row = key_addr.row(); auto col = key_addr.col(); @@ -650,7 +650,7 @@ bool DefyKeyScanner::isKeyswitchPressed(KeyAddr key_addr) } } -bool DefyKeyScanner::wasKeyswitchPressed(KeyAddr key_addr) +bool KeyboardKeyScanner::wasKeyswitchPressed(KeyAddr key_addr) { auto row = key_addr.row(); auto col = key_addr.col(); @@ -665,17 +665,17 @@ bool DefyKeyScanner::wasKeyswitchPressed(KeyAddr key_addr) } } -uint8_t DefyKeyScanner::pressedKeyswitchCount() +uint8_t KeyboardKeyScanner::pressedKeyswitchCount() { return __builtin_popcountll(leftHandState.all) + __builtin_popcountll(rightHandState.all); } -uint8_t DefyKeyScanner::previousPressedKeyswitchCount() +uint8_t KeyboardKeyScanner::previousPressedKeyswitchCount() { return __builtin_popcountll(previousLeftHandState.all) + __builtin_popcountll(previousRightHandState.all); } -void DefyKeyScanner::setup() +void KeyboardKeyScanner::setup() { static constexpr uint8_t keyscanner_pins[] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42}; @@ -687,7 +687,7 @@ void DefyKeyScanner::setup() } } -void DefyKeyScanner::reset(void) +void KeyboardKeyScanner::reset(void) { leftHandState.all = 0; rightHandState.all = 0; @@ -695,7 +695,7 @@ void DefyKeyScanner::reset(void) Runtime.hid().keyboard().sendReport(); } -Communications_protocol::Devices DefyKeyScanner::leftHandDevice(void) +Communications_protocol::Devices KeyboardKeyScanner::leftHandDevice(void) { for (const auto &connection : leftConnection) { @@ -708,7 +708,7 @@ Communications_protocol::Devices DefyKeyScanner::leftHandDevice(void) return UNKNOWN; } -Communications_protocol::Devices DefyKeyScanner::rightHandDevice(void) +Communications_protocol::Devices KeyboardKeyScanner::rightHandDevice(void) { for (const auto &connection : rightConnection) { @@ -721,7 +721,7 @@ Communications_protocol::Devices DefyKeyScanner::rightHandDevice(void) return UNKNOWN; } -void DefyKeyScanner::usbConnectionsStateMachine() +void KeyboardKeyScanner::usbConnectionsStateMachine() { uint32_t actualTime = millis(); bool usbMounted = TinyUSBDevice.mounted(); @@ -770,7 +770,7 @@ void DefyKeyScanner::usbConnectionsStateMachine() rightConnection[1] = BLE_DEFY_RIGHT; } - DefyHands::sendPacketBrightness(); + KeyboardHands::sendPacketBrightness(); _BleManager.setForceBle(false); @@ -790,19 +790,19 @@ void DefyKeyScanner::usbConnectionsStateMachine() } } -bool DefyKeyScanner::rightSideWiredConnection() +bool KeyboardKeyScanner::rightSideWiredConnection() { return nrf_gpio_pin_read(SIDE_NRESET_2); } -bool DefyKeyScanner::leftSideWiredConnection() +bool KeyboardKeyScanner::leftSideWiredConnection() { return nrf_gpio_pin_read(SIDE_NRESET_1); } -/********* DefyNrf class (Hardware plugin) *********/ +/********* KeyboardNrf class (Hardware plugin) *********/ -void DefyNrf::setup() +void KeyboardNrf::setup() { // Check if we can live without this reset sides nrf_gpio_cfg_input(SIDE_NRESET_1, NRF_GPIO_PIN_NOPULL); @@ -811,44 +811,44 @@ void DefyNrf::setup() status_leds.init(); status_leds.static_green(NEURON_LED_BRIGHTNESS); - DefyHands::setup(); - DefyFocus.init(); + KeyboardHands::setup(); + KeyboardFocus.init(); KeyScanner::setup(); LEDDriver::setup(); } -void DefyLEDDriver::setCrgbNeuron(cRGB crgb) +void KeyboardLEDDriver::setCrgbNeuron(cRGB crgb) { isLEDChangedNeuron |= !(neuronLED.r == crgb.r && neuronLED.g == crgb.g && neuronLED.b == crgb.b && neuronLED.w == crgb.w); neuronLED = crgb; } -uint8_t DefyNrf::side::getPower() +uint8_t KeyboardNrf::side::getPower() { - return DefyHands::getSidePower(); + return KeyboardHands::getSidePower(); } -void DefyNrf::side::setPower(uint8_t power) +void KeyboardNrf::side::setPower(uint8_t power) { - DefyHands::setSidePower(power); + KeyboardHands::setSidePower(power); } -uint8_t DefyNrf::side::leftVersion() +uint8_t KeyboardNrf::side::leftVersion() { // TODO: Versions of keyscanner return 0; - // return DefyHands::hand_spi1.readVersion(); + // return KeyboardHands::hand_spi1.readVersion(); } -uint8_t DefyNrf::side::rightVersion() +uint8_t KeyboardNrf::side::rightVersion() { // TODO: Versions of keyscanner return 0; - // return DefyHands::hand_spi2.readVersion(); + // return KeyboardHands::hand_spi2.readVersion(); } -void DefyNrf::side::reset_sides() +void KeyboardNrf::side::reset_sides() { nrf_gpio_cfg_output(SIDE_NRESET_1); nrf_gpio_cfg_output(SIDE_NRESET_2); @@ -860,29 +860,29 @@ void DefyNrf::side::reset_sides() delay(50); // We should give a bit more time but for now lest leave it like this } -void DefyNrf::side::prepareForFlash() +void KeyboardNrf::side::prepareForFlash() { Wire::begin(100); } -uint16_t DefyNrf::settings::keyscanInterval() +uint16_t KeyboardNrf::settings::keyscanInterval() { - return DefyHands::keyscanInterval(); + return KeyboardHands::keyscanInterval(); } -void DefyNrf::settings::getChipID(char *buff, uint16_t len) +void KeyboardNrf::settings::getChipID(char *buff, uint16_t len) { - DefyHands::getChipID(buff, len); + KeyboardHands::getChipID(buff, len); } -void DefyNrf::settings::get_chip_info(char *buff, uint16_t len) +void KeyboardNrf::settings::get_chip_info(char *buff, uint16_t len) { - DefyHands::get_chip_info(buff, len); + KeyboardHands::get_chip_info(buff, len); } -void DefyNrf::settings::keyscanInterval(uint16_t interval) +void KeyboardNrf::settings::keyscanInterval(uint16_t interval) { - DefyHands::keyscanInterval(interval); + KeyboardHands::keyscanInterval(interval); } } // namespace dygma diff --git a/src/kaleidoscope/device/dygma/defy_wireless/Focus.cpp b/src/kaleidoscope/device/dygma/keyboards/Focus.cpp similarity index 95% rename from src/kaleidoscope/device/dygma/defy_wireless/Focus.cpp rename to src/kaleidoscope/device/dygma/keyboards/Focus.cpp index 44fc1af..abdb171 100644 --- a/src/kaleidoscope/device/dygma/defy_wireless/Focus.cpp +++ b/src/kaleidoscope/device/dygma/keyboards/Focus.cpp @@ -19,13 +19,13 @@ #include "kaleidoscope/Runtime.h" #include -#include "kaleidoscope/device/dygma/defy_wireless/Focus.h" +#include "kaleidoscope/device/dygma/keyboards/Focus.h" #include "Communications.h" namespace kaleidoscope { namespace device { namespace dygma { -namespace defy_wireless { +namespace dygma_keyboards { EventHandlerResult Focus::onFocusEvent(const char *command) { if (::Focus.handleHelp(command, @@ -67,7 +67,7 @@ EventHandlerResult Focus::onFocusEvent(const char *command) { if (strcmp(command + 9, "firmware") == 0) { NRF_LOG_DEBUG("read request: hardware.firmware"); - ::Focus.send(DEFY_NEURON_FW_VERSION); + ::Focus.send(KEYBOARD_NEURON_FW_VERSION); return EventHandlerResult::EVENT_CONSUMED; } @@ -141,10 +141,10 @@ EventHandlerResult Focus::onFocusEvent(const char *command) { void Focus::init() { } -} // namespace defy_wireless +} // namespace dygma_keyboards } // namespace dygma } // namespace device } // namespace kaleidoscope -kaleidoscope::device::dygma::defy_wireless::Focus DefyFocus; +kaleidoscope::device::dygma::dygma_keyboards::Focus KeyboardFocus; #endif diff --git a/src/kaleidoscope/device/dygma/defy_wireless/Focus.h b/src/kaleidoscope/device/dygma/keyboards/Focus.h similarity index 89% rename from src/kaleidoscope/device/dygma/defy_wireless/Focus.h rename to src/kaleidoscope/device/dygma/keyboards/Focus.h index 3e7ea69..d2f27e9 100644 --- a/src/kaleidoscope/device/dygma/defy_wireless/Focus.h +++ b/src/kaleidoscope/device/dygma/keyboards/Focus.h @@ -24,7 +24,7 @@ namespace kaleidoscope { namespace device { namespace dygma { -namespace defy_wireless { +namespace dygma_keyboards { class Focus : public kaleidoscope::Plugin { public: @@ -32,10 +32,10 @@ class Focus : public kaleidoscope::Plugin { EventHandlerResult onFocusEvent(const char *command); }; -} // namespace defy_wireless +} // namespace dygma_keyboards } // namespace dygma } // namespace device } // namespace kaleidoscope -extern kaleidoscope::device::dygma::defy_wireless::Focus DefyFocus; +extern kaleidoscope::device::dygma::dygma_keyboards::Focus KeyboardFocus; #endif \ No newline at end of file diff --git a/src/kaleidoscope/device/dygma/defy_wireless/Hand.cpp b/src/kaleidoscope/device/dygma/keyboards/Hand.cpp similarity index 95% rename from src/kaleidoscope/device/dygma/defy_wireless/Hand.cpp rename to src/kaleidoscope/device/dygma/keyboards/Hand.cpp index 76d90a3..0660bf5 100644 --- a/src/kaleidoscope/device/dygma/defy_wireless/Hand.cpp +++ b/src/kaleidoscope/device/dygma/keyboards/Hand.cpp @@ -1,7 +1,7 @@ #ifdef ARDUINO_ARCH_NRF52 #include "Hand.h" -#include "Defy_wireless.h" +#include DYGMA_KEYBOARD #include #ifdef __cplusplus @@ -22,7 +22,7 @@ namespace device { namespace dygma { -namespace defy_wireless +namespace dygma_keyboards { Hand::Hand(HandSide side) : this_device_(side) @@ -70,7 +70,7 @@ void Hand::releaseAllKeys() } -} // namespace defy_wireless +} // namespace dygma_keyboards } // namespace dygma } // namespace device } // namespace kaleidoscope diff --git a/src/kaleidoscope/device/dygma/defy_wireless/Hand.h b/src/kaleidoscope/device/dygma/keyboards/Hand.h similarity index 94% rename from src/kaleidoscope/device/dygma/defy_wireless/Hand.h rename to src/kaleidoscope/device/dygma/keyboards/Hand.h index 0e1c979..6a1d699 100644 --- a/src/kaleidoscope/device/dygma/defy_wireless/Hand.h +++ b/src/kaleidoscope/device/dygma/keyboards/Hand.h @@ -32,7 +32,7 @@ struct cRGB { namespace kaleidoscope { namespace device { namespace dygma { -namespace defy_wireless { +namespace dygma_keyboards { #define LED_BANKS 11 @@ -66,7 +66,7 @@ class Hand { LEDData_t led_data{}; private: - defy_wireless::key_data key_data_{}; + dygma_keyboards::key_data key_data_{}; bool new_key_; public: @@ -80,7 +80,7 @@ class Hand { [[nodiscard]] bool newKey() const { return new_key_; } }; -} // namespace defy_wireless +} // namespace dygma_keyboards } // namespace dygma } // namespace device } // namespace kaleidoscope diff --git a/src/kaleidoscope/device/dygma/defy_wireless/SideFlash.h b/src/kaleidoscope/device/dygma/keyboards/SideFlash.h similarity index 98% rename from src/kaleidoscope/device/dygma/defy_wireless/SideFlash.h rename to src/kaleidoscope/device/dygma/keyboards/SideFlash.h index 90a1df5..13eb28e 100644 --- a/src/kaleidoscope/device/dygma/defy_wireless/SideFlash.h +++ b/src/kaleidoscope/device/dygma/keyboards/SideFlash.h @@ -24,7 +24,7 @@ namespace kaleidoscope { namespace device { namespace dygma { -namespace defy_wireless { +namespace dygma_keyboards { template class SideFlash : public kaleidoscope::Plugin { diff --git a/src/kaleidoscope/device/dygma/defy_wireless/TWI.cpp b/src/kaleidoscope/device/dygma/keyboards/TWI.cpp similarity index 99% rename from src/kaleidoscope/device/dygma/defy_wireless/TWI.cpp rename to src/kaleidoscope/device/dygma/keyboards/TWI.cpp index 61f54c4..561e014 100644 --- a/src/kaleidoscope/device/dygma/defy_wireless/TWI.cpp +++ b/src/kaleidoscope/device/dygma/keyboards/TWI.cpp @@ -26,7 +26,7 @@ Twi_master twi_master(TWI_SCL_PIN, TWI_SDA_PIN); namespace kaleidoscope { namespace device { namespace dygma { -namespace defy_wireless { +namespace dygma_keyboards { bool TWI::twi_already_init = false; diff --git a/src/kaleidoscope/device/dygma/defy_wireless/TWI.h b/src/kaleidoscope/device/dygma/keyboards/TWI.h similarity index 98% rename from src/kaleidoscope/device/dygma/defy_wireless/TWI.h rename to src/kaleidoscope/device/dygma/keyboards/TWI.h index c10f532..6c26da6 100644 --- a/src/kaleidoscope/device/dygma/defy_wireless/TWI.h +++ b/src/kaleidoscope/device/dygma/keyboards/TWI.h @@ -41,7 +41,7 @@ namespace kaleidoscope { namespace device { namespace dygma { -namespace defy_wireless { +namespace dygma_keyboards { class TWI { diff --git a/src/kaleidoscope/device/dygma/defy_wireless/bootloader_util.cpp b/src/kaleidoscope/device/dygma/keyboards/bootloader_util.cpp similarity index 100% rename from src/kaleidoscope/device/dygma/defy_wireless/bootloader_util.cpp rename to src/kaleidoscope/device/dygma/keyboards/bootloader_util.cpp diff --git a/src/kaleidoscope/device/dygma/defy_wireless/bootloader_util.h b/src/kaleidoscope/device/dygma/keyboards/bootloader_util.h similarity index 100% rename from src/kaleidoscope/device/dygma/defy_wireless/bootloader_util.h rename to src/kaleidoscope/device/dygma/keyboards/bootloader_util.h