AP_OSD: added OSD_FONT parameter

allow for user selection of font
This commit is contained in:
Andrew Tridgell 2018-07-09 18:08:47 +10:00
parent 4055f28bc5
commit 6347de2b89
5 changed files with 17 additions and 2 deletions

View File

@ -76,6 +76,13 @@ const AP_Param::GroupInfo AP_OSD::var_info[] = {
// @Bitmask: 0:UseDecimalPack
// @User: Standard
AP_GROUPINFO("_OPTIONS", 8, AP_OSD, options, OPTION_DECIMAL_PACK),
// @Param: _FONT
// @DisplayName: OSD Font
// @Description: This sets which OSD font to use. It is an integer from 0 to the number of fonts available
// @User: Standard
// @RebootRequired: True
AP_GROUPINFO("_FONT", 9, AP_OSD, font_num, 0),
AP_GROUPEND
};

View File

@ -161,6 +161,7 @@ public:
AP_Int8 osd_type;
AP_Int8 rc_channel;
AP_Int8 sw_method;
AP_Int8 font_num;
enum {
OPTION_DECIMAL_PACK = 1U<<0,

View File

@ -52,6 +52,9 @@ public:
protected:
AP_OSD& _osd;
// get font choice
uint8_t get_font_num(void) const { return (uint8_t)_osd.font_num.get(); }
};

View File

@ -155,7 +155,9 @@ bool AP_OSD_MAX7456::update_font()
{
uint32_t font_size;
uint8_t updated_chars = 0;
uint8_t *font_data = AP_ROMFS::find_decompress("font0.bin", font_size);
char fontname[] = "font0.bin";
fontname[4] = get_font_num() + '0';
uint8_t *font_data = AP_ROMFS::find_decompress(fontname, font_size);
if (font_data == nullptr || font_size != NVM_RAM_SIZE * 256) {
return false;
}

View File

@ -42,7 +42,9 @@ extern const AP_HAL::HAL &hal;
void AP_OSD_SITL::load_font(void)
{
uint32_t font_size;
uint8_t *font_data = AP_ROMFS::find_decompress("font0.bin", font_size);
char fontname[] = "font0.bin";
fontname[4] = get_font_num() + '0';
uint8_t *font_data = AP_ROMFS::find_decompress(fontname, font_size);
if (font_data == nullptr || font_size != 54 * 256) {
AP_HAL::panic("Bad font file");
}