Skip to content

Commit

Permalink
fix: adde connection for defy wn
Browse files Browse the repository at this point in the history
Signed-off-by: noteolvides <[email protected]>
  • Loading branch information
Noteolvides committed Oct 24, 2023
1 parent 8a61986 commit 8d1ab15
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/kaleidoscope/device/dygma/DefyWN.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions src/kaleidoscope/device/dygma/DefyWN.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ class LedDriverWN : public kaleidoscope::driver::led::Base<LedDriverProps> {
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;
Expand Down Expand Up @@ -145,6 +149,8 @@ class KeyScannerWN : public kaleidoscope::driver::keyscanner::Base<KeyScannerPro
static void scanMatrix();
static void readMatrix();
static void actOnMatrixScan();
static Communications_protocol::Devices rightHandDevice(void);
static Communications_protocol::Devices leftHandDevice(void);

static void maskKey(KeyAddr key_addr);
static void unMaskKey(KeyAddr key_addr);
Expand All @@ -167,6 +173,7 @@ class KeyScannerWN : public kaleidoscope::driver::keyscanner::Base<KeyScannerPro
inline static defyWN::key_data previousRightHandState;
inline static defyWN::key_data leftHandMask;
inline static defyWN::key_data rightHandMask;

};

struct StoragePropsWN : public kaleidoscope::driver::storage::FlashProps {
Expand Down

0 comments on commit 8d1ab15

Please sign in to comment.