Skip to content

Commit

Permalink
Merge pull request #33 from Dygmalab/gl-wired-neuron-update
Browse files Browse the repository at this point in the history
Gl wired neuron update
  • Loading branch information
ota-jaylabs authored Dec 18, 2024
2 parents 6133386 + ee10157 commit 0432561
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 37 deletions.
2 changes: 1 addition & 1 deletion src/Kaleidoscope-Hardware-Dygma-DefyWN.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@

#pragma once

#include "kaleidoscope/device/dygma/DefyWN.h"
#include "kaleidoscope/device/dygma/defyWN/DefyWN.h"
33 changes: 12 additions & 21 deletions src/kaleidoscope/device/dygma/defyWN/DefyWN.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,9 @@
#include "DefyWN.h"
#include "Colormap-Defy.h"
#include "Communications_protocol.h"
#include "kaleidoscope/device/dygma/defyWN/Hand.h"

#define I2C_SDA_PIN 26 // SWe 20220719: I2C1 data out-/in-put, MASTER role
#define I2C_SCL_PIN 27 // SWe 20220719: I2C1 clock output, MASTER role
#define WIRE_ Wire1
#define I2C_CLOCK_KHZ 100
#define I2C_FLASH_CLOCK_KHZ 100 // flashing doesn't work reliably at higher clock speeds
//#define SIDE_POWER 1 // side power switch pa10; SWe 20220719: old, used in Neuron
#define SIDE_nRESET_1 22 //19 // SWe 20220719: nRESET signal OUT to keyboard side 1; HIGH = running, LOW = reset
#define SIDE_nRESET_2 10 //12 // SWe 20220719: nRESET signal OUT to keyboard side 2; HIGH = running, LOW = reset
#define nPWR_OK 1 // SWe 20220719: Power nOK IN-PULLUP from the 3.3V LDO, open drain, needs internal pull-up. NOTE: this is not implemented in the Development Board, only in the real WIRED Neuron2.
// SWe 20220719: LED pins
#define RGBW_LED_RED 6 // SWe 20220719: RED RGBW led OUT, PWM3 A can be used to control its intensity
#define RGBW_LED_GREEN 0 // SWe 20220719: GREEN RGBW led OUT, PWM0 A can be used to control its intensity
#define RGBW_LED_BLUE 2 // SWe 20220719: BLUE RGBW led OUT, PWM1 A can be used to control its intensity
#define RGBW_LED_WHITE 4 // SWe 20220719: WHITE RGBW led OUT, PWM2 A can be used to control its intensity
// SWe 20220719: analog pins
#define USB_CC1 28 // SWe 20220719: USB CC1 pin, can be used to check how much power the host does support by checking its analog value
#define USB_CC2 29 // SWe 20220719: USB CC2 pin, can be used to check how much power the host does support by checking its analog value
// SWe 20220719: ADC Vref input, tied to 3.3V with resistor and capacitor for filtering and buffering
// SWe 20220719: optional pins
#include "kaleidoscope/device/dygma/defyWN/universalModules/Hand.h"

#include "common.h"

namespace kaleidoscope {
namespace device {
Expand Down Expand Up @@ -515,6 +497,15 @@ Devices KeyScannerWN::leftHandDevice() {
Devices KeyScannerWN::rightHandDevice() {
return rightConnection[0];
}

bool KeyScannerWN::rightSideWiredConnection() {
return gpio_get(SIDE_nRESET_2);
}

bool KeyScannerWN::leftSideWiredConnection(){
return gpio_get(SIDE_nRESET_1);
}

} // namespace dygma
} // namespace device
} // namespace kaleidoscope
Expand Down
48 changes: 38 additions & 10 deletions src/kaleidoscope/device/dygma/defyWN/DefyWN.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,9 @@

#ifdef ARDUINO_RASPBERRY_PI_PICO

#ifndef FIRMWARE_VERSION
#define FIRMWARE_VERSION "v1.1.0"
#endif

#define WIRED_FIRMWARE_VERSION FIRMWARE_VERSION

#include <Arduino.h>
#include <string>
#include "kaleidoscope/device/dygma/defyWN/Hand.h"
#include "universalModules/Hand.h"

#define CRGB(r, g, b) \
(cRGB) { \
Expand All @@ -40,6 +34,14 @@
b, g, r, w \
}

// LED definitions
#define KEY_MATRIX_LEDS 35
#define UNDERGLOW_LEDS_LEFT_SIDE 53
#define LEDS_HAND_LEFT 35
#define UNDERGLOW_LEDS_RIGHT_SIDE 53
#define LEDS_HAND_RIGHT 35
#define NEURON_LED 2

