Created
September 5, 2022 21:10
-
-
Save b2ox/fca27a9b68cba50c5d2b6f60e6beb63c to your computer and use it in GitHub Desktop.
cool640 x 2 split keyboard wtth kmk firmware
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from kmk.hid import HIDModes | |
from cool640 import KMKKeyboard | |
if __name__ == '__main__': | |
try: | |
keeb = KMKKeyboard() | |
keeb.debug_enabled = True | |
keeb.go(hid_type=HIDModes.USB) #Wired USB enable | |
except OSError: | |
import supervisor | |
supervisor.reload() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# cool640 split keyboard | |
import board | |
from kmk.hid import HIDModes | |
from kmk.scanners import DiodeOrientation | |
from kmk.keys import KC | |
from kmk.kmk_keyboard import KMKKeyboard as _KMKKeyboard | |
from kmk.modules.split import Split, SplitSide, SplitType | |
from kmk.modules.layers import Layers | |
from kmk.modules.mouse_keys import MouseKeys | |
from kmk.modules.modtap import ModTap | |
from kmk.modules.tapdance import TapDance | |
from kmk.modules.sticky_mod import StickyMod | |
#from kmk.modules.oneshot import OneShot | |
from NPXStatus import NPXStatus | |
class KMKKeyboard(_KMKKeyboard): | |
layers = Layers() | |
layers.tap_time = 400 | |
_KMKKeyboard.modules.append(layers) | |
modtap = ModTap() | |
modtap.tap_time = 400 | |
_KMKKeyboard.modules.append(modtap) | |
tapdance = TapDance() | |
tapdance.tap_time = 300 | |
_KMKKeyboard.modules.append(tapdance) | |
_KMKKeyboard.modules.append(StickyMod()) | |
#_KMKKeyboard.modules.append(OneShot()) | |
_KMKKeyboard.modules.append(MouseKeys()) | |
# 左右はドライブ名末尾のL/Rで決定 | |
split = Split( | |
split_type = SplitType.UART, | |
data_pin = board.GP0, # cool640 pcb v1.1 ではTRRSの1極とGP0共にNCなので空中配線して双方向通信にする | |
data_pin2 = board.GP1, | |
uart_flip = True, | |
use_pio = True # pcbかケーブルを弄ってクロス接続にするならPIO不要 | |
) | |
_KMKKeyboard.modules.append(split) | |
# 片手4行5列 | |
row_pins = (board.GP3, board.GP2, board.GP6, board.GP4) | |
col_pins = (board.GP15, board.GP14, board.GP10, board.GP7, board.GP5) | |
diode_orientation = DiodeOrientation.ROWS | |
coord_mapping = [ | |
0, 1, 2, 3, 4, 20, 21, 22, 23, 24, | |
5, 6, 7, 8, 9, 25, 26, 27, 28, 29, | |
10, 11, 12, 13, 14, 30, 31, 32, 33, 34, | |
15, 16, 17, 18, 19, 35, 36, 37, 38, 39 | |
] | |
npxStatus = NPXStatus(board.GP13, 6, [(0, 0, 15), (0, 15, 0), (15, 0, 0), (14, 5, 5), (5, 5, 14), (5, 14, 5)]) | |
_KMKKeyboard.modules.append(npxStatus) | |
def kcLT(lno, key): | |
return KC.LT(lno, key, prefer_hold = True) | |
def kcMT(key, mkey): | |
return KC.MT(key, mkey, prefer_hold = True) | |
____ = KC.NO | |
LYR3 = KC.MO(3) | |
ENT_L1 = kcLT(1, KC.ENT) | |
SPC_L2 = kcLT(2, KC.SPC) | |
CtlSPC = KC.LCTL(KC.SPC) | |
CtlA = KC.LCTL(KC.A) | |
CtlC = KC.LCTL(KC.C) | |
CtlD = KC.LCTL(KC.D) | |
CS_D = KC.LCTL(KC.LSFT(KC.D)) | |
CS_I = KC.LCTL(KC.LSFT(KC.I)) | |
CtlS = KC.LCTL(KC.S) | |
CtlV = KC.LCTL(KC.V) | |
CtlW = KC.LCTL(KC.W) | |
CtlX = KC.LCTL(KC.X) | |
CtlZ = KC.LCTL(KC.Z) | |
AltF4 = KC.LALT(KC.F4) | |
AppChg = KC.SM(KC.TAB, KC.LALT) | |
SCLN_WIN = kcMT(KC.SCLN, KC.LWIN) | |
COMM_ALT = kcMT(KC.COMM, KC.LALT) | |
SLSH_SFT = kcMT(KC.SLSH, KC.LSFT) | |
SPC_SFT = kcMT(KC.SPC, KC.LSFT) | |
ESC_SFT = kcMT(KC.ESC, KC.LSFT) | |
TAB_CTL = kcMT(KC.TAB, KC.LCTL) | |
BS_CTL = kcMT(KC.BSPC, KC.LCTL) | |
TD_PRN = KC.TD(KC.LPRN, KC.RPRN) | |
TD_BRC = KC.TD(KC.LBRC, KC.RBRC) | |
TD_CBR = KC.TD(KC.LCBR, KC.RCBR) | |
TD_MINS = KC.TD(KC.MINS, KC.TILD) | |
TD_QUOT = KC.TD(KC.QUOT, KC.GRV) | |
# ..> KC.MO --> KC.TO | |
# L0: Alphabets ..> L1,2,3 | |
# L1: Move & Shortcut | |
# L2: Number & Symbol | |
# L3: Functions & Misc | |
keymap = [ | |
# Layer0: Alphabets | |
[ | |
KC.Q, KC.F, KC.U, KC.Y, KC.SCLN, KC.J, KC.D, KC.G, KC.Z, KC.P, | |
KC.A, KC.O, KC.E, KC.I, KC.COMM, KC.H, KC.T, KC.K, KC.S, KC.N, | |
KC.X, KC.C, KC.V, KC.L, KC.DOT, KC.B, KC.R, KC.M, KC.W, SLSH_SFT, | |
LYR3, KC.LWIN, ESC_SFT, TAB_CTL, SPC_L2, ENT_L1, SPC_SFT, BS_CTL, KC.RALT, LYR3 | |
], | |
# Layer1: Move & Shortcut | |
[ | |
____, CtlW, CS_D, CS_I, AltF4, KC.HOME, KC.PGDN, KC.PGUP, KC.END, AppChg, | |
CtlA, CtlS, CtlD, ____, ____, KC.LEFT, KC.DOWN, KC.UP, KC.RGHT, ____, | |
CtlZ, CtlX, CtlC, CtlV, CtlSPC, KC.MS_LT, KC.MS_DN, KC.MS_UP, KC.MS_RT, KC.RSFT, | |
____, ____, ____, ____, ____, ____, KC.DEL, KC.BSPC, KC.MB_LMB, KC.MB_RMB | |
], | |
# Layer2: Number & Symbol | |
[ | |
KC.BSLS, KC.HASH, KC.CIRC, TD_CBR, KC.AT, KC.PLUS, KC.N7, KC.N8, KC.N9, KC.ASTR, | |
KC.PERC, KC.DLR, KC.AMPR, TD_PRN, TD_QUOT, TD_MINS, KC.N4, KC.N5, KC.N6, KC.EQL, | |
KC.EXLM, KC.UNDS, KC.PIPE, TD_BRC, KC.DQUO, KC.N0, KC.N1, KC.N2, KC.N3, KC.SLSH, | |
____, ____, ____, ____, ____, KC.ENT, KC.DOT, KC.BSPC, ____, ____ | |
], | |
# Layer3: Function & Misc | |
[ | |
____, ____, ____, ____, ____, KC.F9, KC.F10, KC.F11, KC.F12, ____, | |
____, ____, ____, ____, ____, KC.F5, KC.F6, KC.F7, KC.F8, KC.RLD, | |
____, ____, ____, ____, ____, KC.F1, KC.F2, KC.F3, KC.F4, KC.DEBUG, | |
____, ____, ____, ____, ____, ____, ____, ____, ____, ____ | |
], | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
NPXStatus.pyはこちら
https://gist.github.com/b2ox/91ca055f2e90972bf535a8a5df8fae60