mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-27 05:06:44 +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();
|
lv_zifont_init();
|
||||||
|
|
||||||
static lv_font_t font1;
|
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;
|
static lv_style_t ft_style;
|
||||||
lv_style_copy(&ft_style, &lv_style_plain);
|
lv_style_copy(&ft_style, &lv_style_plain);
|
||||||
|
@ -68,7 +68,7 @@ lv_zifont_char_t lastCharInfo; // Holds the last Glyph DSC
|
|||||||
|
|
||||||
#if ESP32
|
#if ESP32
|
||||||
// static lv_zifont_char_t charCache[256 - 32]; // glyphID DSC cache
|
// static lv_zifont_char_t charCache[256 - 32]; // glyphID DSC cache
|
||||||
#define CHAR_CACHE_SIZE 224
|
#define CHAR_CACHE_SIZE 95
|
||||||
#else
|
#else
|
||||||
#define CHAR_CACHE_SIZE 95
|
#define CHAR_CACHE_SIZE 95
|
||||||
// static lv_zifont_char_t charCache[256 - 32]; // glyphID DSC cache
|
// 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)
|
int lv_zifont_init(void)
|
||||||
{
|
{
|
||||||
|
FS.begin(true);
|
||||||
// charBitmap_p = (uint8_t *)lv_mem_alloc(32 * 32);
|
// charBitmap_p = (uint8_t *)lv_mem_alloc(32 * 32);
|
||||||
return LV_RES_OK; // OK
|
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);
|
LOG_ERROR(TAG_FONT, F("Opening font: %s"), filename);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
LOG_TRACE(TAG_FONT, F("Opening font: %s"), filename);
|
||||||
return file;
|
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
|
charInBuffer = 0; // invalidate any previous cache
|
||||||
|
|
||||||
if(!*font) {
|
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));
|
*font = (lv_font_t*)lv_mem_alloc(sizeof(lv_font_t));
|
||||||
LV_ASSERT_MEM(*font);
|
LV_ASSERT_MEM(*font);
|
||||||
_lv_memset_00(*font, sizeof(lv_font_t)); // lv_mem_alloc might be dirty
|
_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;
|
lv_font_fmt_zifont_dsc_t* dsc;
|
||||||
if(!(*font)->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));
|
dsc = (lv_font_fmt_zifont_dsc_t*)lv_mem_alloc(sizeof(lv_font_fmt_zifont_dsc_t));
|
||||||
LV_ASSERT_MEM(dsc);
|
LV_ASSERT_MEM(dsc);
|
||||||
_lv_memset_00(dsc, sizeof(lv_font_fmt_zifont_dsc_t)); // lv_mem_alloc might be dirty
|
_lv_memset_00(dsc, sizeof(lv_font_fmt_zifont_dsc_t)); // lv_mem_alloc might be dirty
|
||||||
|
dsc->ascii_glyph_dsc = NULL;
|
||||||
} else {
|
} else {
|
||||||
|
LOG_TRACE(TAG_FONT, F("File %s - Line %d - reuse font dsc"), __FILE__, __LINE__);
|
||||||
dsc = (lv_font_fmt_zifont_dsc_t*)(*font)->dsc;
|
dsc = (lv_font_fmt_zifont_dsc_t*)(*font)->dsc;
|
||||||
}
|
}
|
||||||
LV_ASSERT_MEM(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;
|
zi_font_header_t header;
|
||||||
size_t readSize = file.readBytes((char*)&header, sizeof(zi_font_header_t));
|
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 */
|
/* Check that we read the correct size */
|
||||||
if(readSize != sizeof(zi_font_header_t)) {
|
if(readSize != sizeof(zi_font_header_t)) {
|
||||||
LOG_ERROR(TAG_FONT, F("Error reading ziFont Header"));
|
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;
|
return ZIFONT_ERROR_READING_DATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LOG_TRACE(TAG_FONT, F("File %s - Line %d"), __FILE__, __LINE__);
|
||||||
|
|
||||||
/* Check ziFile Header Format */
|
/* Check ziFile Header Format */
|
||||||
if(header.Password != 4 || header.Version != 5) {
|
if(header.Password != 4 || header.Version != 5) {
|
||||||
LOG_ERROR(TAG_FONT, F("Unknown font file format"));
|
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;
|
return ZIFONT_ERROR_UNKNOWN_HEADER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LOG_TRACE(TAG_FONT, F("File %s - Line %d"), __FILE__, __LINE__);
|
||||||
|
|
||||||
dsc->CharHeight = header.CharHeight;
|
dsc->CharHeight = header.CharHeight;
|
||||||
dsc->CharWidth = header.CharWidth;
|
dsc->CharWidth = header.CharWidth;
|
||||||
dsc->Maximumnumchars = header.Maximumnumchars;
|
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->Startdataaddress = header.Startdataaddress + header.Descriptionlength;
|
||||||
dsc->Fontdataadd8byte = header.Fontdataadd8byte;
|
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);
|
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_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
|
_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) {
|
if(dsc->ascii_glyph_dsc == NULL) {
|
||||||
file.close();
|
file.close();
|
||||||
return ZIFONT_ERROR_OUT_OF_MEMORY;
|
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 */
|
/* read charmap into cache */
|
||||||
file.seek(0 * sizeof(zi_font_header_t) + dsc->Startdataaddress, SeekSet);
|
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
|
//* read and fill charmap cache
|
||||||
readSize = file.readBytes((char*)dsc->ascii_glyph_dsc, sizeof(lv_zifont_char_t) * CHAR_CACHE_SIZE);
|
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
|
//* Check that we read the correct size
|
||||||
if(readSize != sizeof(lv_zifont_char_t) * CHAR_CACHE_SIZE) {
|
if(readSize != sizeof(lv_zifont_char_t) * CHAR_CACHE_SIZE) {
|
||||||
LOG_ERROR(TAG_FONT, F("Error reading ziFont character map"));
|
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` */
|
/* header data struct */ /*The custom font data. Will be accessed by `get_glyph_bitmap/dsc` */
|
||||||
(*font)->subpx = 0;
|
(*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 != (char*)font_path) {
|
||||||
if((*font)->user_data) free((*font)->user_data);
|
if((*font)->user_data) free((*font)->user_data);
|
||||||
(*font)->user_data = (char*)font_path;
|
(*font)->user_data = (char*)font_path;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user