Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Elecrow ESP32 HMI support and initial TFT display POC #745

Merged
merged 38 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
99bfd6f
Initial addition of the elecrow_esp32_hmi boards
jeremypoulter Oct 5, 2023
2151248
Initialise the FSF screen
jeremypoulter Oct 6, 2023
f851b59
Removed LVGL for now and added some demo screens for the LCD
jeremypoulter Oct 11, 2023
5f88ed7
Initial code to render a boot screen and charging screen (with some r…
jeremypoulter Oct 13, 2023
36c3365
Adding PNG lib and tweaking the SPI speed≈
jeremypoulter Oct 14, 2023
03469f2
Limit the fonts we load
jeremypoulter Oct 14, 2023
40e5501
Render the boot screen as component parts so we can save flash space.
jeremypoulter Oct 14, 2023
4425505
Adding builds to the CI
jeremypoulter Oct 16, 2023
2df92a3
Update Charge screen
chris1howell Oct 16, 2023
a738ef6
Delete gui-tft/ChargeScreene.png
chris1howell Oct 17, 2023
d5e1219
Blanked Screen
chris1howell Oct 17, 2023
c05b752
Updated charging image
jeremypoulter Oct 18, 2023
8a8e1ba
Added rendering the text values
jeremypoulter Oct 18, 2023
58513a3
Get the live delivered power
jeremypoulter Oct 18, 2023
f79bfe1
Split out the bits of the charge screen that are a little harder to r…
jeremypoulter Oct 19, 2023
d95fb3d
Render a lot of more of the UI in software to make the update faster
jeremypoulter Oct 20, 2023
a99cdd4
Remaining values are now live
jeremypoulter Oct 23, 2023
0a96137
Updated to continually update the display
jeremypoulter Oct 24, 2023
aa0a7d8
Fixed flickering when updating the text, by rendering to a sprite first
jeremypoulter Oct 25, 2023
4c29270
Fixed flicker on progress bar update
jeremypoulter Oct 25, 2023
13a90e6
Use fill sprite as it can be faster
jeremypoulter Oct 25, 2023
3c055f9
Merge branch 'master' into elecrow_esp32_hmi
jeremypoulter Oct 25, 2023
83dfa20
Merge branch 'master' of github.com:OpenEVSE/ESP32_WiFi_V3.x into ele…
jeremypoulter Oct 31, 2023
69b3b7d
Adding status icons
jeremypoulter Nov 5, 2023
c41df86
Latest GUI
jeremypoulter Nov 5, 2023
5ef3b7f
Added switching the status icon
jeremypoulter Nov 5, 2023
ed7d7c4
Merge branch 'master' into elecrow_esp32_hmi
jeremypoulter Nov 13, 2023
bfb2514
Adding options to build for the new TFT OpenEVSE board
jeremypoulter Nov 13, 2023
79384cb
Ignore .pem files
jeremypoulter Nov 17, 2023
baea014
Moved LEDs to GPIO26 as GPIO10 conflicts with the internal flash chip
jeremypoulter Nov 20, 2023
eb3ce9a
Merge branch 'master' into elecrow_esp32_hmi
jeremypoulter Jan 29, 2024
d944e64
Swap the serial ports on the dev verion of OpenEVSE WiFi TFT so it is…
jeremypoulter Feb 4, 2024
5056653
Fix for crash during initial setup
jeremypoulter Feb 4, 2024
31d0788
Merge branch 'master' of github.com:OpenEVSE/ESP32_WiFi_V4.x into ele…
jeremypoulter Feb 4, 2024
98fc63b
Enabled 16MB flash on the TFT boards
jeremypoulter Feb 4, 2024
6069bd7
Fixed memory monitor to not depend on the OpenEVSE module being dete…
jeremypoulter Feb 4, 2024
f867740
Disabled debug messages
jeremypoulter Feb 4, 2024
fd44f89
Adding in some more initilisation/memory debug logs
jeremypoulter Feb 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ jobs:
- heltec_esp32-wifi-lora-v2
- wt32-eth01
- esp32-c3-devkitc-02
- elecrow_esp32_hmi
- elecrow_esp32_hmi_dev
- openevse_wifi_tft_v1
- openevse_wifi_tft_v1_dev
gui:
- name: gui-v2
repo: OpenEVSE/openevse-gui-v2
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,4 @@ lib/MicroTasks
*.bin
divert_sim/epoxyfsdata
divert_sim/epoxyeepromdata
*.pem
Binary file added 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 ChargeScreen.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/button_bar.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/car_connected.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/car_disconnected.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/charging.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/connected.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/disabled.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/error.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/logo.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/not_connected.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/sleeping.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/start.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion gui-v2
7 changes: 7 additions & 0 deletions openevse_16mb.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Name, Type, SubType, Offset, Size, Flags
nvs, data, nvs, 0x9000, 0x5000,
otadata, data, ota, 0xe000, 0x2000,
app0, app, ota_0, 0x10000, 0x640000,
app1, app, ota_1, 0x650000,0x640000,
spiffs, data, spiffs, 0xc90000,0x360000,
coredump, data, coredump,0xFF0000,0x10000,
100 changes: 100 additions & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ debug_flags =
#-D ENABLE_NOISY_PROFILE
#-D ENABLE_DEBUG_MICROTASKS
#-D ENABLE_DEBUG_ENERGY_METER
#-D ENABLE_DEBUG_MEMORY_MONITOR
src_build_flags =
# -D ARDUINOJSON_USE_LONG_LONG
# -D ENABLE_ASYNC_WIFI_SCAN
Expand Down Expand Up @@ -99,11 +100,60 @@ build_flags =
-D USE_ESP32
-D USE_ESP32_FRAMEWORK_ARDUINO
-D MG_MAX_HTTP_REQUEST_SIZE=8196
build_flags_openevse_tft =
${common.build_flags}
${common.src_build_flags}
${common.gfx_display_build_flags}
-D NEO_PIXEL_PIN=26
-D NEO_PIXEL_LENGTH=14
-D WIFI_PIXEL_NUMBER=1
-D WIFI_BUTTON=0
-D WIFI_BUTTON_PRESSED_STATE=LOW
build_partitions = min_spiffs.csv
build_partitions_debug = min_spiffs_debug.csv
build_partitions_16mb = openevse_16mb.csv

neopixel_lib = adafruit/Adafruit [email protected]

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

gfx_display_build_flags =
# -D LV_CONF_INCLUDE_SIMPLE
# -D LV_CONF_SUPPRESS_DEFINE_CHECK
-D USER_SETUP_LOADED
-D ILI9488_DRIVER
-D TFT_WIDTH=320
-D TFT_HEIGHT=480
-D TFT_BL=27
-D TFT_MISO=12
-D TFT_MOSI=13
-D TFT_SCLK=14
-D TFT_CS=15
-D TFT_DC=2
-D TFT_RST=-1
-D TOUCH_CS=33
# -D LOAD_GLCD
# -D LOAD_FONT2
# -D LOAD_FONT4
# -D LOAD_FONT6
# -D LOAD_FONT7
# -D LOAD_FONT8
-D LOAD_GFXFF
# -D SMOOTH_FONT
# -D SPI_FREQUENCY=15999999
# -D SPI_FREQUENCY=20000000
# -D SPI_FREQUENCY=27000000
-D SPI_FREQUENCY=40000000
# -D SPI_FREQUENCY=55000000
# -D SPI_FREQUENCY=65000000
# -D SPI_FREQUENCY=80000000
-D SPI_READ_FREQUENCY=20000000
-D SPI_TOUCH_FREQUENCY=600000
-D ENABLE_SCREEN_LCD_TFT

[env]
# specify exact Arduino ESP SDK version, requires platformio 3.5+ (curently dev version)
Expand Down Expand Up @@ -358,3 +408,53 @@ build_flags =
-D NEO_PIXEL_PIN=8
-D NEO_PIXEL_LENGTH=1
-D WIFI_PIXEL_NUMBER=1

[env:elecrow_esp32_hmi]
board = denky32
build_flags =
${common.build_flags}
${common.src_build_flags}
-D DEBUG_PORT=Serial
-D RAPI_PORT=Serial1
-D RX1=16
-D TX1=17
lib_deps =
${common.lib_deps}
${common.gfx_display_libs}

[env:elecrow_esp32_hmi_dev]
extends = env:elecrow_esp32_hmi
build_flags =
${env:elecrow_esp32_hmi.build_flags}
${common.debug_flags}
${common.gfx_display_build_flags}
upload_protocol = custom
upload_command = curl -F firmware=@$SOURCE http://$UPLOAD_PORT/update
#build_type = debug
#board_build.partitions = ${common.build_partitions_debug}

[env:openevse_wifi_tft_v1]
board = denky32
build_flags =
${common.build_flags_openevse_tft}
-D DEBUG_PORT=Serial2
-D RAPI_PORT=Serial
lib_deps =
${common.lib_deps}
${common.gfx_display_libs}
${common.neopixel_lib}
board_build.partitions = ${common.build_partitions_16mb}
board_upload.flash_size = 16MB
board_build.flash_mode = qio
board_build.f_flash = 80000000L

[env:openevse_wifi_tft_v1_dev]
extends = env:openevse_wifi_tft_v1
build_flags =
${common.build_flags_openevse_tft}
${common.debug_flags}
-D DEBUG_PORT=Serial
-D RAPI_PORT=Serial2
#upload_protocol = custom
#upload_command = curl -F firmware=@$SOURCE http://$UPLOAD_PORT/update
build_type = debug
35 changes: 23 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,19 @@ 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):
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:
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 +183,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 +195,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 +205,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'])
26 changes: 26 additions & 0 deletions src/embedded_files.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#if defined(ENABLE_DEBUG) && !defined(ENABLE_DEBUG_EMBEDDED_FILES)
#undef ENABLE_DEBUG
#endif

