Add Support for SofleV2

Added support for SofleV2 using the SparkFun Pro Micro RP2040
This commit is contained in:
ldsands 2022-04-05 14:07:21 -05:00 committed by Kyle Brown
parent 7b92596937
commit cc82433f74
3 changed files with 110 additions and 0 deletions

View File

@ -0,0 +1,24 @@
# Sofle V2
![Sofle V2](https://github.com/josefadamcik/SofleKeyboard)
"Sofle is 6×4+5 keys column-staggered split keyboard with encoder support. Based on Lily58, Corne and Helix keyboards."
Hardware Availability: [PCB & Case Source](https://github.com/josefadamcik/SofleKeyboard)
`kb.py` is designed to work with the [SparkFun Pro Micro RP2040](https://www.sparkfun.com/products/18288).
Retailers
[beekeeb (Hong Kong)](https://shop.beekeeb.com/product/sofle-v2-soflekeyboard-v2-0-1-split-ergonomic-diy-mechanical-keyboard-pcb-kit/)
[Ergomech Store (Vietnam)](https://ergomech.store/shop/product/sofle-v2-2#attr=5,23)
Extentions enabled by default
- [Layers](https://github.com/KMKfw/kmk_firmware/blob/master/docs/layers.md) "Layers module adds keys for accessing other layers."
- [Split](https://github.com/KMKfw/kmk_firmware/blob/master/docs/split_keyboards.md) Connects halves with or without wires (currently uses wires)
- You must add the `adafruit_pioasm.mpy` to the `lib` folder on the RP2040 for this code to work. More about this is described [here](https://github.com/KMKfw/kmk_firmware/blob/master/docs/split_keyboards.md#rp2040-pio-implementation).
- [Encoder](https://github.com/KMKfw/kmk_firmware/blob/master/docs/encoder.md) "Add twist control to your keyboard!"
## Notes
- As of 2022-04-05: Only one encoder will work at the moment. The side that is plugged in will work and the way I wrote it is designed to work with the left plugged in. If the right is plugged in the encoder will work but the encoder will work backwards.
- It is possible that the KMK code used for the Sofle V2 could be used on the Sofle V1 or the Sofle RGB or the Sofle Choc. These would each need to be tested to see if they work.

View File

@ -0,0 +1,19 @@
import board
from kmk.kmk_keyboard import KMKKeyboard as _KMKKeyboard
from kmk.matrix import DiodeOrientation
class KMKKeyboard(_KMKKeyboard):
col_pins = (board.A1, board.A0, board.SCK, board.MISO, board.MOSI, board.D21)
row_pins = (board.D5, board.D6, board.D7, board.D8, board.D9)
diode_orientation = DiodeOrientation.COL2ROW
encoder_pin_0 = board.A2
encoder_pin_1 = board.A3
# i2c = board.I2C
coord_mapping = [
0, 1, 2, 3, 4, 5, 35, 34, 33, 32, 31, 30,
6, 7, 8, 9, 10, 11, 41, 40, 39, 38, 37, 36,
12, 13, 14, 15, 16, 17, 47, 46, 45, 44, 43, 42,
18, 19, 20, 21, 22, 23, 53, 52, 51, 50, 49, 48,
24, 25, 26, 27, 28, 29, 59, 58, 57, 56, 55, 54
]

View File

@ -0,0 +1,67 @@
import board
from kb import KMKKeyboard
from kmk.keys import KC
from kmk.modules.encoder import EncoderHandler
from kmk.modules.layers import Layers
from kmk.modules.split import Split, SplitType
keyboard = KMKKeyboard()
layers_ext = Layers()
split = Split(
split_flip=True, # If both halves are the same, but flipped, set this True
split_type=SplitType.UART, # Defaults to UART
uart_interval=20, # Sets the uarts delay. Lower numbers draw more power
data_pin=board.RX, # The primary data pin to talk to the secondary device with
data_pin2=board.TX, # Second uart pin to allow 2 way communication
use_pio=True, # allows for UART to be used with PIO
)
keyboard.modules = [layers_ext, split]
# Cleaner key names
XXXXXXX = KC.NO
LOWER = KC.MO(1)
RAISE = KC.MO(2)
keyboard.keymap = [
[ #QWERTY
#HERE-----#HERE-----#HERE-----#HERE-----#HERE-----#HERE-----#HERE-----#ENCODER--#ENCODER--#HERE-----#HERE-----#HERE-----#HERE-----#HERE-----#HERE-----#HERE-----
KC.ESC, KC.N1, KC.N2, KC.N3, KC.N4, KC.N5, KC.N6, KC.N7, KC.N8, KC.N9, KC.N0, KC.BSPC,
KC.TAB, KC.Q, KC.W, KC.E, KC.R, KC.T, KC.Y, KC.U, KC.I, KC.O, KC.P, KC.BSLS,
KC.LCTL, KC.A, KC.S, KC.D, KC.F, KC.G, KC.H, KC.J, KC.K, KC.L, KC.SCLN, KC.QUOT,
KC.LSFT, KC.Z, KC.X, KC.C, KC.V, KC.B, KC.N, KC.M, KC.COMM, KC.DOT, KC.SLSH, KC.RSFT,
KC.LGUI, KC.LALT, KC.LCTL, LOWER, KC.ENT, KC.MUTE, KC.MPLY, KC.SPC, RAISE, KC.RCTL, KC.RALT, KC.RCMD,
],
[ #LOWER
#HERE-----#HERE-----#HERE-----#HERE-----#HERE-----#HERE-----#HERE-----#ENCODER--#ENCODER--#HERE-----#HERE-----#HERE-----#HERE-----#HERE-----#HERE-----#HERE-----
KC.ESC, KC.F1, KC.F2, KC.F3, KC.F4, KC.F5, KC.F6, KC.F7, KC.F8, KC.F9, KC.F10, KC.F11,
XXXXXXX, KC.N1, KC.N2, KC.N3, KC.N4, KC.N5, KC.N6, KC.N7, KC.N8, KC.N9, KC.N0, KC.F12,
KC.LCTL, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC.LEFT, KC.DOWN, KC.UP, KC.RIGHT, XXXXXXX, XXXXXXX,
KC.LSFT, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
KC.LGUI, KC.LALT, KC.LCTL, LOWER, KC.ENT, XXXXXXX, XXXXXXX, KC.SPC, RAISE, KC.RCTL, KC.RALT, KC.RCMD,
],
[ #RAISE
#HERE-----#HERE-----#HERE-----#HERE-----#HERE-----#HERE-----#HERE-----#ENCODER--#ENCODER--#HERE-----#HERE-----#HERE-----#HERE-----#HERE-----#HERE-----#HERE-----
KC.ESC, KC.EXLM, KC.AT, KC.HASH, KC.DLR, KC.PERC, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC.BSPC,
XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC.CIRC, KC.AMPR, KC.ASTR, KC.LPRN, KC.RPRN, KC.BSLS,
XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC.MINS, KC.EQL, KC.LBRC, KC.RBRC, KC.PIPE, XXXXXXX,
XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC.UNDS, KC.PLUS, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
KC.LGUI, KC.LALT, KC.LCTL, LOWER, KC.ENT, KC.MUTE, XXXXXXX, KC.SPC, RAISE, KC.RCTL, KC.RALT, KC.RCMD,
]
]
encoder_handler = EncoderHandler()
encoder_handler.pins = ((keyboard.encoder_pin_1, keyboard.encoder_pin_0, None, False),)
encoder_handler.map = (
((KC.VOLD, KC.VOLU),), # base layer
((KC.VOLD, KC.VOLU),), # Raise
((KC.VOLD, KC.VOLU),), # Lower
)
keyboard.modules.append(encoder_handler)
if __name__ == "__main__":
keyboard.go()