Skip to content

Commit

Permalink
Render the boot screen as component parts so we can save flash space.
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremypoulter committed Oct 14, 2023
1 parent 03469f2 commit 40e5501
Show file tree
Hide file tree
Showing 6 changed files with 1,241 additions and 9 deletions.
File renamed without changes
Binary file added gui-tft/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1,208 changes: 1,208 additions & 0 deletions src/lcd_static/lcd_gui.logo_png.h

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/lcd_static/lcd_gui_static_files.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "lcd_gui.BootScreen_png.h"
#include "lcd_gui.ChargeScreen_png.h"
#include "lcd_gui.logo_png.h"
StaticFile lcd_gui_static_files[] = {
{ "/BootScreen.png", CONTENT_BOOTSCREEN_PNG, sizeof(CONTENT_BOOTSCREEN_PNG) - 1, _CONTENT_TYPE_PNG, CONTENT_BOOTSCREEN_PNG_ETAG, false },
{ "/ChargeScreen.png", CONTENT_CHARGESCREEN_PNG, sizeof(CONTENT_CHARGESCREEN_PNG) - 1, _CONTENT_TYPE_PNG, CONTENT_CHARGESCREEN_PNG_ETAG, false },
{ "/logo.png", CONTENT_LOGO_PNG, sizeof(CONTENT_LOGO_PNG) - 1, _CONTENT_TYPE_PNG, CONTENT_LOGO_PNG_ETAG, false },
};
37 changes: 30 additions & 7 deletions src/lcd_tft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
#include "app_config.h"
#include <sys/time.h>
#include "embedded_files.h"
//#include "fonts/DejaVu_Sans_72.h"

#define TFT_OPENEVSE_BACK 0x2413
#define TFT_OPENEVSE_GREEN 0x3E92

#include "web_server.h"

Expand Down Expand Up @@ -77,7 +81,10 @@ unsigned long LcdTask::loop(MicroTasks::WakeReason reason)
_lcd.begin();
_lcd.setRotation(1);

render_image("/BootScreen.png", 0, 0);
_lcd.fillScreen(TFT_OPENEVSE_BACK);
_lcd.fillSmoothRoundRect(90, 90, 300, 110, 15, TFT_WHITE);
_lcd.fillSmoothRoundRect(90, 235, 300, 16, 8, TFT_OPENEVSE_GREEN);
render_image("/logo.png", 104, 115);

pinMode(LCD_BACKLIGHT_PIN, OUTPUT);
digitalWrite(LCD_BACKLIGHT_PIN, HIGH);
Expand All @@ -88,12 +95,16 @@ unsigned long LcdTask::loop(MicroTasks::WakeReason reason)
case State::Charge:
render_image("/ChargeScreen.png", 0, 0);

_lcd.setCursor(0, 0, 2);
_lcd.setTextColor(TFT_WHITE, TFT_BLACK);
_lcd.setTextSize(2);
_lcd.print("OpenEVSE");
_lcd.setCursor(0, 16);
_lcd.print("WiFi Connected");
_lcd.setCursor(120, 180);
_lcd.setTextColor(TFT_BLACK, TFT_WHITE);
// _lcd.setFreeFont(&DejaVu_Sans_72);
// _lcd.setTextSize(1);
_lcd.setFreeFont(&FreeSans24pt7b);
_lcd.setTextSize(3);
_lcd.print("16");
_lcd.setFreeFont(&FreeSans24pt7b);
_lcd.setTextSize(1);
_lcd.println("A");

break;

Expand Down Expand Up @@ -127,6 +138,18 @@ void LcdTask::render_image(const char *filename, int16_t x, int16_t y)
}
}

#ifdef SMOOTH_FONT
void LcdTask::load_font(const char *filename)
{
StaticFile *file = NULL;
if(embedded_get_file(filename, lcd_gui_static_files, ARRAY_LENGTH(lcd_gui_static_files), &file))
{
DBUGF("Found %s (%d bytes)", filename, file->length);
_lcd.loadFont((uint8_t *)file->data);
}
}
#endif

void LcdTask::png_draw(PNGDRAW *pDraw)
{
image_render_state *state = (image_render_state *)pDraw->pUser;
Expand Down
1 change: 1 addition & 0 deletions src/lcd_tft.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class LcdTask : public MicroTasks::Task
unsigned long loop(MicroTasks::WakeReason reason);

void render_image(const char *filename, int16_t x, int16_t y);
void load_font(const char *filename);

public:
LcdTask();
Expand Down

0 comments on commit 40e5501

Please sign in to comment.