From fd02865a8baeed92bdedbb282301a429b634a75a Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 9 Jul 2018 17:58:57 +1000 Subject: [PATCH] HAL_ChibiOS: use wildcard ROMFS name for fonts --- .../AP_HAL_ChibiOS/hwdef/KakuteF4/hwdef.dat | 2 +- .../hwdef/MatekF405-Wing/hwdef.dat | 2 +- .../AP_HAL_ChibiOS/hwdef/MatekF405/hwdef.dat | 2 +- .../AP_HAL_ChibiOS/hwdef/OMNIBUSF7V2/hwdef.dat | 2 +- .../AP_HAL_ChibiOS/hwdef/omnibusf4pro/hwdef.dat | 2 +- .../hwdef/scripts/chibios_hwdef.py | 16 +++++++++++++++- 6 files changed, 20 insertions(+), 6 deletions(-) diff --git a/libraries/AP_HAL_ChibiOS/hwdef/KakuteF4/hwdef.dat b/libraries/AP_HAL_ChibiOS/hwdef/KakuteF4/hwdef.dat index 841a417ee8..1e18ef369b 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/KakuteF4/hwdef.dat +++ b/libraries/AP_HAL_ChibiOS/hwdef/KakuteF4/hwdef.dat @@ -139,7 +139,7 @@ SPIDEV osd SPI3 DEVID4 MAX7456_CS MODE0 10*MHZ 10*MHZ # setup for OSD define OSD_ENABLED ENABLED -ROMFS osd_font.bin libraries/AP_OSD/fonts/clarity.bin +ROMFS_WILDCARD libraries/AP_OSD/fonts/font*.bin # 8 PWM available by default define BOARD_PWM_COUNT_DEFAULT 8 diff --git a/libraries/AP_HAL_ChibiOS/hwdef/MatekF405-Wing/hwdef.dat b/libraries/AP_HAL_ChibiOS/hwdef/MatekF405-Wing/hwdef.dat index cbc094e6c9..f3b2c7f22f 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/MatekF405-Wing/hwdef.dat +++ b/libraries/AP_HAL_ChibiOS/hwdef/MatekF405-Wing/hwdef.dat @@ -167,7 +167,7 @@ define HAL_COMPASS_HMC5843_ROTATION ROTATION_YAW_90 define ALLOW_ARM_NO_COMPASS define OSD_ENABLED ENABLED -ROMFS osd_font.bin libraries/AP_OSD/fonts/clarity.bin +ROMFS_WILDCARD libraries/AP_OSD/fonts/font*.bin define BOARD_PWM_COUNT_DEFAULT 9 diff --git a/libraries/AP_HAL_ChibiOS/hwdef/MatekF405/hwdef.dat b/libraries/AP_HAL_ChibiOS/hwdef/MatekF405/hwdef.dat index 34960d536c..3327d627f2 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/MatekF405/hwdef.dat +++ b/libraries/AP_HAL_ChibiOS/hwdef/MatekF405/hwdef.dat @@ -166,4 +166,4 @@ define BOARD_PWM_COUNT_DEFAULT 8 # setup for OSD define OSD_ENABLED ENABLED -ROMFS osd_font.bin libraries/AP_OSD/fonts/clarity.bin +ROMFS_WILDCARD libraries/AP_OSD/fonts/font*.bin diff --git a/libraries/AP_HAL_ChibiOS/hwdef/OMNIBUSF7V2/hwdef.dat b/libraries/AP_HAL_ChibiOS/hwdef/OMNIBUSF7V2/hwdef.dat index 47c5b65432..bb0ff8135d 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/OMNIBUSF7V2/hwdef.dat +++ b/libraries/AP_HAL_ChibiOS/hwdef/OMNIBUSF7V2/hwdef.dat @@ -124,4 +124,4 @@ define ALLOW_ARM_NO_COMPASS define HAL_BARO_DEFAULT HAL_BARO_BMP280_SPI define OSD_ENABLED ENABLED -ROMFS osd_font.bin libraries/AP_OSD/fonts/clarity.bin +ROMFS_WILDCARD libraries/AP_OSD/fonts/font*.bin diff --git a/libraries/AP_HAL_ChibiOS/hwdef/omnibusf4pro/hwdef.dat b/libraries/AP_HAL_ChibiOS/hwdef/omnibusf4pro/hwdef.dat index b7deaa719e..15aa8541f8 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/omnibusf4pro/hwdef.dat +++ b/libraries/AP_HAL_ChibiOS/hwdef/omnibusf4pro/hwdef.dat @@ -136,4 +136,4 @@ define BOARD_PWM_COUNT_DEFAULT 6 #define CH_DBG_ENABLE_STACK_CHECK TRUE #font for the osd -ROMFS osd_font.bin libraries/AP_OSD/fonts/clarity.bin +ROMFS_WILDCARD libraries/AP_OSD/fonts/font*.bin diff --git a/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py b/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py index d40794cfed..919fac34e1 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py +++ b/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py @@ -1165,6 +1165,18 @@ def write_env_py(filename): env_vars['CHIBIOS_BUILD_FLAGS'] = ' '.join(build_flags) pickle.dump(env_vars, open(filename, "wb")) +def romfs_add(romfs_filename, filename): + '''add a file to ROMFS''' + romfs.append((romfs_filename, filename)) + +def romfs_wildcard(pattern): + '''add a set of files to ROMFS by wildcard''' + base_path = os.path.join(os.path.dirname(__file__), '..', '..', '..', '..') + (pattern_dir, pattern) = os.path.split(pattern) + for f in os.listdir(os.path.join(base_path, pattern_dir)): + if fnmatch.fnmatch(f, pattern): + romfs.append((f, os.path.join(pattern_dir, f))) + def process_line(line): '''process one line of pin definition file''' global allpins @@ -1205,7 +1217,9 @@ def process_line(line): if a[0] == 'SPIDEV': spidev.append(a[1:]) if a[0] == 'ROMFS': - romfs.append((a[1],a[2])) + romfs_add(a[1],a[2]) + if a[0] == 'ROMFS_WILDCARD': + romfs_wildcard(a[1]) if a[0] == 'undef': print("Removing %s" % a[1]) config.pop(a[1], '')