#include "kaleidoscope/driver/keyscanner/Base.h"
#include "kaleidoscope/driver/led/Base.h"
#include "kaleidoscope/driver/storage/Flash.h"
Expand All @@ -53,12 +55,30 @@ namespace device::dygma {
using kaleidoscope::driver::led::no_led;

struct LedDriverProps : public kaleidoscope::driver::led::BaseProps {
/*
static constexpr uint8_t underglow_leds = 53;
static constexpr uint8_t key_matrix_leds = 35;
static constexpr uint8_t leds_hand = underglow_leds + key_matrix_leds;
static constexpr uint8_t led_count = leds_hand * 2 + 2; //178 This has to be par number that's why the neuron takes 2
*/

// clang-format off

static constexpr uint8_t key_matrix_leds = KEY_MATRIX_LEDS; // Per keyboard side. ANSI only.

static constexpr uint8_t underglow_leds_leftSide = UNDERGLOW_LEDS_LEFT_SIDE; //UG Left side.
static constexpr uint8_t leds_hand_left = LEDS_HAND_LEFT; // BL Left side

static constexpr uint8_t underglow_leds_rightSide = UNDERGLOW_LEDS_RIGHT_SIDE; // UG Right side.
static constexpr uint8_t leds_hand_right = LEDS_HAND_RIGHT; // BL Right side.

static constexpr uint8_t neuron_led = NEURON_LED;

static constexpr uint8_t leds_hand = underglow_leds_rightSide + underglow_leds_leftSide + leds_hand_right + leds_hand_left;

static constexpr uint8_t led_count = leds_hand + neuron_led; //This number needs to be par so Neuron takes two LEDs


// clang-format off
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 + key_matrix_leds, 5 + key_matrix_leds, 4 + key_matrix_leds, 3 + key_matrix_leds, 2 + key_matrix_leds, 1 + key_matrix_leds, 0 + key_matrix_leds,
Expand All @@ -85,8 +105,12 @@ class LedDriverWN : public kaleidoscope::driver::led::Base<LedDriverProps> {

static void updateNeuronLED();

static constexpr uint8_t underglow_leds = LedDriverProps::underglow_leds;
static constexpr uint8_t key_matrix_leds = LedDriverProps::key_matrix_leds;
/* static constexpr uint8_t underglow_leds = LedDriverProps::underglow_leds;
static constexpr uint8_t key_matrix_leds = LedDriverProps::key_matrix_leds;*/
static constexpr uint8_t underglow_leds = LedDriverProps::underglow_leds_leftSide;
static constexpr uint8_t key_matrix_left = LedDriverProps::leds_hand_left;
static constexpr uint8_t key_matrix_right = LedDriverProps::leds_hand_right;
static constexpr uint8_t underglow_leds_right = LedDriverProps::underglow_leds_rightSide;

int getBrightnessWireless();

Expand Down Expand Up @@ -167,6 +191,10 @@ class KeyScannerWN : public kaleidoscope::driver::keyscanner::Base<KeyScannerPro

static void reset();

static bool leftSideWiredConnection();
static bool rightSideWiredConnection();


inline static defyWN::key_data leftHandState;
inline static defyWN::key_data rightHandState;
inline static defyWN::key_data previousLeftHandState;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ namespace device {
namespace dygma {
namespace defyWN {

#ifndef WIRED_FIRMWARE_VERSION
#define WIRED_FIRMWARE_VERSION "<unknown>"
#endif

EventHandlerResult SettingsConfigurator::onFocusEvent(const char *command) {
if (::Focus.handleHelp(command,
PSTR("hardware.version\n"
Expand All @@ -54,7 +50,7 @@ EventHandlerResult SettingsConfigurator::onFocusEvent(const char *command) {
}

if (strcmp_P(command + 9, PSTR("firmware")) == 0) {
::Focus.send(WIRED_FIRMWARE_VERSION);
::Focus.send(DEFY_FW_VERSION);
return EventHandlerResult::EVENT_CONSUMED;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
* this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifdef ARDUINO_ARCH_NRF52

#include <string.h>
#include "bootloader_util.h"
#include "nrf_dfu_types.h"
Expand Down Expand Up @@ -235,3 +237,5 @@ bool bldrUtil::update_request( void )
{
return _update_request( &bldr_settings );
}

#endif /* ARDUINO_ARCH_NRF52 */
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#ifndef __BOOTLOADER_UTIL_H_
#define __BOOTLOADER_UTIL_H_

#ifdef ARDUINO_ARCH_NRF52

#include <stdbool.h>
#include <stdint.h>

Expand All @@ -33,4 +35,6 @@ class bldrUtil
private:
};

#endif /* ARDUINO_ARCH_NRF52 */

#endif /* __BOOTLOADER_UTIL_H_ */

0 comments on commit 0432561

Please sign in to comment.