mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-26 20:56:37 +00:00
Additional logging
This commit is contained in:
parent
228148b92d
commit
edfaae4299
@ -15,7 +15,7 @@ Obtain or create a font file:
|
||||
lv_zifont_init();
|
||||
|
||||
static lv_font_t font1;
|
||||
lv_zifont_font_init(&font1, "./notosans_32.zi", 0);
|
||||
lv_zifont_font_init(&font1, "/notosans_32.zi", 0);
|
||||
|
||||
static lv_style_t ft_style;
|
||||
lv_style_copy(&ft_style, &lv_style_plain);
|
||||
|
@ -68,7 +68,7 @@ lv_zifont_char_t lastCharInfo; // Holds the last Glyph DSC
|
||||
|
||||
#if ESP32
|
||||
// static lv_zifont_char_t charCache[256 - 32]; // glyphID DSC cache
|
||||
#define CHAR_CACHE_SIZE 224
|
||||
#define CHAR_CACHE_SIZE 95
|
||||
#else
|
||||
#define CHAR_CACHE_SIZE 95
|
||||
// static lv_zifont_char_t charCache[256 - 32]; // glyphID DSC cache
|
||||
@ -90,6 +90,7 @@ static void IRAM_ATTR colorsAdd(uint8_t * charBitmap_p, uint8_t color1, uint16_t
|
||||
|
||||
int lv_zifont_init(void)
|
||||
{
|
||||
FS.begin(true);
|
||||
// charBitmap_p = (uint8_t *)lv_mem_alloc(32 * 32);
|
||||
return LV_RES_OK; // OK
|
||||
}
|
||||
@ -103,6 +104,7 @@ static inline bool openFont(File & file, const char * filename)
|
||||
LOG_ERROR(TAG_FONT, F("Opening font: %s"), filename);
|
||||
return false;
|
||||
}
|
||||
LOG_TRACE(TAG_FONT, F("Opening font: %s"), filename);
|
||||
return file;
|
||||
}
|
||||
|
||||
@ -128,6 +130,7 @@ int lv_zifont_font_init(lv_font_t ** font, const char * font_path, uint16_t size
|
||||
charInBuffer = 0; // invalidate any previous cache
|
||||
|
||||
if(!*font) {
|
||||
LOG_TRACE(TAG_FONT, F("File %s - Line %d - init font"), __FILE__, __LINE__);
|
||||
*font = (lv_font_t*)lv_mem_alloc(sizeof(lv_font_t));
|
||||
LV_ASSERT_MEM(*font);
|
||||
_lv_memset_00(*font, sizeof(lv_font_t)); // lv_mem_alloc might be dirty
|
||||
@ -135,10 +138,13 @@ int lv_zifont_font_init(lv_font_t ** font, const char * font_path, uint16_t size
|
||||
|
||||
lv_font_fmt_zifont_dsc_t* dsc;
|
||||
if(!(*font)->dsc) {
|
||||
LOG_TRACE(TAG_FONT, F("File %s - Line %d - init font dsc"), __FILE__, __LINE__);
|
||||
dsc = (lv_font_fmt_zifont_dsc_t*)lv_mem_alloc(sizeof(lv_font_fmt_zifont_dsc_t));
|
||||
LV_ASSERT_MEM(dsc);
|
||||
_lv_memset_00(dsc, sizeof(lv_font_fmt_zifont_dsc_t)); // lv_mem_alloc might be dirty
|
||||
dsc->ascii_glyph_dsc = NULL;
|
||||
} else {
|
||||
LOG_TRACE(TAG_FONT, F("File %s - Line %d - reuse font dsc"), __FILE__, __LINE__);
|
||||
dsc = (lv_font_fmt_zifont_dsc_t*)(*font)->dsc;
|
||||
}
|
||||
LV_ASSERT_MEM(dsc);
|
||||
@ -160,6 +166,8 @@ int lv_zifont_font_init(lv_font_t ** font, const char * font_path, uint16_t size
|
||||
zi_font_header_t header;
|
||||
size_t readSize = file.readBytes((char*)&header, sizeof(zi_font_header_t));
|
||||
|
||||
LOG_TRACE(TAG_FONT, F("File %s - Line %d"), __FILE__, __LINE__);
|
||||
|
||||
/* Check that we read the correct size */
|
||||
if(readSize != sizeof(zi_font_header_t)) {
|
||||
LOG_ERROR(TAG_FONT, F("Error reading ziFont Header"));
|
||||
@ -167,6 +175,8 @@ int lv_zifont_font_init(lv_font_t ** font, const char * font_path, uint16_t size
|
||||
return ZIFONT_ERROR_READING_DATA;
|
||||
}
|
||||
|
||||
LOG_TRACE(TAG_FONT, F("File %s - Line %d"), __FILE__, __LINE__);
|
||||
|
||||
/* Check ziFile Header Format */
|
||||
if(header.Password != 4 || header.Version != 5) {
|
||||
LOG_ERROR(TAG_FONT, F("Unknown font file format"));
|
||||
@ -174,6 +184,8 @@ int lv_zifont_font_init(lv_font_t ** font, const char * font_path, uint16_t size
|
||||
return ZIFONT_ERROR_UNKNOWN_HEADER;
|
||||
}
|
||||
|
||||
LOG_TRACE(TAG_FONT, F("File %s - Line %d"), __FILE__, __LINE__);
|
||||
|
||||
dsc->CharHeight = header.CharHeight;
|
||||
dsc->CharWidth = header.CharWidth;
|
||||
dsc->Maximumnumchars = header.Maximumnumchars;
|
||||
@ -182,21 +194,34 @@ int lv_zifont_font_init(lv_font_t ** font, const char * font_path, uint16_t size
|
||||
dsc->Startdataaddress = header.Startdataaddress + header.Descriptionlength;
|
||||
dsc->Fontdataadd8byte = header.Fontdataadd8byte;
|
||||
|
||||
if(!dsc->ascii_glyph_dsc) {
|
||||
LOG_TRACE(TAG_FONT, F("File %s - Line %d - %d"), __FILE__, __LINE__, dsc->ascii_glyph_dsc);
|
||||
|
||||
if(dsc->ascii_glyph_dsc == NULL) {
|
||||
LOG_TRACE(TAG_FONT, F("File %s - Line %d - ascii_glyph_dsc init"), __FILE__, __LINE__);
|
||||
dsc->ascii_glyph_dsc = (lv_zifont_char_t*)lv_mem_alloc(sizeof(lv_zifont_char_t) * CHAR_CACHE_SIZE);
|
||||
LV_ASSERT_MEM(dsc->ascii_glyph_dsc);
|
||||
_lv_memset_00(dsc->ascii_glyph_dsc, sizeof(lv_zifont_char_t) * CHAR_CACHE_SIZE); // lv_mem_alloc might be dirty
|
||||
}
|
||||
|
||||
LOG_TRACE(TAG_FONT, F("File %s - Line %d"), __FILE__, __LINE__);
|
||||
|
||||
if(dsc->ascii_glyph_dsc == NULL) {
|
||||
file.close();
|
||||
return ZIFONT_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
LOG_TRACE(TAG_FONT, F("File %s - Line %d - Seerkset: %d"), __FILE__, __LINE__, dsc->Startdataaddress);
|
||||
|
||||
/* read charmap into cache */
|
||||
file.seek(0 * sizeof(zi_font_header_t) + dsc->Startdataaddress, SeekSet);
|
||||
|
||||
LOG_TRACE(TAG_FONT, F("File %s - Line %d"), __FILE__, __LINE__);
|
||||
|
||||
//* read and fill charmap cache
|
||||
readSize = file.readBytes((char*)dsc->ascii_glyph_dsc, sizeof(lv_zifont_char_t) * CHAR_CACHE_SIZE);
|
||||
|
||||
LOG_TRACE(TAG_FONT, F("File %s - Line %d"), __FILE__, __LINE__);
|
||||
|
||||
//* Check that we read the correct size
|
||||
if(readSize != sizeof(lv_zifont_char_t) * CHAR_CACHE_SIZE) {
|
||||
LOG_ERROR(TAG_FONT, F("Error reading ziFont character map"));
|
||||
@ -236,6 +261,8 @@ int lv_zifont_font_init(lv_font_t ** font, const char * font_path, uint16_t size
|
||||
/* header data struct */ /*The custom font data. Will be accessed by `get_glyph_bitmap/dsc` */
|
||||
(*font)->subpx = 0;
|
||||
|
||||
LOG_TRACE(TAG_FONT, F("File %s - Line %d"), __FILE__, __LINE__);
|
||||
|
||||
if((*font)->user_data != (char*)font_path) {
|
||||
if((*font)->user_data) free((*font)->user_data);
|
||||
(*font)->user_data = (char*)font_path;
|
||||
|
Loading…
x
Reference in New Issue
Block a user