Skip to content

Commit

Permalink
Merge pull request #260 from OpenEVSE/new-divert
Browse files Browse the repository at this point in the history
Divert mode back-port
  • Loading branch information
glynhudson authored Jul 14, 2020
2 parents 2fd7b55 + 0167ebf commit 6e05310
Show file tree
Hide file tree
Showing 48 changed files with 2,854 additions and 1,469 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,6 @@ ubuntu-xenial-16.04-cloudimg-console.log
.vscode/*.db
.vscode/launch.json
.vscode/.browse.c_cpp.db*
lib/ConfigJson
lib/ESPAL
lib/OpenEVSE
61 changes: 43 additions & 18 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,47 @@ data_dir = src/data
default_envs = openevse

[common]
version = -DBUILD_TAG=2.8.1
version = -DBUILD_TAG=2.9.0
monitor_speed=115200
lib_deps = [email protected], ESP Async [email protected], [email protected]
lib_deps =
[email protected]
ESP Async [email protected]
[email protected]
[email protected]
Micro [email protected]
[email protected]
[email protected]
[email protected]
extra_scripts = scripts/extra_script.py
debug_flags = -DENABLE_DEBUG -DENABLE_PROFILE -DDEBUG_PORT=Serial1
ota_flags = -DENABLE_OTA -DWIFI_LED=0
debug_flags =
-DENABLE_DEBUG
# -DENABLE_DEBUG_WEB
# -DENABLE_DEBUG_RAPI
-DENABLE_PROFILE
-DDEBUG_PORT=Serial1
ota_flags =
-DENABLE_OTA
-DWIFI_LED=0
src_build_flags =
# -DENABLE_ASYNC_WIFI_SCAN

build_flags =
# -DENABLE_ASYNC_WIFI_SCAN

# specify exact Arduino ESP SDK version, requires platformio 3.5+ (curently dev version)
# http://docs.platformio.org/en/latest/projectconf/section_env_general.html#platform
platform = https://github.com/platformio/platform-espressif8266.git#release/v1.6.0
platform_stage = https://github.com/platformio/platform-espressif8266.git#feature/stage
#platform = https://github.com/platformio/platform-espressif8266.git#release/v1.6.0
platform = [email protected]
platform_stage = https://github.com/platformio/platform-espressif8266.git#develop

[env:openevse]
platform = ${common.platform}
board = esp12e
framework = arduino
lib_deps = ${common.lib_deps}
src_build_flags = ${common.version} ${common.build_flags}
build_flags = ${common.build_flags}
src_build_flags = ${common.version} ${common.src_build_flags}
# Upload at faster baud: takes 20s instead of 50s. Use 'pio run -t upload -e evse_slow to use slower default baud rate'
upload_speed=921600
upload_speed = 921600
monitor_speed = ${common.monitor_speed}
extra_scripts = ${common.extra_scripts}

Expand All @@ -60,7 +79,8 @@ platform = ${common.platform}
board = esp12e
framework = arduino
lib_deps = ${common.lib_deps}
src_build_flags = ${common.version} ${common.build_flags}
build_flags = ${common.build_flags}
src_build_flags = ${common.version} ${common.src_build_flags}
monitor_speed = ${common.monitor_speed}
extra_scripts = ${common.extra_scripts}

Expand All @@ -69,9 +89,10 @@ platform = ${common.platform}
board = esp12e
framework = arduino
lib_deps = ${common.lib_deps}
src_build_flags = ${common.version}.dev ${common.build_flags} ${common.ota_flags} ${common.debug_flags}
upload_protocol = espota
upload_port = openevse.local
build_flags = ${common.build_flags} ${common.debug_flags}
src_build_flags = ${common.version}.dev ${common.src_build_flags} ${common.ota_flags} ${common.debug_flags}
#upload_protocol = espota
#upload_port = openevse.local
monitor_speed = ${common.monitor_speed}
extra_scripts = ${common.extra_scripts}

Expand All @@ -80,8 +101,10 @@ platform = ${common.platform}
board = esp12e
framework = arduino
lib_deps = ${common.lib_deps}
src_build_flags = ${common.version}.dev ${common.build_flags} ${common.ota_flags} ${common.debug_flags}
upload_speed=921600
build_flags = ${common.build_flags} ${common.debug_flags}
src_build_flags = ${common.version}.dev ${common.src_build_flags} ${common.ota_flags} ${common.debug_flags}
# Upload at faster baud: takes 20s instead of 50s. Use 'pio run -t upload -e evse_slow to use slower default baud rate'
upload_speed = 921600
monitor_speed = ${common.monitor_speed}
extra_scripts = ${common.extra_scripts}

Expand All @@ -92,8 +115,9 @@ platform = ${common.platform_stage}
board = esp12e
framework = arduino
lib_deps = ${common.lib_deps}
build_flags = -DDEBUG_ESP_WIFI
src_build_flags = ${common.version}.stag ${common.build_flags} ${common.ota_flags} ${common.debug_flags}
build_flags = ${common.build_flags} ${common.debug_flags}
src_build_flags = ${common.version}.stag ${common.src_build_flags} ${common.ota_flags} ${common.debug_flags}
#upload_speed = 921600
upload_protocol = espota
upload_port = openevse.local
monitor_speed = ${common.monitor_speed}
Expand All @@ -105,7 +129,8 @@ platform = ${common.platform_stage}
board = esp12e
framework = arduino
lib_deps = https://github.com/knolleary/pubsubclient, https://github.com/me-no-dev/ESPAsyncWebServer.git, https://github.com/me-no-dev/ESPAsyncTCP.git
src_build_flags = ${common.version}.stagelib ${common.build_flags} ${common.ota_flags} ${common.debug_flags}
build_flags = ${common.build_flags} ${common.debug_flags}
src_build_flags = ${common.version}.stagelib ${common.src_build_flags} ${common.ota_flags} ${common.debug_flags}
upload_protocol = espota
upload_port = openevse.local
monitor_speed = ${common.monitor_speed}
Expand Down
12 changes: 7 additions & 5 deletions scripts/extra_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def get_c_name(source_file):

def text_to_header(source_file):
with open(source_file) as source_fh:
original = source_fh.read().decode('utf-8')
original = source_fh.read()
filename = get_c_name(source_file)
output = "static const char CONTENT_{}[] PROGMEM = ".format(filename)
for line in original.splitlines():
Expand All @@ -38,7 +38,7 @@ def binary_to_header(source_file):

with open(source_file, "rb") as source_fh:
byte = source_fh.read(1)
while byte != "":
while byte != b"":
output += "0x{:02x}, ".format(ord(byte))
count += 1
if 16 == count:
Expand All @@ -55,14 +55,14 @@ def data_to_header(env, target, source):
for source_file in source:
#print("Reading {}".format(source_file))
file = source_file.get_abspath()
if file.endswith(".css") or file.endswith(".js") or file.endswith(".htm") or file.endswith(".html"):
if file.endswith(".css") or file.endswith(".js") or file.endswith(".htm") or file.endswith(".html") or file.endswith(".svg"):
output += text_to_header(file)
else:
output += binary_to_header(file)
target_file = target[0].get_abspath()
print("Generating {}".format(target_file))
with open(target_file, "w") as output_file:
output_file.write(output.encode('utf-8'))
output_file.write(output)

def make_static(env, target, source):
output = ""
Expand Down Expand Up @@ -94,6 +94,8 @@ def make_static(env, target, source):
filetype = "JPEG"
elif out_file.endswith(".png"):
filetype = "PNG"
elif out_file.endswith(".svg"):
filetype = "SVG"

c_name = get_c_name(out_file)
output += " { \"/"+out_file+"\", CONTENT_"+c_name+", sizeof(CONTENT_"+c_name+") - 1, _CONTENT_TYPE_"+filetype+" },\n"
Expand All @@ -103,7 +105,7 @@ def make_static(env, target, source):
target_file = target[0].get_abspath()
print("Generating {}".format(target_file))
with open(target_file, "w") as output_file:
output_file.write(output.encode('utf-8'))
output_file.write(output)

def process_html_app(source, dest, env):
web_server_static_files = join(dest, "web_server_static_files.h")
Expand Down
Loading

3 comments on commit 6e05310

@Edison517
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated my OpenEVSE to 2.9.0 recently; I didn't see much change other than it kinda broke my data.openevse.com dashboard......not a big deal, but I downgraded back to 2.8.2 in the meantime. Just FYI.

@jeremypoulter
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you give more details about what broke?

@Edison517
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see this error, and the current kW Usage value is always zero:
This is using a custom dashboard, but it should still work no?

EmonCMS Error

Message: TypeError: data[(data.length - 1)] is undefined
Route: vis/realtime?embed=1&feedid=13719&colour=000000&initzoom=1&kw=0
Line: 118
Column: 15

Please sign in to comment.