mirror of
https://github.com/SlimeVR/SlimeVR-Tracker-ESP.git
synced 2026-04-06 02:01:57 +02:00
Bump PlatformIO platforms (#239)
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,3 +1,4 @@
|
||||
.pio
|
||||
.vscode/*
|
||||
build/
|
||||
venv/
|
||||
|
||||
134
ci/build.py
134
ci/build.py
@@ -1,9 +1,11 @@
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
import shutil
|
||||
from enum import Enum
|
||||
from textwrap import dedent
|
||||
from typing import List
|
||||
import configparser
|
||||
|
||||
COLOR_ESC = '\033['
|
||||
COLOR_RESET = f'{COLOR_ESC}0m'
|
||||
@@ -13,108 +15,36 @@ COLOR_CYAN = f'{COLOR_ESC}36m'
|
||||
COLOR_GRAY = f'{COLOR_ESC}30;1m'
|
||||
|
||||
|
||||
class Board(Enum):
|
||||
SLIMEVR = "BOARD_SLIMEVR"
|
||||
WROOM32 = "BOARD_WROOM32"
|
||||
LOLIN_C3_MINI = "BOARD_LOLIN_C3_MINI"
|
||||
ES32C3DEVKITM1 = "BOARD_ES32C3DEVKITM1"
|
||||
|
||||
|
||||
class DeviceConfiguration:
|
||||
def __init__(self, platform: str, board: Board, platformio_board: str) -> None:
|
||||
def __init__(self, platform: str, board: str, platformio_board: str) -> None:
|
||||
self.platform = platform
|
||||
self.board = board
|
||||
self.platformio_board = platformio_board
|
||||
|
||||
def get_platformio_section(self) -> str:
|
||||
section = f"[env:{self.platformio_board}]\n"
|
||||
section += f"platform = {self.platform}\n"
|
||||
section += f"board = {self.platformio_board}\n"
|
||||
|
||||
if self.board == Board.LOLIN_C3_MINI:
|
||||
section += "build_flags = \n"
|
||||
section += " ${env.build_flags}\n"
|
||||
section += " -DESP32C3\n"
|
||||
|
||||
if self.board == Board.ES32C3DEVKITM1:
|
||||
section += "build_flags = \n"
|
||||
section += " ${env.build_flags}\n"
|
||||
section += " -DESP32C3\n"
|
||||
|
||||
return section
|
||||
|
||||
def filename(self) -> str:
|
||||
return f"{self.platformio_board}.bin"
|
||||
|
||||
def build_header(self) -> str:
|
||||
sda = ""
|
||||
scl = ""
|
||||
imu_int = ""
|
||||
imu_int2 = ""
|
||||
battery_level = ""
|
||||
led_pin = 2
|
||||
led_invert = False
|
||||
|
||||
if self.board == Board.SLIMEVR:
|
||||
sda = "4"
|
||||
scl = "5"
|
||||
imu_int = "10"
|
||||
imu_int2 = "13"
|
||||
battery_level = "17"
|
||||
led_invert = True
|
||||
elif self.board == Board.WROOM32:
|
||||
sda = "21"
|
||||
scl = "22"
|
||||
imu_int = "23"
|
||||
imu_int2 = "25"
|
||||
battery_level = "36"
|
||||
elif self.board == Board.LOLIN_C3_MINI:
|
||||
sda = "5"
|
||||
scl = "4"
|
||||
imu_int = "6"
|
||||
imu_int2 = "8"
|
||||
battery_level = "3"
|
||||
elif self.board == Board.ES32C3DEVKITM1:
|
||||
sda = "5"
|
||||
scl = "4"
|
||||
imu_int = "6"
|
||||
imu_int2 = "7"
|
||||
battery_level = "3"
|
||||
else:
|
||||
raise Exception(f"Unknown board: {self.board.value}")
|
||||
|
||||
return f"""
|
||||
#define IMU IMU_BNO085
|
||||
#define SECOND_IMU IMU
|
||||
#define BOARD {self.board.value}
|
||||
#define IMU_ROTATION DEG_90
|
||||
#define SECOND_IMU_ROTATION DEG_90
|
||||
|
||||
#define BATTERY_MONITOR BAT_EXTERNAL
|
||||
#define BATTERY_SHIELD_RESISTANCE 180
|
||||
|
||||
#define PIN_IMU_SDA {sda}
|
||||
#define PIN_IMU_SCL {scl}
|
||||
#define PIN_IMU_INT {imu_int}
|
||||
#define PIN_IMU_INT_2 {imu_int2}
|
||||
#define PIN_BATTERY_LEVEL {battery_level}
|
||||
#define LED_PIN {led_pin}
|
||||
#define LED_INVERTED {led_invert.__str__().lower()}
|
||||
"""
|
||||
|
||||
def __str__(self) -> str:
|
||||
return f"{self.platform}@{self.board.value}"
|
||||
return f"{self.platform}@{self.board}"
|
||||
|
||||
|
||||
def get_matrix() -> List[DeviceConfiguration]:
|
||||
matrix: List[DeviceConfiguration] = []
|
||||
|
||||
configFile = open("./ci/devices.json", "r")
|
||||
config = json.load(configFile)
|
||||
config = configparser.ConfigParser()
|
||||
config.read("./platformio-tools.ini")
|
||||
for section in config.sections():
|
||||
if section == "env":
|
||||
continue
|
||||
|
||||
board = section.split(":")[1]
|
||||
platform = config[section]["platform"]
|
||||
platformio_board = config[section]["board"]
|
||||
|
||||
for deviceConfig in config:
|
||||
matrix.append(DeviceConfiguration(
|
||||
deviceConfig["platform"], Board[deviceConfig["board"]], deviceConfig["platformio_board"]))
|
||||
platform,
|
||||
board,
|
||||
platformio_board))
|
||||
|
||||
return matrix
|
||||
|
||||
@@ -122,14 +52,12 @@ def get_matrix() -> List[DeviceConfiguration]:
|
||||
def prepare() -> None:
|
||||
print(f"🡢 {COLOR_CYAN}Preparation{COLOR_RESET}")
|
||||
|
||||
print(f" 🡢 {COLOR_GRAY}Backing up src/defines.h{COLOR_RESET}")
|
||||
shutil.copy("src/defines.h", "src/defines.h.bak")
|
||||
|
||||
print(f" 🡢 {COLOR_GRAY}Backing up platformio.ini{COLOR_RESET}")
|
||||
shutil.copy("./platformio.ini", "platformio.ini.bak")
|
||||
|
||||
print(f" 🡢 {COLOR_GRAY}Copying over build/platformio.ini{COLOR_RESET}")
|
||||
shutil.copy("./ci/platformio.ini", "platformio.ini")
|
||||
print(
|
||||
f" 🡢 {COLOR_GRAY}Switching platformio.ini to platformio-tools.ini{COLOR_RESET}")
|
||||
shutil.copy("./platformio-tools.ini", "platformio.ini")
|
||||
|
||||
if os.path.exists("./build"):
|
||||
print(f" 🡢 {COLOR_GRAY}Removing existing build folder...{COLOR_RESET}")
|
||||
@@ -144,12 +72,6 @@ def prepare() -> None:
|
||||
def cleanup() -> None:
|
||||
print(f"🡢 {COLOR_CYAN}Cleanup{COLOR_RESET}")
|
||||
|
||||
print(f" 🡢 {COLOR_GRAY}Restoring src/defines.h...{COLOR_RESET}")
|
||||
shutil.copy("src/defines.h.bak", "src/defines.h")
|
||||
|
||||
print(f" 🡢 {COLOR_GRAY}Removing src/defines.h.bak...{COLOR_RESET}")
|
||||
os.remove("src/defines.h.bak")
|
||||
|
||||
print(f" 🡢 {COLOR_GRAY}Restoring platformio.ini...{COLOR_RESET}")
|
||||
shutil.copy("platformio.ini.bak", "platformio.ini")
|
||||
|
||||
@@ -167,16 +89,12 @@ def build() -> int:
|
||||
|
||||
matrix = get_matrix()
|
||||
|
||||
with open("./platformio.ini", "a") as f1:
|
||||
for device in matrix:
|
||||
f1.write(device.get_platformio_section())
|
||||
|
||||
for device in matrix:
|
||||
print(f" 🡢 {COLOR_CYAN}Building for {device.platform}{COLOR_RESET}")
|
||||
|
||||
status = build_for_device(device)
|
||||
|
||||
if status == False:
|
||||
if not status:
|
||||
failed_builds.append(device.platformio_board)
|
||||
|
||||
if len(failed_builds) > 0:
|
||||
@@ -197,14 +115,10 @@ def build_for_device(device: DeviceConfiguration) -> bool:
|
||||
|
||||
print(f"::group::Build {device}")
|
||||
|
||||
with open("src/defines.h", "wt") as f:
|
||||
f.write(device.build_header())
|
||||
|
||||
code = os.system(
|
||||
f"platformio run -e {device.platformio_board}")
|
||||
code = os.system(f"platformio run -e {device.board}")
|
||||
|
||||
if code == 0:
|
||||
shutil.copy(f".pio/build/{device.platformio_board}/firmware.bin",
|
||||
shutil.copy(f".pio/build/{device.board}/firmware.bin",
|
||||
f"build/{device.filename()}")
|
||||
|
||||
print(f" 🡢 {COLOR_GREEN}Success!{COLOR_RESET}")
|
||||
@@ -213,7 +127,7 @@ def build_for_device(device: DeviceConfiguration) -> bool:
|
||||
|
||||
print(f" 🡢 {COLOR_RED}Failed!{COLOR_RESET}")
|
||||
|
||||
print(f"::endgroup::")
|
||||
print("::endgroup::")
|
||||
|
||||
return success
|
||||
|
||||
@@ -223,7 +137,7 @@ def main() -> None:
|
||||
code = build()
|
||||
cleanup()
|
||||
|
||||
os._exit(code)
|
||||
sys.exit(code)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
[
|
||||
{
|
||||
"platform": "espressif8266",
|
||||
"platformio_board": "esp12e",
|
||||
"board": "SLIMEVR"
|
||||
},
|
||||
{
|
||||
"platform": "espressif32 @ 5.1.1",
|
||||
"platformio_board": "esp32dev",
|
||||
"board": "WROOM32"
|
||||
},
|
||||
{
|
||||
"platform": "espressif32 @ 5.1.1",
|
||||
"platformio_board": "lolin_c3_mini",
|
||||
"board": "LOLIN_C3_MINI"
|
||||
},
|
||||
{
|
||||
"platform": "espressif32 @ 5.1.1",
|
||||
"platformio_board": "esp32-c3-devkitm-1",
|
||||
"board": "ES32C3DEVKITM1"
|
||||
}
|
||||
]
|
||||
@@ -1,9 +0,0 @@
|
||||
[env]
|
||||
lib_deps=
|
||||
https://github.com/SlimeVR/CmdParser.git
|
||||
monitor_speed = 115200
|
||||
framework = arduino
|
||||
build_flags =
|
||||
-O2
|
||||
-std=gnu++17
|
||||
build_unflags = -Os -std=gnu++11
|
||||
@@ -3,54 +3,53 @@ lib_deps=
|
||||
https://github.com/SlimeVR/CmdParser.git
|
||||
monitor_speed = 115200
|
||||
framework = arduino
|
||||
build_flags =
|
||||
-O2
|
||||
build_unflags = -Os
|
||||
build_flags = -O2 -std=gnu++17
|
||||
build_unflags = -Os -std=gnu++11
|
||||
|
||||
[env:BOARD_SLIMEVR]
|
||||
platform = espressif8266
|
||||
platform = espressif8266 @ 4.2.0
|
||||
board = esp12e
|
||||
|
||||
[env:BOARD_SLIMEVR_DEV]
|
||||
platform = espressif8266
|
||||
platform = espressif8266 @ 4.2.0
|
||||
board = esp12e
|
||||
|
||||
[env:BOARD_NODEMCU]
|
||||
platform = espressif8266
|
||||
platform = espressif8266 @ 4.2.0
|
||||
board = esp12e
|
||||
|
||||
[env:BOARD_WEMOSD1MINI]
|
||||
platform = espressif8266
|
||||
platform = espressif8266 @ 4.2.0
|
||||
board = esp12e
|
||||
|
||||
[env:BOARD_TTGO_TBASE]
|
||||
platform = espressif8266
|
||||
platform = espressif8266 @ 4.2.0
|
||||
board = esp12e
|
||||
|
||||
[env:BOARD_WROOM32]
|
||||
platform = espressif32@4.4.0
|
||||
platform = espressif32 @ 6.1.0
|
||||
board = esp32dev
|
||||
|
||||
[env:BOARD_ESP01]
|
||||
platform = espressif32@4.4.0
|
||||
platform = espressif32 @ 6.1.0
|
||||
board = esp32dev
|
||||
|
||||
[env:BOARD_LOLIN_C3_MINI]
|
||||
platform = espressif32@5.1.1
|
||||
platform = espressif32 @ 6.1.0
|
||||
build_flags =
|
||||
${env.build_flags}
|
||||
-DESP32C3
|
||||
board = lolin_c3_mini
|
||||
|
||||
[env:BOARD_BEETLE32C3]
|
||||
platform = espressif32@5.1.1
|
||||
platform = espressif32 @ 6.1.0
|
||||
build_flags =
|
||||
${env.build_flags}
|
||||
-DESP32C3
|
||||
board = dfrobot_beetle_esp32c3
|
||||
|
||||
[env:BOARD_ES32C3DEVKITM1]
|
||||
platform = espressif32 @5.1.1
|
||||
platform = espressif32 @ 6.1.0
|
||||
build_flags =
|
||||
${env.build_flags}
|
||||
-DESP32C3
|
||||
|
||||
@@ -50,7 +50,7 @@ build_unflags = -Os -std=gnu++11
|
||||
; Settings for different boards
|
||||
|
||||
[env:esp12e]
|
||||
platform = espressif8266
|
||||
platform = espressif8266 @ 4.2.0
|
||||
board = esp12e
|
||||
; Comment out this line below if you have any trouble uploading the firmware
|
||||
; and if it has a CP2102 on it (a square chip next to the usb port): change to 3000000 (3 million) for even faster upload speed
|
||||
@@ -58,13 +58,13 @@ upload_speed = 921600
|
||||
|
||||
; Uncomment below if you want to build for ESP-01
|
||||
;[env:esp01_1m]
|
||||
;platform = espressif8266
|
||||
;platform = espressif8266 @ 4.2.0
|
||||
;board = esp01_1m
|
||||
|
||||
; Uncomment below if you want to build for esp32
|
||||
; Check your board name at https://docs.platformio.org/en/latest/platforms/espressif32.html#boards
|
||||
; [env:esp32]
|
||||
; platform = espressif32 @ 5.1.1
|
||||
; platform = espressif32 @ 6.1.0
|
||||
; board = esp32dev
|
||||
; Comment out this line below if you have any trouble uploading the firmware - and if it has a CP2102 on it (a square chip next to the usb port): change to 3000000 (3 million) for even faster upload speed
|
||||
;upload_speed = 921600
|
||||
@@ -79,9 +79,8 @@ upload_speed = 921600
|
||||
; -DARDUINO_USB_CDC_ON_BOOT=1
|
||||
|
||||
;[env:esp32c3]
|
||||
;platform = espressif32 @ 5.1.1
|
||||
;platform = espressif32 @ 6.1.0
|
||||
;build_flags =
|
||||
; ${env.build_flags}
|
||||
; -DESP32C3
|
||||
;board = lolin_c3_mini
|
||||
|
||||
|
||||
Reference in New Issue
Block a user