@ -22,7 +22,8 @@
@@ -22,7 +22,8 @@
# include <AP_HAL/Util.h>
# include <AP_HAL/Semaphores.h>
# include <AP_HAL/Scheduler.h>
# include <AP_ROMFS/AP_ROMFS.h>
# include <AP_Filesystem/AP_Filesystem.h>
# include <GCS_MAVLink/GCS.h>
# include <utility>
@ -157,13 +158,19 @@ bool AP_OSD_MAX7456::init()
@@ -157,13 +158,19 @@ bool AP_OSD_MAX7456::init()
bool AP_OSD_MAX7456 : : update_font ( )
{
uint32_t font_size ;
uint8_t updated_chars = 0 ;
char fontname [ ] = " font0.bin " ;
last_font = get_font_num ( ) ;
fontname [ 4 ] = last_font + ' 0 ' ;
const uint8_t * font_data = AP_ROMFS : : find_decompress ( fontname , font_size ) ;
if ( font_data = = nullptr | | font_size ! = NVM_RAM_SIZE * 256 ) {
FileData * fd = load_font_data ( last_font ) ;
if ( fd = = nullptr ) {
return false ;
}
const uint8_t * font_data = fd - > data ;
uint32_t font_size = fd - > length ;
if ( font_size ! = NVM_RAM_SIZE * 256 ) {
GCS_SEND_TEXT ( MAV_SEVERITY_ERROR , " AP_OSD: bad font size %u \n " , unsigned ( font_size ) ) ;
delete fd ;
return false ;
}
@ -173,18 +180,13 @@ bool AP_OSD_MAX7456::update_font()
@@ -173,18 +180,13 @@ bool AP_OSD_MAX7456::update_font()
if ( ! check_font_char ( chr , chr_font_data ) ) {
//update char inside max7456 NVM
if ( ! update_font_char ( chr , chr_font_data ) ) {
hal . console - > printf ( " AP_OSD: error during font char update \n " ) ;
AP_ROMFS : : free ( font_data ) ;
delete fd ;
return false ;
}
updated_chars + + ;
}
}
if ( updated_chars > 0 ) {
hal . console - > printf ( " AP_OSD: updated %d symbols. \n " , updated_chars ) ;
}
hal . console - > printf ( " AP_OSD: osd font is up to date. \n " ) ;
AP_ROMFS : : free ( font_data ) ;
delete fd ;
return true ;
}