Add support for Piantor

This commit is contained in:
Cai Maver 2023-02-27 00:45:43 +00:00
parent 88c3616b6a
commit 4d71b65717
3 changed files with 127 additions and 0 deletions

View File

@ -0,0 +1,12 @@
# Piantor
The [Piantor, created by Leo Lou](https://github.com/beekeeb/piantor), is a 36- or 42-key staggered column, diodeless keyboard . It is based on the [Cantor by Diego Palacios](https://github.com/diepala/cantor), but uses a Raspberry Pi Pico as the controller.
The default keymap replicates the Corne/crkbd default keymap by foostan and drashna.
Purchase: [BeeKeeb](https://shop.beekeeb.com/product/piantor-keyboard-kit/)
## Microcontroller and Split Support
This firmware assumes that VBUS will be used for split side detection as in the QMK implementation. This requires that the USB cable is plugged into the left side to ensure that the correct pin mapping is used. If using a rp2040 microcontroller without a VBus sense circuit (like the WeAct RP2040), resistors must be soldered to the bottom of the PCBs, and you will need to uncomment line 9 of kb.py to assign the VBus sense pin to GP24.
An alternative option is to detect the split sides using the drive names. See the KMK documentation for setting this up. Once you have set drive names, you can comment out lines 12-14 and uncomment lines 17-18 in kb.py to enable this option.

View File

@ -0,0 +1,52 @@
import board
import digitalio
from storage import getmount
from kmk.kmk_keyboard import KMKKeyboard as _KMKKeyboard
from kmk.scanners.keypad import KeysScanner
# VBus pin config
VBUS_PIN = board.VBUS_SENSE # RPi Pico
# VBUS_PIN = board.GP29 # WeAct RP2040 + resistors on Piantor PCB
# split side detection using vbus sense
vbus = digitalio.DigitalInOut(VBUS_PIN)
vbus.direction = digitalio.Direction.INPUT
isRight = True if vbus.value == False else False
# alternate option: set side based on drive names
# name = str(getmount('/').label)
# isRight = True if name.endswith('R') else False
# GPIO to key mapping, Left
_KEY_CFG_LEFT = [
board.GP5, board.GP4, board.GP11, board.GP15, board.GP3, board.GP2,
board.GP22, board.GP20, board.GP10, board.GP14, board.GP9, board.GP8,
board.GP21, board.GP19, board.GP6, board.GP7, board.GP13, board.GP12,
board.GP17, board.GP18, board.GP16
]
# GPIO to key mapping, Left
_KEY_CFG_RIGHT = [
board.GP22, board.GP21, board.GP2, board.GP5, board.GP8, board.GP11,
board.GP20, board.GP19, board.GP3, board.GP6, board.GP9, board.GP12,
board.GP18, board.GP17, board.GP4, board.GP7, board.GP10, board.GP13,
board.GP15, board.GP14, board.GP16
]
class KMKKeyboard(_KMKKeyboard):
def __init__(self):
# create and register the scanner
self.matrix = KeysScanner(
pins = _KEY_CFG_RIGHT if isRight == True else _KEY_CFG_LEFT
)
# flake8: noqa
# fmt: off
coord_mapping = [
0, 1, 2, 3, 4, 5, 21, 22, 23, 24, 25, 26,
6, 7, 8, 9, 10, 11, 27, 28, 29, 30, 31, 32,
12, 13, 14, 15, 16, 17, 33, 34, 35, 36, 37, 38,
18, 19, 20, 39, 40, 41
]

View File

@ -0,0 +1,63 @@
import board
import digitalio
from kb import KMKKeyboard, isRight
from storage import getmount
from kmk.keys import KC
from kmk.modules.layers import Layers
from kmk.modules.split import Split, SplitSide, SplitType
keyboard = KMKKeyboard()
keyboard.tap_time = 100
layers = Layers()
split_side = SplitSide.RIGHT if isRight else SplitSide.LEFT
data_pin = board.GP1 if split_side == SplitSide.LEFT else board.GP0
data_pin2 = board.GP0 if split_side == SplitSide.LEFT else board.GP1
split = Split(
split_side=split_side,
split_type=SplitType.UART,
split_flip=False,
data_pin=data_pin,
data_pin2=data_pin2
)
keyboard.modules = [layers, split]
LOWER = KC.MO(1)
RAISE = KC.MO(2)
ADJUST = KC.LT(3, KC.SPC)
# Same as the default Corne/crkbd keymap by foostan and drashna
keyboard.keymap = [
[ #QWERTY
KC.TAB, KC.Q, KC.W, KC.E, KC.R, KC.T, KC.Y, KC.U, KC.I, KC.O, KC.P, KC.BSPC,\
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, LOWER, ADJUST, KC.ENT, RAISE, KC.RALT,
],
[ #LOWER
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.LCTL, KC.NO, KC.NO, KC.NO, KC.NO, KC.NO, KC.LEFT, KC.DOWN, KC.UP, KC.RIGHT, KC.NO, KC.NO, \
KC.LSFT, KC.NO, KC.NO, KC.NO, KC.NO, KC.NO, KC.NO, KC.NO, KC.NO, KC.NO, KC.NO, KC.NO, \
KC.LGUI, LOWER, ADJUST, KC.ENT, RAISE, KC.RALT,
],
[ #RAISE
KC.ESC, KC.EXLM, KC.AT, KC.HASH, KC.DLR, KC.PERC, KC.CIRC, KC.AMPR, KC.ASTR, KC.LPRN, KC.RPRN, KC.BSPC,\
KC.LCTL, KC.NO, KC.NO, KC.NO, KC.NO, KC.NO, KC.MINS, KC.EQL, KC.LCBR, KC.RCBR, KC.PIPE, KC.GRV,\
KC.LSFT, KC.NO, KC.NO, KC.NO, KC.NO, KC.NO, KC.UNDS, KC.PLUS, KC.LBRC, KC.RBRC, KC.BSLS, KC.TILD,\
KC.LGUI, LOWER, ADJUST, KC.ENT, RAISE, KC.RALT,
],
[ #ADJUST
KC.NO, KC.NO, KC.NO, KC.NO, KC.NO, KC.NO, KC.NO, KC.NO, KC.NO, KC.NO, KC.NO, KC.NO, \
KC.NO, KC.NO, KC.NO, KC.NO, KC.NO, KC.NO, KC.NO, KC.NO, KC.NO, KC.NO, KC.NO, KC.NO, \
KC.NO, KC.NO, KC.NO, KC.NO, KC.NO, KC.NO, KC.NO, KC.NO, KC.NO, KC.NO, KC.NO, KC.NO, \
KC.LGUI, LOWER, ADJUST, KC.ENT, RAISE, KC.RALT,
]
]
if __name__ == '__main__':
keyboard.go()