AP_OSD: added font switching at runtime for SITL

This commit is contained in:
Andrew Tridgell 2018-07-09 20:48:59 +10:00
parent 64fae25882
commit 52a8198311
2 changed files with 6 additions and 1 deletions

View File

@ -43,7 +43,8 @@ void AP_OSD_SITL::load_font(void)
{
uint32_t font_size;
char fontname[] = "font0.bin";
fontname[4] = get_font_num() + '0';
last_font = get_font_num();
fontname[4] = last_font + '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");
@ -173,6 +174,9 @@ void AP_OSD_SITL::update_thread(void)
blink = (blink+1) % 4;
w->display();
if (last_font != get_font_num()) {
load_font();
}
usleep(10000);
}
}

View File

@ -49,6 +49,7 @@ private:
sf::RenderWindow *w;
sf::Texture font[256];
uint8_t last_font;
// setup to match MAX7456 layout
static const uint8_t char_width = 12;