Skip to content

Commit

Permalink
Removed LVGL for now and added some demo screens for the LCD
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremypoulter committed Oct 11, 2023
1 parent 2151248 commit f851b59
Show file tree
Hide file tree
Showing 11 changed files with 3,537 additions and 58 deletions.
Binary file added gui-tft/BootScreen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gui-tft/ChargeScreen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,13 @@ build_partitions_debug = min_spiffs_debug.csv
neopixel_lib = adafruit/Adafruit [email protected]

gfx_display_libs =
lvgl/[email protected]
# lvgl/[email protected]
bodmer/TFT_eSPI@^2.5.31
SPI

gfx_display_build_flags =
-D LV_CONF_INCLUDE_SIMPLE
-D LV_CONF_SUPPRESS_DEFINE_CHECK
# -D LV_CONF_INCLUDE_SIMPLE
# -D LV_CONF_SUPPRESS_DEFINE_CHECK
-D USER_SETUP_LOADED
-D ILI9488_DRIVER
-D TFT_WIDTH=320
Expand Down
38 changes: 26 additions & 12 deletions scripts/extra_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,20 +102,26 @@ def make_safe(file):
for c in chars:
if c in file:
file = file.replace(c, "_")

return file

def make_static(env, target, source):
def make_static_web(env, target, source):
return make_static(env, target, source, "web_server", dist_dir)

def make_static_lcd(env, target, source):
return make_static(env, target, source, "lcd_gui", lcd_gui_dir)

def make_static(env, target, source, prefix, files_dir):
output = ""

out_files = filtered_listdir(dist_dir)
out_files = filtered_listdir(files_dir)

# include the files
for out_file in out_files:
filename = "web_server."+make_safe(out_file)+".h"
filename = prefix+"."+make_safe(out_file)+".h"
output += "#include \"{}\"\n".format(filename)

output += "StaticFile staticFiles[] = {\n"
output += "StaticFile "+prefix+"_static_files[] = {\n"

for out_file in out_files:
filetype = None
Expand Down Expand Up @@ -156,19 +162,22 @@ def make_static(env, target, source):
with open(target_file, "w") as output_file:
output_file.write(output)

def process_html_app(source, dest, env):
web_server_static_files = join(dest, "web_server_static_files.h")
web_server_static = join(env.subst("$BUILD_DIR"), "src/web_server_static.cpp.o")
def process_html_app(source, dest, env, prefix, static_func):
print("Processing HTML app in {}".format(source))

web_server_static_files = join(dest, prefix+"_static_files.h")
web_server_static = join(env.subst("$BUILD_DIR"), "src/"+prefix+"_static.cpp.o")

files = filtered_listdir(source)

for file in files:
print(" {}".format(file))
data_file = join(source, file)
header_file = join(dest, "web_server."+make_safe(file)+".h")
header_file = join(dest, prefix+"."+make_safe(file)+".h")
env.Command(header_file, data_file, data_to_header)
env.Depends(web_server_static_files, header_file)

env.Depends(web_server_static, env.Command(web_server_static_files, source, make_static))
env.Depends(web_server_static, env.Command(web_server_static_files, source, static_func))

#
# Generate Web app resources
Expand All @@ -177,7 +186,7 @@ def process_html_app(source, dest, env):
headers_src = join(env.subst("$PROJECTSRC_DIR"), "web_static")

gui_name = environ.get("GUI_NAME")
if gui_name in (None, ""):
if gui_name in (None, ""):
gui_name = "gui-v2"

gui_dir = join(env.subst("$PROJECT_DIR"), gui_name)
Expand All @@ -189,7 +198,7 @@ def process_html_app(source, dest, env):
# Check to see if the Node modules have been downloaded
if(isdir(node_modules)):
if(isdir(dist_dir)):
process_html_app(dist_dir, headers_src, env)
process_html_app(dist_dir, headers_src, env, "web_server", make_static_web)
else:
print("Warning: GUI not built, run 'cd %s; npm run build'" % (gui_dir))
else:
Expand All @@ -199,4 +208,9 @@ def process_html_app(source, dest, env):
else:
print("Warning: Node.JS and NPM required to update the UI")

# LCD GUI files
lcd_gui_dir = join(env.subst("$PROJECT_DIR"), "gui-tft")
headers_src = join(env.subst("$PROJECTSRC_DIR"), "lcd_static")
process_html_app(lcd_gui_dir, headers_src, env, "lcd_gui", make_static_lcd)

print("PATH="+env['ENV']['PATH'])
1,387 changes: 1,387 additions & 0 deletions src/lcd_static/lcd_gui.BootScreen_png.h

Large diffs are not rendered by default.

2,097 changes: 2,097 additions & 0 deletions src/lcd_static/lcd_gui.ChargeScreen_png.h

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions src/lcd_static/lcd_gui_static_files.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include "lcd_gui.BootScreen_png.h"
#include "lcd_gui.ChargeScreen_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 },
};
44 changes: 12 additions & 32 deletions src/lcd_tft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,20 @@
#include "app_config.h"
#include <sys/time.h>

