Memory optimizations

This commit is contained in:
fvanroie 2020-11-23 23:36:26 +01:00
parent f04d275154
commit 307f259a51
5 changed files with 21 additions and 17 deletions

View File

@ -260,13 +260,13 @@ const uint8_t * IRAM_ATTR lv_font_get_bitmap_fmt_zifont(const lv_font_t * font,
}
File file;
char filename[128];
char filename[32];
uint32_t glyphID;
uint16_t charmap_position;
if(unicode_letter >= 0xF000) {
//return NULL;
sprintf_P(filename, PSTR("/fontawesome%u.zi"), fdsc->CharHeight);
// return NULL;
snprintf_P(filename, sizeof(filename), PSTR("/fontawesome%u.zi"), fdsc->CharHeight);
charmap_position = 25 + sizeof(zi_font_header_t);
glyphID = unicode_letter - 0xf000; // start of fontawesome
} else {
@ -454,9 +454,9 @@ bool IRAM_ATTR lv_font_get_glyph_dsc_fmt_zifont(const lv_font_t * font, lv_font_
/* Open the font for reading */
if(unicode_letter >= 0xF000) {
// return false;
// return false;
char filename[32];
sprintf_P(filename, PSTR("/fontawesome%u.zi"), fdsc->CharHeight);
snprintf_P(filename, sizeof(filename), PSTR("/fontawesome%u.zi"), fdsc->CharHeight);
if(!openFont(file, filename)) return false;
} else {
if(!openFont(file, (char *)font->user_data)) return false;

View File

@ -241,7 +241,7 @@ static inline void haspSetLabelText(lv_obj_t * obj, const char * value)
}
// OK
static inline bool haspGetLabelText(lv_obj_t * obj, char * text)
static bool haspGetLabelText(lv_obj_t * obj, char * text)
{
if(!obj) {
Log.warning(TAG_ATTR, F("Button not defined"));
@ -909,7 +909,7 @@ static void hasp_process_obj_attribute_range(lv_obj_t * obj, const char * attr,
*/
void hasp_process_obj_attribute(lv_obj_t * obj, const char * attr_p, const char * payload, bool update)
{
unsigned long start = millis();
// unsigned long start = millis();
if(!obj) return Log.warning(TAG_ATTR, F("Unknown object"));
int16_t val = atoi(payload);
@ -1096,7 +1096,8 @@ void hasp_process_obj_attribute(lv_obj_t * obj, const char * attr_p, const char
}
hasp_local_style_attr(obj, attr, attr_hash, payload, update);
Log.verbose(TAG_ATTR, F("%s (%d) took %d ms."), attr_p, attr_hash, millis() - start);
Log.verbose(TAG_ATTR, F("%s (%d)"), attr_p, attr_hash);
// Log.verbose(TAG_ATTR, F("%s (%d) took %d ms."), attr_p, attr_hash, millis() - start);
}
/* **************************

View File

@ -503,9 +503,14 @@ void guiSetup()
/* allocate on heap */
static lv_disp_buf_t disp_buf;
static lv_color_t guiVdbBuffer1[4 * 512u]; // 4 KBytes
// static lv_color_t guiVdbBuffer2[3 * 1024u]; // 6 KBytes
guiVDBsize = sizeof(guiVdbBuffer1) / sizeof(guiVdbBuffer1[0]);
lv_disp_buf_init(&disp_buf, guiVdbBuffer1, NULL, guiVDBsize);
// static lv_disp_buf_t disp_buf;
// static lv_color_t * guiVdbBuffer1;
// guiVDBsize = 4 * 512u; // 4 KBytes * 2
// guiVdbBuffer1 = (lv_color_t *)malloc(sizeof(lv_color_t) * guiVDBsize);
// lv_disp_buf_init(&disp_buf, guiVdbBuffer1, NULL, guiVDBsize);
#else
static lv_disp_buf_t disp_buf;
static lv_color_t guiVdbBuffer1[16 * 512u]; // 16 KBytes

View File

@ -211,7 +211,7 @@ void hasp_send_obj_attribute_int(lv_obj_t * obj, const char * attribute, int32_t
void hasp_send_obj_attribute_color(lv_obj_t * obj, const char * attribute, lv_color_t color)
{
char buffer[128];
char buffer[16];
lv_color32_t c32;
c32.full = lv_color_to32(color);
snprintf(buffer, sizeof(buffer), PSTR("#%02x%02x%02x"), c32.ch.red, c32.ch.green, c32.ch.blue);

View File

@ -41,6 +41,11 @@ void setup()
configSetup(); // also runs debugPreSetup(), debugSetup() and debugStart()
dispatchSetup();
guiSetup();
debugSetup(); // Init the console
#if HASP_USE_GPIO > 0
gpioSetup();
#endif
/****************************
* Apply User Configuration
@ -54,9 +59,6 @@ void setup()
networkSetup();
#endif
debugSetup(); // Init the console
guiSetup();
if(!oobeSetup()) {
haspSetup();
}
@ -81,10 +83,6 @@ void setup()
slaveSetup();
#endif
#if HASP_USE_GPIO > 0
gpioSetup();
#endif
mainLastLoopTime = millis() - 1000; // reset loop counter
delay(250);
}