rushabhcodes/wireless-split-keyboard

Wireless Split Keyboard — custom routed nRF52840 split PCBs with a printable enclosure

Version
0.4.5
License
unset
Stars
0

Use with the tscircuit CLI

tsci is the tscircuit CLI. Install it with npm install -g tscircuit.

tsci clone rushabhcodes/wireless-split-keyboard  # download the package files into ./wireless-split-keyboard
tsci add rushabhcodes/wireless-split-keyboard    # add it to your project as @tsci/rushabhcodes.wireless-split-keyboard

In a cloned or new (tsci init) project: tsci dev starts a local preview, tsci build outputs Circuit JSON, and tsci push publishes to tscircuit.com.

firmware/boards/custom/custom_sofle/custom_sofle.dtsi

// Generated from src/pinout.ts. Application at 0: SWD only, no borrowed bootloader.
/dts-v1/;
#include <nordic/nrf52840_qiaa.dtsi>
#include <zephyr/dt-bindings/gpio/gpio.h>
#include <zephyr/dt-bindings/pinctrl/nrf-pinctrl.h>
#include <zephyr/dt-bindings/adc/adc.h>
#include <dt-bindings/zmk/matrix_transform.h>
/ {
    model = "Custom Sofle Wireless";
    compatible = "custom,sofle-wireless";
    chosen {
        zephyr,sram = &sram0;
        zephyr,flash = &flash0;
        zephyr,code-partition = &code_partition;
        zmk,kscan = &kscan0;
        zmk,matrix-transform = &default_transform;
        zmk,battery = &battery;
        zephyr,display = &lcd;
    };
    kscan0: kscan {
        compatible = "zmk,kscan-gpio-matrix";
        diode-direction = "col2row";
        row-gpios = <&gpio0 11 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>,
            <&gpio0 12 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>,
            <&gpio0 13 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>,
            <&gpio0 14 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>,
            <&gpio0 15 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>;
        col-gpios = <&gpio0 16 (GPIO_ACTIVE_HIGH)>,
            <&gpio0 17 (GPIO_ACTIVE_HIGH)>,
            <&gpio0 19 (GPIO_ACTIVE_HIGH)>,
            <&gpio0 20 (GPIO_ACTIVE_HIGH)>,
            <&gpio0 21 (GPIO_ACTIVE_HIGH)>,
            <&gpio0 22 (GPIO_ACTIVE_HIGH)>;
    };
    default_transform: matrix_transform {
        compatible = "zmk,matrix-transform";
        rows = <5>; columns = <12>;
        map = <RC(0,5) RC(0,4) RC(0,3) RC(0,2) RC(0,1) RC(0,0) RC(0,6) RC(0,7) RC(0,8) RC(0,9) RC(0,10) RC(0,11)
            RC(1,5) RC(1,4) RC(1,3) RC(1,2) RC(1,1) RC(1,0) RC(1,6) RC(1,7) RC(1,8) RC(1,9) RC(1,10) RC(1,11)
            RC(2,5) RC(2,4) RC(2,3) RC(2,2) RC(2,1) RC(2,0) RC(2,6) RC(2,7) RC(2,8) RC(2,9) RC(2,10) RC(2,11)
            RC(3,5) RC(3,4) RC(3,3) RC(3,2) RC(3,1) RC(3,0) RC(3,6) RC(3,7) RC(3,8) RC(3,9) RC(3,10) RC(3,11)
            RC(4,5) RC(4,4) RC(4,3) RC(4,2) RC(4,1) RC(4,0) RC(4,6) RC(4,7) RC(4,8) RC(4,9) RC(4,10) RC(4,11)>;
    };
    encoder_left: encoder_left {
        compatible = "alps,ec11";
        a-gpios = <&gpio0 23 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
        b-gpios = <&gpio0 24 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
        steps = <48>;
        status = "disabled";
    };
    encoder_right: encoder_right {
        compatible = "alps,ec11";
        a-gpios = <&gpio0 23 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
        b-gpios = <&gpio0 24 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
        steps = <48>;
        status = "disabled";
    };
    sensors: sensors {
        compatible = "zmk,keymap-sensors";
        sensors = <&encoder_left &encoder_right>;
        triggers-per-rotation = <24>;
    };
    battery: battery {
        compatible = "zmk,battery-voltage-divider";
        io-channels = <&adc 0>;
        output-ohms = <1000000>;
        full-ohms = <2000000>;
        power-gpios = <&gpio1 12 (GPIO_ACTIVE_HIGH)>;
    };
};
&gpio0 { status = "okay"; };
&gpio1 { status = "okay"; };
&gpiote { status = "okay"; };
&reg1 { regulator-initial-mode = <NRF5X_REG_MODE_DCDC>; };
&adc {
    status = "okay";
    #address-cells = <1>; #size-cells = <0>;
    channel@0 {
        reg = <0>; zephyr,gain = "ADC_GAIN_1_6";
        zephyr,reference = "ADC_REF_INTERNAL";
        zephyr,acquisition-time = <ADC_ACQ_TIME(ADC_ACQ_TIME_MICROSECONDS, 40)>;
        zephyr,input-positive = <NRF_SAADC_AIN2>;
        zephyr,resolution = <12>;
    };
};
&pinctrl {
    spi1_default: spi1_default { group1 {
        psels = <NRF_PSEL(SPIM_SCK,0,26)>, <NRF_PSEL(SPIM_MOSI,0,27)>;
    }; };
    spi1_sleep: spi1_sleep { group1 {
        psels = <NRF_PSEL(SPIM_SCK,0,26)>, <NRF_PSEL(SPIM_MOSI,0,27)>;
        low-power-enable;
    }; };
};
&spi1 {
    compatible = "nordic,nrf-spim"; status = "okay";
    pinctrl-0 = <&spi1_default>; pinctrl-1 = <&spi1_sleep>;
    pinctrl-names = "default", "sleep";
    cs-gpios = <&gpio1 8 (GPIO_ACTIVE_HIGH)>;
    lcd: ls011b7dh03@0 {
        compatible = "sharp,ls0xx"; reg = <0>;
        spi-max-frequency = <1000000>;
        width = <160>; height = <68>;
        extcomin-gpios = <&gpio1 10 (GPIO_ACTIVE_HIGH)>;
        extcomin-frequency = <60>;
        disp-en-gpios = <&gpio1 9 (GPIO_ACTIVE_HIGH)>;
    };
};
zephyr_udc0: &usbd { status = "okay"; };
&flash0 {
    partitions {
        compatible = "fixed-partitions";
        #address-cells = <1>; #size-cells = <1>;
        code_partition: partition@0 { reg = <0x0 0xF0000>; };
        storage_partition: partition@f0000 { reg = <0xF0000 0x10000>; };
    };
};