Skip to content

Commit

Permalink
Add frameworking for development board presets (#16637)
Browse files Browse the repository at this point in the history
* Add frameworking for development board presets

* Update lib/python/qmk/info.py

Co-authored-by: Nick Brassel <nick@tzarc.org>

Co-authored-by: Nick Brassel <nick@tzarc.org>
  • Loading branch information
zvecr and tzarc committed Apr 3, 2022
1 parent 1660b2d commit c0ac3f7
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
17 changes: 17 additions & 0 deletions data/mappings/defaults.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"development_board": {
"promicro": {
"processor": "atmega32u4",
"bootloader": "caterina"
},
"elite_c": {
"processor": "atmega32u4",
"bootloader": "atmel-dfu"
},
"proton_c": {
"processor": "STM32F303",
"bootloader": "stm32-dfu",
"board": "QMK_PROTON_C"
}
}
}
4 changes: 4 additions & 0 deletions data/schemas/keyboard.jsonschema
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
"type": "string",
"format": "uri"
},
"development_board": {
"type": "string",
"enum": ["promicro", "elite_c", "proton_c"]
},
"processor": {
"type": "string",
"enum": ["cortex-m0", "cortex-m0plus", "cortex-m3", "cortex-m4", "MKL26Z64", "MK20DX128", "MK20DX256", "MK66FX1M0", "STM32F042", "STM32F072", "STM32F103", "STM32F303", "STM32F401", "STM32F405", "STM32F407", "STM32F411", "STM32F446", "STM32G431", "STM32G474", "STM32L412", "STM32L422", "STM32L432", "STM32L433", "STM32L442", "STM32L443", "GD32VF103", "WB32F3G71", "atmega16u2", "atmega32u2", "atmega16u4", "atmega32u4", "at90usb162", "at90usb646", "at90usb647", "at90usb1286", "at90usb1287", "atmega32a", "atmega328p", "atmega328", "attiny85", "unknown"]
Expand Down
13 changes: 13 additions & 0 deletions lib/python/qmk/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def info_json(keyboard):

# Merge in the data from info.json, config.h, and rules.mk
info_data = merge_info_jsons(keyboard, info_data)
info_data = _process_defaults(info_data)
info_data = _extract_rules_mk(info_data, rules_mk(str(keyboard)))
info_data = _extract_config_h(info_data, config_h(str(keyboard)))

Expand Down Expand Up @@ -473,6 +474,18 @@ def _extract_config_h(info_data, config_c):
return info_data


def _process_defaults(info_data):
"""Process any additional defaults based on currently discovered information
"""
defaults_map = json_load(Path('data/mappings/defaults.json'))
for default_type in defaults_map.keys():
thing_map = defaults_map[default_type]
if default_type in info_data:
for key, value in thing_map.get(info_data[default_type], {}).items():
info_data[key] = value
return info_data


def _extract_rules_mk(info_data, rules):
"""Pull some keyboard information from existing rules.mk files
"""
Expand Down

0 comments on commit c0ac3f7

Please sign in to comment.