mirror of
https://github.com/qmk/qmk_firmware.git
synced 2025-07-17 05:02:07 +00:00
qmk new-keyboard
: prompt for matrix type and dimensions
This commit is contained in:
parent
9e9b4acbde
commit
edb15390d3
@ -2,11 +2,6 @@
|
||||
"keyboard_name": "%KEYBOARD%",
|
||||
"maintainer": "%USER_NAME%",
|
||||
"manufacturer": "%REAL_NAME%",
|
||||
"diode_direction": "COL2ROW",
|
||||
"matrix_pins": {
|
||||
"cols": ["C2"],
|
||||
"rows": ["D1"]
|
||||
},
|
||||
"usb": {
|
||||
"vid": "0xFEED",
|
||||
"pid": "0x0000",
|
||||
|
@ -97,9 +97,20 @@ def augment_community_info(config, src, dest):
|
||||
width = max(width, int(item["x"]) + 1)
|
||||
height = max(height, int(item["y"]) + 1)
|
||||
|
||||
matrix_type = prompt_matrix_type()
|
||||
(rows, cols) = prompt_matrix_size(len(first_layout))
|
||||
|
||||
if matrix_type == 'direct':
|
||||
info["matrix_pins"] = {
|
||||
"cols": ["C2"] * width,
|
||||
"rows": ["D1"] * height,
|
||||
"direct": [
|
||||
["C2"] * cols
|
||||
] * rows
|
||||
}
|
||||
elif matrix_type in ['COL2ROW', 'ROW2COL']:
|
||||
info["diode_direction"] = matrix_type
|
||||
info["matrix_pins"] = {
|
||||
"cols": ["C2"] * cols,
|
||||
"rows": ["D1"] * rows,
|
||||
}
|
||||
|
||||
# assume a 1:1 mapping on matrix to electrical
|
||||
@ -136,6 +147,32 @@ def prompt_heading_subheading(heading, subheading):
|
||||
cli.log.info(subheading)
|
||||
|
||||
|
||||
def prompt_matrix_type():
|
||||
prompt_heading_subheading("Specify Matrix Type", "")
|
||||
|
||||
matrix_types = ['COL2ROW', 'ROW2COL', 'direct', 'custom']
|
||||
|
||||
return choice("Matrix type?", matrix_types)
|
||||
|
||||
|
||||
def prompt_matrix_size(key_count):
|
||||
prompt_heading_subheading("Specify Matrix Dimensions", "The number of rows and columns in the electrical matrix")
|
||||
|
||||
errmsg = 'Need at least one row or column!'
|
||||
|
||||
ret = True
|
||||
while ret:
|
||||
rows = int(_question("Rows:", reprompt=errmsg, validate=lambda x: int(x) > 0))
|
||||
cols = int(_question("Cols:", reprompt=errmsg, validate=lambda x: int(x) > 0))
|
||||
|
||||
if rows * cols >= key_count:
|
||||
ret = False
|
||||
else:
|
||||
cli.log.error(f"Number of rows ({rows}) * number of cols ({cols}) is not sufficient for the number of keys in the selected layout ({key_count})!")
|
||||
|
||||
return (rows, cols)
|
||||
|
||||
|
||||
def prompt_keyboard():
|
||||
prompt_heading_subheading("Name Your Keyboard Project", """For more information, see:
|
||||
https://docs.qmk.fm/hardware_keyboard_guidelines#naming-your-keyboard-project""")
|
||||
|
Loading…
Reference in New Issue
Block a user