Browse Source

AP_OSD: added font switching at runtime for SITL

mission-4.1.18
Andrew Tridgell 7 years ago
parent
commit
52a8198311
  1. 6
      libraries/AP_OSD/AP_OSD_SITL.cpp
  2. 1
      libraries/AP_OSD/AP_OSD_SITL.h

6
libraries/AP_OSD/AP_OSD_SITL.cpp

@ -43,7 +43,8 @@ void AP_OSD_SITL::load_font(void) @@ -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) @@ -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);
}
}

1
libraries/AP_OSD/AP_OSD_SITL.h

@ -49,6 +49,7 @@ private: @@ -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;

Loading…
Cancel
Save