Skip to content

Commit 5056653

Browse files
committed
Fix for crash during initial setup
1 parent d944e64 commit 5056653

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/lcd_tft.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,11 @@ unsigned long LcdTask::loop(MicroTasks::WakeReason reason)
154154

155155
TFT_eSprite sprite(&_screen);
156156
uint16_t *pixels = (uint16_t *)sprite.createSprite(BOOT_PROGRESS_WIDTH, BOOT_PROGRESS_HEIGHT);
157+
if(nullptr == pixels)
158+
{
159+
DBUGF("Failed to create sprite for boot progress %d x %d", BOOT_PROGRESS_WIDTH, BOOT_PROGRESS_HEIGHT);
160+
break;
161+
}
157162
sprite.fillSprite(TFT_OPENEVSE_BACK);
158163
sprite.fillRoundRect(0, 0, BOOT_PROGRESS_WIDTH, BOOT_PROGRESS_HEIGHT, 8, TFT_WHITE);
159164
if(_boot_progress > 0) {
@@ -322,6 +327,11 @@ void LcdTask::render_text_box(const char *text, int16_t x, int16_t y, int16_t te
322327

323328
int16_t height = sprite.fontHeight();
324329
uint16_t *pixels = (uint16_t *)sprite.createSprite(width, height);
330+
if(nullptr == pixels)
331+
{
332+
DBUGF("Failed to create sprite for text box %d x %d", width, height);
333+
return;
334+
}
325335

326336
sprite.fillSprite(back_colour);
327337
sprite.drawString(text, text_x, height);

0 commit comments

Comments
 (0)