Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Piantor to boards #723

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions boards/beekeeb/piantor/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Piantor

The [Piantor by beekeeb](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](http://kmkfw.io/docs/split_keyboards#drive-names) 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.
Comment on lines +10 to +12
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a more robust and universal solution is to check supervisor.runtime.usb_connected.

52 changes: 52 additions & 0 deletions boards/beekeeb/piantor/kb.py
Original file line number Diff line number Diff line change
@@ -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.A3 # 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
]
63 changes: 63 additions & 0 deletions boards/beekeeb/piantor/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import board
import digitalio
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another unused import.


from kb import KMKKeyboard, isRight
from storage import getmount
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't do anything.


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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't do anything.


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
Comment on lines +18 to +19
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is what the uart_flip option of the split module is for.


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()