-
Notifications
You must be signed in to change notification settings - Fork 4
/
PlatformioScripts.py
executable file
·37 lines (28 loc) · 1.01 KB
/
PlatformioScripts.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
Import("env")
import os
from firmware import reset_firmware
if os.path.isfile('UserPatcher.py'):
from UserPatcher import patch_esp32
def run_patch(target, source, env):
patch_esp32(str(target[0]))
env.AddPostAction("$BUILD_DIR/${PROGNAME}.elf", [run_patch])
def before_upload(target, source, env):
do_reset = env.GetProjectOption("reset_before_after_flash", default='false')
if 'true' in do_reset:
monitor_port = env.GetProjectOption("monitor_port", default=None)
if monitor_port:
try:
reset_firmware(monitor_port)
except Exception as err:
print(err)
def after_upload(target, source, env):
do_reset = env.GetProjectOption("reset_before_after_flash", default='false')
if 'true' in do_reset:
monitor_port = env.GetProjectOption("monitor_port", default=None)
if monitor_port:
try:
reset_firmware(monitor_port)
except Exception as err:
print(err)
env.AddPreAction("upload", [before_upload])
env.AddPostAction("upload", [after_upload])