#include "embedded_files.h"
#include "emonesp.h"

bool embedded_get_file(String filename, StaticFile *index, size_t length, StaticFile **file)
{
DBUGF("Looking for %s", filename.c_str());

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

if(file) {
*file = &index[i];
}
return true;
}
}

return false;
}
22 changes: 22 additions & 0 deletions src/embedded_files.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#ifndef EMBEDDED_FILES_H
#define EMBEDDED_FILES_H

#include <Arduino.h>

#define ARRAY_LENGTH(x) (sizeof(x)/sizeof((x)[0]))

#define IS_ALIGNED(x) (0 == ((uint32_t)(x) & 0x3))

struct StaticFile
{
const char *filename;
const char *data;
size_t length;
const char *type;
const char *etag;
bool compressed;
};

bool embedded_get_file(String filename, StaticFile *index, size_t length, StaticFile **file);

#endif // EMBEDDED_FILES_H
4 changes: 4 additions & 0 deletions src/lcd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#undef ENABLE_DEBUG
#endif

#ifndef ENABLE_SCREEN_LCD_TFT

#include "emonesp.h"
#include "lcd.h"
#include "RapiSender.h"
Expand Down Expand Up @@ -734,3 +736,5 @@ void LcdTask::onButton(int long_press)
}

LcdTask lcd;

#endif // ENABLE_SCREEN_LCD_TFT
12 changes: 10 additions & 2 deletions src/lcd.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@
#define LCD_CLEAR_LINE (1 << 0)
#define LCD_DISPLAY_NOW (1 << 1)

#define LCD_MAX_LEN 16

#ifndef LCD_DISPLAY_CHANGE_TIME
#define LCD_DISPLAY_CHANGE_TIME (4 * 1000)
#endif

#if ENABLE_SCREEN_LCD_TFT
// HACK: This should be done in a much more C++ way
#include "lcd_tft.h"
#else

#define LCD_MAX_LEN 16

#define LCD_CHAR_STOP 1
#define LCD_CHAR_PLAY 2
#define LCD_CHAR_LIGHTNING 3
Expand Down Expand Up @@ -151,6 +156,9 @@ class LcdTask : public MicroTasks::Task
void display(const char *msg, int x, int y, int time, uint32_t flags);
};

#endif // ENABLE_SCREEN_LCD_TFT

extern LcdTask lcd;

#endif // __LCD_H

Loading
Loading