void LcdTask::displayFlush( lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p )
{
uint32_t w = ( area->x2 - area->x1 + 1 );
uint32_t h = ( area->y2 - area->y1 + 1 );
#include "web_server.h"

lcd._lcd.startWrite();
lcd._lcd.setAddrWindow( area->x1, area->y1, w, h );
lcd._lcd.pushColors( ( uint16_t * )&color_p->full, w * h, true );
lcd._lcd.endWrite();
// Static files
struct StaticFile
{
const char *filename;
const char *data;
size_t length;
const char *type;
const char *etag;
bool compressed;
};

lv_disp_flush_ready( disp );
}
#include "lcd_static/lcd_gui_static_files.h"

LcdTask::LcdTask() :
MicroTasks::Task(),
Expand Down Expand Up @@ -56,8 +58,6 @@ void LcdTask::setup()
{
DBUGLN("LCD UI setup");

//lv_init();

_lcd.begin();
_lcd.setRotation(1);
_lcd.fillScreen(TFT_BLACK);
Expand All @@ -66,26 +66,6 @@ void LcdTask::setup()

pinMode(LCD_BACKLIGHT_PIN, OUTPUT);
digitalWrite(LCD_BACKLIGHT_PIN, HIGH);

//size_t bufferSize = _screenWidth * _screenHeight / 13;
//_buf1 = ( lv_color_t * )malloc( bufferSize * sizeof( lv_color_t ) );
//lv_disp_draw_buf_init( &_draw_buf, _buf1, NULL, bufferSize );
//
//static lv_disp_drv_t disp_drv;
//lv_disp_drv_init( &disp_drv );
//
//disp_drv.hor_res = _screenWidth;
//disp_drv.ver_res = _screenHeight;
//disp_drv.flush_cb = displayFlush;
//disp_drv.draw_buf = &_draw_buf;
//lv_disp_drv_register( &disp_drv );

// static lv_indev_drv_t indev_drv;
// lv_indev_drv_init( &indev_drv );
// indev_drv.type = LV_INDEV_TYPE_POINTER;
// indev_drv.read_cb = my_touchpad_read;
// lv_indev_drv_register( &indev_drv );

}

unsigned long LcdTask::loop(MicroTasks::WakeReason reason)
Expand Down
7 changes: 1 addition & 6 deletions src/lcd_tft.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "scheduler.h"
#include "manual.h"

#include <lvgl.h>
//#include <lvgl.h>
#include <TFT_eSPI.h>


Expand All @@ -24,11 +24,6 @@ class LcdTask : public MicroTasks::Task
const uint16_t _screenWidth = TFT_HEIGHT;
const uint16_t _screenHeight = TFT_WIDTH;

lv_disp_draw_buf_t _draw_buf;
lv_color_t *_buf1;

static void displayFlush(lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p);

protected:
void setup();
unsigned long loop(MicroTasks::WakeReason reason);
Expand Down
8 changes: 4 additions & 4 deletions src/web_server_static.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ static bool web_static_get_file(MongooseHttpServerRequest *request, StaticFile *

DBUGF("Looking for %s", path.c_str());

for(int i = 0; i < ARRAY_LENGTH(staticFiles); i++) {
if(path == staticFiles[i].filename)
for(int i = 0; i < ARRAY_LENGTH(web_server_static_files); i++) {
if(path == web_server_static_files[i].filename)
{
DBUGF("Found %s %d@%p", staticFiles[i].filename, staticFiles[i].length, staticFiles[i].data);
DBUGF("Found %s %d@%p", web_server_static_files[i].filename, web_server_static_files[i].length, web_server_static_files[i].data);

if(file) {
*file = &staticFiles[i];
*file = &web_server_static_files[i];
}
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/web_static/web_server_static_files.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include "web_server.pwa_masquable_png.h"
#include "web_server.success_html.h"
#include "web_server.sw_js.h"
StaticFile staticFiles[] = {
StaticFile web_server_static_files[] = {
{ "/assets/components-47d1a95a.js", CONTENT_COMPONENTS_47D1A95A_JS_GZ, sizeof(CONTENT_COMPONENTS_47D1A95A_JS_GZ) - 1, _CONTENT_TYPE_JS, CONTENT_COMPONENTS_47D1A95A_JS_GZ_ETAG, true },
{ "/assets/components-a2a8801e.css", CONTENT_COMPONENTS_A2A8801E_CSS_GZ, sizeof(CONTENT_COMPONENTS_A2A8801E_CSS_GZ) - 1, _CONTENT_TYPE_CSS, CONTENT_COMPONENTS_A2A8801E_CSS_GZ_ETAG, true },
{ "/assets/config-11d9d5f0.js", CONTENT_CONFIG_11D9D5F0_JS_GZ, sizeof(CONTENT_CONFIG_11D9D5F0_JS_GZ) - 1, _CONTENT_TYPE_JS, CONTENT_CONFIG_11D9D5F0_JS_GZ_ETAG, true },
Expand Down

0 comments on commit f851b59

Please sign in to comment.