1
0
Fork 0

qmk new-keyboard: separate dev board and MCU selection (#24548)

This commit is contained in:
Ryan 2024-11-21 17:22:14 +11:00 committed by GitHub
parent 88afd53b1f
commit 638b22d057
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 118 additions and 101 deletions

View file

@ -8,7 +8,7 @@ from pathlib import Path
from dotty_dict import dotty
from milc import cli
from milc.questions import choice, question
from milc.questions import choice, question, yesno
from qmk.git import git_get_username
from qmk.json_schema import load_jsonschema
@ -131,60 +131,70 @@ def _question(*args, **kwargs):
return ret
def prompt_keyboard():
prompt = """{fg_yellow}Name Your Keyboard Project{style_reset_all}
For more infomation, see:
https://docs.qmk.fm/hardware_keyboard_guidelines#naming-your-keyboard-project
def prompt_heading_subheading(heading, subheading):
cli.log.info(f"{{fg_yellow}}{heading}{{style_reset_all}}")
cli.log.info(subheading)
Keyboard Name? """
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""")
errmsg = 'Keyboard already exists! Please choose a different name:'
return _question(prompt, reprompt=errmsg, validate=lambda x: not keyboard(x).exists())
return _question("Keyboard Name?", reprompt=errmsg, validate=lambda x: not keyboard(x).exists())
def prompt_user():
prompt = """
{fg_yellow}Attribution{style_reset_all}
Used for maintainer, copyright, etc
prompt_heading_subheading("Attribution", "Used for maintainer, copyright, etc.")
Your GitHub Username? """
return question(prompt, default=git_get_username())
return question("Your GitHub Username?", default=git_get_username())
def prompt_name(def_name):
prompt = """
{fg_yellow}More Attribution{style_reset_all}
Used for maintainer, copyright, etc
prompt_heading_subheading("More Attribution", "Used for maintainer, copyright, etc.")
Your Real Name? """
return question(prompt, default=def_name)
return question("Your Real Name?", default=def_name)
def prompt_layout():
prompt = """
{fg_yellow}Pick Base Layout{style_reset_all}
As a starting point, one of the common layouts can be used to bootstrap the process
prompt_heading_subheading("Pick Base Layout", """As a starting point, one of the common layouts can be used to
bootstrap the process""")
Default Layout? """
# avoid overwhelming user - remove some?
filtered_layouts = [x for x in available_layouts if not any(xs in x for xs in ['_split', '_blocker', '_tsangan', '_f13'])]
filtered_layouts.append("none of the above")
return choice(prompt, filtered_layouts, default=len(filtered_layouts) - 1)
return choice("Default Layout?", filtered_layouts, default=len(filtered_layouts) - 1)
def prompt_mcu_type():
prompt_heading_subheading(
"What Powers Your Project", """Is your board using a separate development board, such as a Pro Micro,
or is the microcontroller integrated onto the PCB?
For more information, see:
https://docs.qmk.fm/compatible_microcontrollers"""
)
return yesno("Using a Development Board?")
def prompt_dev_board():
prompt_heading_subheading("Select Development Board", """For more information, see:
https://docs.qmk.fm/compatible_microcontrollers""")
return choice("Development Board?", dev_boards, default=dev_boards.index("promicro"))
def prompt_mcu():
prompt = """
{fg_yellow}What Powers Your Project{style_reset_all}
For more infomation, see:
https://docs.qmk.fm/#/compatible_microcontrollers
prompt_heading_subheading("Select Microcontroller", """For more information, see:
https://docs.qmk.fm/compatible_microcontrollers""")
MCU? """
# remove any options strictly used for compatibility
filtered_mcu = [x for x in (dev_boards + mcu_types) if not any(xs in x for xs in ['cortex', 'unknown'])]
filtered_mcu = [x for x in mcu_types if not any(xs in x for xs in ['cortex', 'unknown'])]
return choice(prompt, filtered_mcu, default=filtered_mcu.index("atmega32u4"))
return choice("Microcontroller?", filtered_mcu, default=filtered_mcu.index("atmega32u4"))
@cli.argument('-kb', '--keyboard', help='Specify the name for the new keyboard directory', arg_only=True, type=keyboard_name)
@ -211,7 +221,11 @@ def new_keyboard(cli):
user_name = cli.config.new_keyboard.name if cli.config.new_keyboard.name else prompt_user()
real_name = cli.args.realname or cli.config.new_keyboard.name if cli.args.realname or cli.config.new_keyboard.name else prompt_name(user_name)
default_layout = cli.args.layout if cli.args.layout else prompt_layout()
mcu = cli.args.type if cli.args.type else prompt_mcu()
if cli.args.type:
mcu = cli.args.type
else:
mcu = prompt_dev_board() if prompt_mcu_type() else prompt_mcu()
config = {}
if mcu in dev_boards: