Skip to content

Commit 83a6f71

Browse files
committed
versioning for py files
set split keyboard pins
1 parent b2b3a34 commit 83a6f71

File tree

17 files changed

+168
-55
lines changed

17 files changed

+168
-55
lines changed

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,25 @@ then just run it with dev to start
2222

2323
# Tasks
2424
## urgent
25-
- [ ] boot.py generation
25+
- [ ] guides etc for setup + split workflow
2626
- [ ] share pog.json files
27-
- [ ] use injection points from the pog.json for codeblocks
28-
- [ ] direct pin wiring support
27+
- [ ] check if the controller you use even has the pin you specified (controller lookup and serial to get pins )
2928
- [ ] bluetooth workflow
3029
- [ ] generate layout based on matrix + clear layout button / delete multiple
31-
- [ ] save a backup of the json in electron
3230

3331
## features
34-
- [x] dragging keys on the layout editor
3532
- [ ] language switcher for german and other layouts changing the labels on the keymap
3633
- [ ] modtap/tapdance/macros/sequences
3734
- [ ] encoder support direct pin click
3835
- [ ] way to handle differences between pog.json to kmk code
3936
- [ ] wiring preview
4037

4138
## done
39+
- [x] boot.py generation
40+
- [x] versioning for python files
41+
- [x] direct pin wiring support
42+
- [x] save a backup of the json in electron
43+
- [x] dragging keys on the layout editor
4244
- [x] Layout editor to replace KLE
4345
- [x] save pog.json (use as main storage for everything)
4446
- [x] adjust keymap when matrix changes

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "pog",
3-
"version": "0.9.3",
3+
"version": "0.9.5",
44
"description": "A KMK firmware configurator",
55
"main": "./out/main/index.js",
66
"author": "Jan Lunge",

src/main/index.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -233,25 +233,32 @@ const timeout = (prom, time) => {
233233
}
234234

235235
export const serialBoards: { value: any[] } = { value: [] }
236+
// TODO: resolve callbacks properly
237+
// https://stackoverflow.com/questions/69608234/get-promise-resolve-from-separate-callback
236238
const scanForKeyboards = async () => {
237239
console.log('checking for connected keyboards')
238240
if (connectedKeyboardPort && connectedKeyboardPort.isOpen) connectedKeyboardPort.close()
239241
const ports = await serialPort.SerialPort.list()
240242
const circuitPythonPorts = ports //.filter(port => {
241243
// return port.manufacturer && ['0xCB'].includes(port.manufacturer)
242244
// });
243-
let boards = await Promise.allSettled(
245+
const boards = (await Promise.allSettled(
244246
circuitPythonPorts.map(async (a) => await timeout(getBoardInfo(a), 2000))
245-
)
246-
boards = boards.filter((a) => a.value !== undefined).map((a) => a.value)
247+
)) as {
248+
status: 'fulfilled' | 'rejected'
249+
value: { name: string; id: string; path: string }
250+
}[]
251+
const filteredBoards: { name: string; id: string; path: string }[] = boards
252+
.filter((a) => a.value !== undefined)
253+
.map((a) => a.value)
247254

248255
console.log('boards ready')
249-
boards.map((a) => console.log(`${a.name} - ${a.id} | ${a.path}`))
256+
filteredBoards.map((a) => console.log(`${a.name} - ${a.id} | ${a.path}`))
250257
mainWindow?.webContents.send('keyboardScan', {
251-
keyboards: boards
258+
keyboards: filteredBoards
252259
})
253-
serialBoards.value = boards
254-
return boards
260+
serialBoards.value = filteredBoards
261+
return filteredBoards
255262
}
256263

257264
let currentPackage = ''

src/main/pythontemplates/boot.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export const bootpy = `# boot.py
1+
export const bootpy = `# boot.py - v0.9.5
22
import usb_cdc
33
import supervisor
44
import storage

src/main/pythontemplates/code.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export const codepy = `# Main Keyboard Configuration
1+
export const codepy = `# Main Keyboard Configuration - v0.9.5
22
import board
33
import pog
44

src/main/pythontemplates/coordmaphelper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export const coordmaphelperpy = `# coordmaphelper.py helper script to get your coord map
1+
export const coordmaphelperpy = `# coordmaphelper.py helper script to get your coord map - v0.9.5
22
from kmk.handlers.sequences import simple_key_sequence
33
from kmk.keys import KC
44
from kb import KMKKeyboard as _KMKKeyboard

src/main/pythontemplates/customkeys.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export const customkeyspy = `# These are yous custom keycodes do any needed imports at the top
1+
export const customkeyspy = `# These are yous custom keycodes do any needed imports at the top - v0.9.5
22
# then you can reference them in your keymap with for example customkeys.MyKey
33
44
from kmk.keys import KC

src/main/pythontemplates/kb.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export const kbpy = `# kb.py KB base config
1+
export const kbpy = `# kb.py KB base config - v0.9.5
22
import board
33
import pog
44
@@ -36,6 +36,15 @@ class KMKKeyboard(_KMKKeyboard):
3636
self.combos = Combos()
3737
self.modules.append(self.combos)
3838
39+
if pog.config['split']:
40+
from kmk.modules.split import Split, SplitSide, SplitType
41+
side = SplitSide.RIGHT if str(getmount('/').label)[-1] == 'R' else SplitSide.LEFT
42+
if pog.splitPinB:
43+
self.split = Split(split_side=side, data_pin=pog.splitPinA, data_pin2=pog.splitPinB, use_pio=True)
44+
else:
45+
self.split = Split(split_side=side, data_pin=pog.splitPinA, use_pio=True)
46+
self.modules.append(self.split)
47+
3948
# Add your own modules and extensions here
4049
# or sort them into the correct spot to have the correct import order
4150

src/main/pythontemplates/pog.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export const pogpy =`# pog.py Import the pog config
1+
export const pogpy =`# pog.py Import the pog config - v0.9.5
22
import json
33
import board
44
from kmk.keys import KC
@@ -97,4 +97,11 @@ directPinScanner = (
9797
max_events=64
9898
)"""
9999
)
100+
101+
splitPinA = None
102+
splitPinB = None
103+
if config.get('splitPinA'):
104+
splitPinA = eval(renderPin(config['splitPinA']))
105+
if config.get('splitPinB'):
106+
splitPinB = eval(renderPin(config['splitPinB']))
100107
`

src/main/pythontemplates/pog_serial.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
export const pog_serialpy = `# pog_serial module
1+
export const pog_serialpy = `# pog_serial module - v0.9.5
22
from usb_cdc import data
3-
43
from kmk.modules import Module
54
from kmk.utils import Debug
65
import pog
@@ -11,6 +10,7 @@ import microcontroller
1110
import os
1211
import supervisor
1312
import math
13+
import board
1414
1515
debug = Debug(__name__)
1616
@@ -158,7 +158,7 @@ class pogSerial(Module):
158158
if split[0] == 'info_simple':
159159
# print basic keyboard info
160160
print('getting basic keyboard info')
161-
data.write((json.dumps({"driveMounted": microcontroller.nvm[0]!=0 ,"name": pog.config['name'], "manufacturer": pog.config['manufacturer'], "id": pog.config['id']})+"\\n").encode())
161+
data.write((json.dumps({"driveMounted": microcontroller.nvm[0]!=0 ,"name": pog.config['name'], "manufacturer": pog.config['manufacturer'], "id": pog.config['id'], "board": dir(board) })+"\\n").encode())
162162
if split[0] == 'save':
163163
# read chunks
164164
file_to_delete = open("received_file.json",'w')

0 commit comments

Comments
 (0)