From 8d1ab15367393fc46069f2d193ac4fbcf851903a Mon Sep 17 00:00:00 2001 From: noteolvides Date: Tue, 24 Oct 2023 13:15:01 +0200 Subject: [PATCH] fix: adde connection for defy wn Signed-off-by: noteolvides --- src/kaleidoscope/device/dygma/DefyWN.cpp | 37 ++++++++++++++++++++++++ src/kaleidoscope/device/dygma/DefyWN.h | 7 +++++ 2 files changed, 44 insertions(+) diff --git a/src/kaleidoscope/device/dygma/DefyWN.cpp b/src/kaleidoscope/device/dygma/DefyWN.cpp index 1ab94af..deac1e6 100644 --- a/src/kaleidoscope/device/dygma/DefyWN.cpp +++ b/src/kaleidoscope/device/dygma/DefyWN.cpp @@ -85,8 +85,33 @@ class Hands { inline static uint16_t settings_base_; }; +Communications_protocol::Devices leftConnection[1]{UNKNOWN}; +Communications_protocol::Devices rightConnection[1]{UNKNOWN}; + +auto checkBrightness = [](const Packet &) +{ + ColormapEffectDefy.updateBrigthness(true); +}; void Hands::setup() { + + Communications.callbacks.bind(CONNECTED, ( + [](const Packet &p) + { + if (p.header.device == KEYSCANNER_DEFY_LEFT) leftConnection[0] = KEYSCANNER_DEFY_LEFT; + if (p.header.device == KEYSCANNER_DEFY_RIGHT) leftConnection[0] = KEYSCANNER_DEFY_RIGHT; + })); + Communications.callbacks.bind(DISCONNECTED, ( + [](const Packet &p){ + if (p.header.device == KEYSCANNER_DEFY_LEFT) leftConnection[0] = UNKNOWN; + if (p.header.device == KEYSCANNER_DEFY_RIGHT) rightConnection[0] = UNKNOWN; + })); + + Communications.callbacks.bind(DISCONNECTED, checkBrightness); + Communications.callbacks.bind(CONNECTED, checkBrightness); + Communications.callbacks.bind(CONNECTED, ([](const Packet &) { ::LEDControl.set_mode(::LEDControl.get_mode_index()); })); + + settings_base_ = ::EEPROMSettings.requestSlice(sizeof(Settings)); bool edited = false; Settings settings; @@ -469,6 +494,18 @@ uint8_t DefyWN::settings::keyscanInterval() { void DefyWN::settings::keyscanInterval(uint8_t interval) { Hands::setKeyscanInterval(interval); } +int LedDriverWN::getBrightnessWireless() { + return getBrightness(); +} +uint8_t LedDriverWN::getBrightnessUGWireless() { + return getBrightnessUG(); +} +Devices KeyScannerWN::leftHandDevice() { + return leftConnection[0]; +} +Devices KeyScannerWN::rightHandDevice() { + return rightConnection[0]; +} } // namespace dygma } // namespace device } // namespace kaleidoscope diff --git a/src/kaleidoscope/device/dygma/DefyWN.h b/src/kaleidoscope/device/dygma/DefyWN.h index ea8b21f..7052fd0 100644 --- a/src/kaleidoscope/device/dygma/DefyWN.h +++ b/src/kaleidoscope/device/dygma/DefyWN.h @@ -88,6 +88,10 @@ class LedDriverWN : public kaleidoscope::driver::led::Base { static constexpr uint8_t underglow_leds = LedDriverProps::underglow_leds; static constexpr uint8_t key_matrix_leds = LedDriverProps::key_matrix_leds; + int getBrightnessWireless(); + + uint8_t getBrightnessUGWireless(); + private: inline static bool isLEDChangedNeuron; inline static bool leds_enabled_ = true; @@ -145,6 +149,8 @@ class KeyScannerWN : public kaleidoscope::driver::keyscanner::Base