From 0363ba4379d4eb2d11acca34b076fc9555f49911 Mon Sep 17 00:00:00 2001 From: Thomas Hooge Date: Sun, 15 Feb 2026 13:13:19 +0100 Subject: [PATCH] Add feature to optionally apply patches to gateway code --- lib/obp60task/extra_task.py | 30 ++++++++++++++++++++++++++++-- lib/obp60task/platformio.ini | 2 ++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/lib/obp60task/extra_task.py b/lib/obp60task/extra_task.py index 28e9980..66ee3b1 100644 --- a/lib/obp60task/extra_task.py +++ b/lib/obp60task/extra_task.py @@ -1,12 +1,21 @@ # PlatformIO extra script for obp60task +import subprocess + +patching = False + epdtype = "unknown" pcbvers = "unknown" for x in env["BUILD_FLAGS"]: - if x.startswith("-D HARDWARE_"): + if not x.startswith('-D'): + continue + opt = x[2:].strip() + if opt.startswith("HARDWARE_"): pcbvers = x.split('_')[1] - if x.startswith("-D DISPLAY_"): + elif opt.startswith("DISPLAY_"): epdtype = x.split('_')[1] + elif opt == 'ENABLE_PATCHES': + patching = True propfilename = os.path.join(env["PROJECT_LIBDEPS_DIR"], env["PIOENV"], "GxEPD2/library.properties") properties = {} @@ -28,3 +37,20 @@ except: env["CPPDEFINES"].extend([("BOARD", env["BOARD"]), ("EPDTYPE", epdtype), ("PCBVERS", pcbvers), ("GXEPD2VERS", gxepd2vers)]) print("added hardware info to CPPDEFINES") + +if patching: + # apply patches to gateway code + print("applying gateway patches") + patchdir = os.path.join(os.path.dirname(script), "patches") + if not os.path.isdir(patchdir): + print("patchdir not found, no patches applied") + else: + patchfiles = [f for f in os.listdir(patchdir)] + for p in patchfiles: + patch = os.path.join(patchdir, p) + print(f"applying {patch}") + res = subprocess.run(["git", "apply", patch], capture_output=True, text=True) + if res.returncode != 0: + print(res.stderr) + else: + print("no patches found") diff --git a/lib/obp60task/platformio.ini b/lib/obp60task/platformio.ini index 63468c3..03a5463 100644 --- a/lib/obp60task/platformio.ini +++ b/lib/obp60task/platformio.ini @@ -58,6 +58,7 @@ build_flags= # -D DISPLAY_GYE042A87 #alternativ E-Ink display from Genyo Optical, R10 2.2 ohm - medium # -D DISPLAY_SE0420NQ04 #alternativ E-Ink display from SID Technology, R10 2.2 ohm - bad (burn in effects) # -D DISPLAY_ZJY400300-042CAAMFGN #alternativ E-Ink display from ZZE Technology, R10 2.2 ohm - very good +# -D ENABLE_PATCHES #enable patching of gateway code ${env.build_flags} #CONFIG_ESP_TASK_WDT_TIMEOUT_S = 10 #Task Watchdog timeout period (seconds) [1...60] 5 default upload_port = /dev/ttyACM0 #OBP60 download via USB-C direct @@ -108,6 +109,7 @@ build_flags= #-D DISPLAY_ZJY400300-042CAAMFGN #alternativ E-Ink display from ZZE Technology, R10 2.2 ohm - very good -D LIPO_ACCU_1200 #Hardware extension, LiPo accu 3,7V 1200mAh -D VOLTAGE_SENSOR #Hardware extension, LiPo voltage sensor with two resistors + #-D ENABLE_PATCHES #enable patching of gateway code ${env.build_flags} upload_port = /dev/ttyUSB0 #OBP40 download via external USB/Serail converter upload_protocol = esptool #firmware upload via USB OTG seriell, by first upload need to set the ESP32-S3 in the upload mode with shortcut GND to Pin27