Skip to content

Commit a9ebf04

Browse files
committed
Merge remote-tracking branch 'origin/master' into develop
2 parents 8eb1423 + c713ef6 commit a9ebf04

File tree

6 files changed

+88
-16
lines changed

6 files changed

+88
-16
lines changed

data/mappings/info_config.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,9 @@
3838
"RGBLIGHT_SPLIT": {"info_key": "rgblight.split", "value_type": "bool"},
3939
"PRODUCT": {"info_key": "keyboard_folder", "to_json": false},
4040
"PRODUCT_ID": {"info_key": "usb.pid", "value_type": "hex"},
41-
"VENDOR_ID": {"info_key": "usb.vid", "value_type": "hex"}
41+
"VENDOR_ID": {"info_key": "usb.vid", "value_type": "hex"},
42+
"QMK_ESC_OUTPUT": {"info_key": "qmk_lufa_bootloader.esc_output"},
43+
"QMK_ESC_INPUT": {"info_key": "qmk_lufa_bootloader.esc_input"},
44+
"QMK_LED": {"info_key": "qmk_lufa_bootloader.led"},
45+
"QMK_SPEAKER": {"info_key": "qmk_lufa_bootloader.speaker"}
4246
}

data/schemas/keyboard.jsonschema

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,28 @@
299299
"pattern": "^[0-9A-F]x[0-9A-F][0-9A-F][0-9A-F][0-9A-F]"
300300
}
301301
}
302+
},
303+
"qmk_lufa_bootloader": {
304+
"type": "object",
305+
"additionalProperties": false,
306+
"properties": {
307+
"esc_output": {
308+
"type": "string",
309+
"pattern": "^[A-K]\\d{1,2}$"
310+
},
311+
"esc_input": {
312+
"type": "string",
313+
"pattern": "^[A-K]\\d{1,2}$"
314+
},
315+
"led": {
316+
"type": "string",
317+
"pattern": "^[A-K]\\d{1,2}$"
318+
},
319+
"speaker": {
320+
"type": "string",
321+
"pattern": "^[A-K]\\d{1,2}$"
322+
}
323+
}
302324
}
303325
}
304326
}

lib/python/qmk/cli/generate/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from . import api
22
from . import config_h
3+
from . import dfu_header
34
from . import docs
45
from . import info_json
56
from . import layouts
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
"""Used by the make system to generate LUFA Keyboard.h from info.json
2+
"""
3+
from dotty_dict import dotty
4+
from milc import cli
5+
6+
from qmk.decorators import automagic_keyboard
7+
from qmk.info import info_json
8+
from qmk.path import is_keyboard, normpath
9+
10+
11+
@cli.argument('-o', '--output', arg_only=True, type=normpath, help='File to write to')
12+
@cli.argument('-q', '--quiet', arg_only=True, action='store_true', help="Quiet mode, only output error messages")
13+
@cli.argument('-kb', '--keyboard', help='Keyboard to generate LUFA Keyboard.h for.')
14+
@cli.subcommand('Used by the make system to generate LUFA Keyboard.h from info.json', hidden=True)
15+
@automagic_keyboard
16+
def generate_dfu_header(cli):
17+
"""Generates the Keyboard.h file.
18+
"""
19+
# Determine our keyboard(s)
20+
if not cli.config.generate_dfu_header.keyboard:
21+
cli.log.error('Missing parameter: --keyboard')
22+
cli.subcommands['info'].print_help()
23+
return False
24+
25+
if not is_keyboard(cli.config.generate_dfu_header.keyboard):
26+
cli.log.error('Invalid keyboard: "%s"', cli.config.generate_dfu_header.keyboard)
27+
return False
28+
29+
# Build the Keyboard.h file.
30+
kb_info_json = dotty(info_json(cli.config.generate_dfu_header.keyboard))
31+
32+
keyboard_h_lines = ['/* This file was generated by `qmk generate-dfu-header`. Do not edit or copy.' ' */', '', '#pragma once']
33+
keyboard_h_lines.append(f'#define MANUFACTURER {kb_info_json["manufacturer"]}')
34+
keyboard_h_lines.append(f'#define PRODUCT {cli.config.generate_dfu_header.keyboard} Bootloader')
35+
36+
# Optional
37+
if 'qmk_lufa_bootloader.esc_output' in kb_info_json:
38+
keyboard_h_lines.append(f'#define QMK_ESC_OUTPUT {kb_info_json["qmk_lufa_bootloader.esc_output"]}')
39+
if 'qmk_lufa_bootloader.esc_input' in kb_info_json:
40+
keyboard_h_lines.append(f'#define QMK_ESC_INPUT {kb_info_json["qmk_lufa_bootloader.esc_input"]}')
41+
if 'qmk_lufa_bootloader.led' in kb_info_json:
42+
keyboard_h_lines.append(f'#define QMK_LED {kb_info_json["qmk_lufa_bootloader.led"]}')
43+
if 'qmk_lufa_bootloader.speaker' in kb_info_json:
44+
keyboard_h_lines.append(f'#define QMK_SPEAKER {kb_info_json["qmk_lufa_bootloader.speaker"]}')
45+
46+
# Show the results
47+
keyboard_h = '\n'.join(keyboard_h_lines)
48+
49+
if cli.args.output:
50+
cli.args.output.parent.mkdir(parents=True, exist_ok=True)
51+
if cli.args.output.exists():
52+
cli.args.output.replace(cli.args.output.parent / (cli.args.output.name + '.bak'))
53+
cli.args.output.write_text(keyboard_h)
54+
55+
if not cli.args.quiet:
56+
cli.log.info('Wrote Keyboard.h to %s.', cli.args.output)
57+
58+
else:
59+
print(keyboard_h)

tmk_core/avr.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ extcoff: $(BUILD_DIR)/$(TARGET).elf
284284

285285
bootloader:
286286
make -C lib/lufa/Bootloaders/DFU/ clean
287-
$(TMK_DIR)/make_dfu_header.sh $(ALL_CONFIGS)
287+
bin/qmk generate-dfu-header --quiet --keyboard $(KEYBOARD) --output lib/lufa/Bootloaders/DFU/Keyboard.h
288288
$(eval MAX_SIZE=$(shell n=`$(CC) -E -mmcu=$(MCU) $(CFLAGS) $(OPT_DEFS) tmk_core/common/avr/bootloader_size.c 2> /dev/null | sed -ne 's/\r//;/^#/n;/^AVR_SIZE:/,$${s/^AVR_SIZE: //;p;}'` && echo $$(($$n)) || echo 0))
289289
$(eval PROGRAM_SIZE_KB=$(shell n=`expr $(MAX_SIZE) / 1024` && echo $$(($$n)) || echo 0))
290290
$(eval BOOT_SECTION_SIZE_KB=$(shell n=`expr $(BOOTLOADER_SIZE) / 1024` && echo $$(($$n)) || echo 0))

tmk_core/make_dfu_header.sh

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)