Skip to content

Commit d126697

Browse files
Better CI pipeline
1 parent 63a0ca5 commit d126697

File tree

4 files changed

+111
-21
lines changed

4 files changed

+111
-21
lines changed

CYD-Klipper/platformio.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ lib_deps =
121121
board = esp32-JC8048W550
122122

123123
[env:ESP32-JC3248W535C]
124-
board = esp32-JC3248W535C
124+
board = esp32-JC3248W535C
125125
lib_deps =
126126
SPI
127127
moononournation/GFX Library for Arduino

ci.json

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
{
2+
"esp32-2432S024C-SD": {
3+
"name": "ESP32-2432S024 (2.4\" Capacitive)",
4+
"site": true,
5+
"s3": false
6+
},
7+
"esp32-2432S028R": {
8+
"name": "ESP32-2432S028 (2.8\" Resistive)",
9+
"site": true,
10+
"s3": false,
11+
"default": true
12+
},
13+
"esp32-2432S032C-SD": {
14+
"name": "ESP32-2432S032 (3.2\" Capacitive)",
15+
"site": true,
16+
"s3": false
17+
},
18+
"esp32-3248S035C": {
19+
"name": "ESP32-3248S035 (3.5\" Capacitive)",
20+
"site": true,
21+
"s3": false
22+
},
23+
"esp32-3248S035C-V": {
24+
"name": "ESP32-3248S035 (3.5\" Capacitive) Vertical Orientation",
25+
"site": true,
26+
"s3": false
27+
},
28+
"esp32-4827S043C-SD": {
29+
"name": "ESP32-4827S043 (4.3\" 480x270 Capacitive)",
30+
"site": true,
31+
"s3": true
32+
},
33+
"esp32-8048S043C-SD": {
34+
"name": "ESP32-8048S043 (4.3\" 800x480 Capacitive)",
35+
"site": true,
36+
"s3": true
37+
},
38+
"esp32-8048S043C-SD-alt": {
39+
"name": "ESP32-8048S043 Alt (4.3\" 800x480 Capacitive)",
40+
"site": true,
41+
"s3": true
42+
},
43+
"esp32-CROWPANEL-28R": {
44+
"name": "ESP32-CROWPANEL-28R (2.8\" Resistive)",
45+
"site": true,
46+
"s3": false,
47+
"brand": "CrowPanel"
48+
},
49+
"esp32-CROWPANEL-35C": {
50+
"name": "ESP32-CROWPANEL-35C (3.5\" Capacitive)",
51+
"site": true,
52+
"s3": true,
53+
"brand": "CrowPanel"
54+
},
55+
"esp32-JC8048W550": {
56+
"name": "Guition JC8048W550 (5\" Capacitive)",
57+
"site": true,
58+
"s3": true,
59+
"brand": "Guition"
60+
}
61+
}

ci.py

Lines changed: 48 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import subprocess, os, shutil, json
22

33
CYD_PORTS = [
4-
"esp32-3248S035C",
54
"esp32-2432S028R",
5+
"esp32-3248S035C",
66
"esp32-2432S032C-SD",
77
"esp32-8048S043C-SD",
88
"esp32-8048S043C-SD-alt",
@@ -25,18 +25,18 @@
2525

2626
BASE_DIR = os.getcwd()
2727

28-
def get_manifest(base_path : str, device_name : str):
28+
def get_manifest(base_path : str, device_name : str, is_s3 : bool):
2929
return {
3030
"name": f"to {device_name}",
3131
"funding_url": "https://ko-fi.com/suchmememanyskill",
3232
"new_install_prompt_erase": True,
3333
"builds": [
3434
{
35-
"chipFamily": "ESP32-S3" if device_name in ESP_S3_CHIPS else "ESP32",
35+
"chipFamily": "ESP32-S3" if is_s3 else "ESP32",
3636
"parts": [
3737
{
3838
"path": f"{base_path}/bootloader.bin",
39-
"offset": 0 if device_name in ESP_S3_CHIPS else 0x1000
39+
"offset": 0 if is_s3 else 0x1000
4040
},
4141
{
4242
"path": f"{base_path}/partitions.bin",
@@ -61,6 +61,7 @@ def extract_commit() -> str:
6161

6262
repo_version = extract_commit()
6363
configurations = []
64+
site_sections : dict[str, dict] = {"CYD": []}
6465

6566
def add_configuration(board : str):
6667
configurations.append({
@@ -69,10 +70,32 @@ def add_configuration(board : str):
6970
"URL": f"https://suchmememanyskill.github.io/CYD-Klipper/out/{board}/firmware.bin"
7071
})
7172

73+
def add_site_section(port : str, data : dict[str, bool|str]):
74+
brand = data["brand"] if "brand" in data else "CYD"
75+
76+
if brand not in site_sections:
77+
site_sections[brand] = []
78+
79+
site_sections[brand].append({
80+
"name": data["name"],
81+
"port": port,
82+
"default": "default" in data and data["default"],
83+
})
84+
7285
if os.path.exists("out"):
7386
shutil.rmtree("out")
7487

75-
for port in CYD_PORTS:
88+
if not os.path.exists("_site"):
89+
os.makedirs("_site")
90+
91+
with open("./ci.json", "r") as fp:
92+
ci_data : dict[str, dict[str, bool|str]] = json.load(fp)
93+
94+
for port, data in ci_data.items():
95+
if "skip" in data and data["skip"]:
96+
print(f"Skipping {port}...")
97+
continue
98+
7699
port_path = f"out/{port}"
77100
os.chdir(BASE_DIR)
78101
os.makedirs(port_path, exist_ok=True)
@@ -84,18 +107,21 @@ def add_configuration(board : str):
84107

85108
shutil.copy(os.path.join(os.path.expanduser("~"), ".platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin"), f"{port_path}/boot_app0.bin")
86109
os.chdir(port_path)
87-
if (port in ESP_S3_CHIPS):
88-
subprocess.run(["python3", "-m", "esptool", "--chip", "esp32s3", "merge_bin", "-o", "merged_firmware.bin", "--flash_mode", "dio", "--flash_freq", "80m", "--flash_size", "16MB", "0x0000", "bootloader.bin", "0x8000", "partitions.bin", "0xe000", "boot_app0.bin", "0x10000", "firmware.bin"], check=True)
110+
if (bool(data["s3"])):
111+
subprocess.run(["esptool", "--chip", "esp32s3", "merge_bin", "-o", "merged_firmware.bin", "--flash_mode", "dio", "--flash_freq", "80m", "--flash_size", "16MB", "0x0000", "bootloader.bin", "0x8000", "partitions.bin", "0xe000", "boot_app0.bin", "0x10000", "firmware.bin"], check=True)
89112
else:
90-
subprocess.run(["python3", "-m", "esptool", "--chip", "esp32", "merge_bin", "-o", "merged_firmware.bin", "--flash_mode", "dio", "--flash_freq", "40m", "--flash_size", "4MB", "0x1000", "bootloader.bin", "0x8000", "partitions.bin", "0xe000", "boot_app0.bin", "0x10000", "firmware.bin"], check=True)
113+
subprocess.run(["esptool", "--chip", "esp32", "merge_bin", "-o", "merged_firmware.bin", "--flash_mode", "dio", "--flash_freq", "40m", "--flash_size", "4MB", "0x1000", "bootloader.bin", "0x8000", "partitions.bin", "0xe000", "boot_app0.bin", "0x10000", "firmware.bin"], check=True)
91114

92115
os.chdir(BASE_DIR)
93116

94117
with open(f"./_site/{port}.json", "w") as f:
95-
json.dump(get_manifest(port_path, port), f)
118+
json.dump(get_manifest(port_path, port, bool(data["s3"])), f)
96119

97120
add_configuration(port)
98121

122+
if "site" in data and data["site"]:
123+
add_site_section(port, data)
124+
99125
os.chdir(BASE_DIR)
100126
out_dir = "./_site/out"
101127
if os.path.exists(out_dir):
@@ -104,3 +130,16 @@ def add_configuration(board : str):
104130

105131
with open("./_site/OTA.json", "w") as f:
106132
json.dump({"Configurations": configurations}, f)
133+
134+
with open("./_site/index.html", "w") as fp:
135+
with open("./template.html", "r") as template_fp:
136+
template = template_fp.read()
137+
138+
insert_html = ""
139+
140+
for brand, sections in site_sections.items():
141+
option_htmls = [f"<option {'selected' if x['default'] else ''} value=\"{x['port']}\">{x['name']}</option>" for x in sections]
142+
section_html = f"<optgroup label=\"{brand}\">{''.join(option_htmls)}</optgroup>"
143+
insert_html += section_html
144+
145+
fp.write(template.replace("{{%PORTS%}}", insert_html))

_site/index.html renamed to template.html

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -132,17 +132,7 @@ <h3><span class="iconify" data-icon="mdi-github" style="color: white; filter: dr
132132
<h3><span class="iconify" data-icon="mdi-download"></span> Install</h3>
133133
<p>Select your device from the list below and click 'Connect'.<br>Note: You may need to hold the 'BOOT' button on the device while pressing install.<br><br>The 2.8" Resistive and 3.5" Capacitive models are best suited (in my opinion) for CYD-Klipper.<br><br>Note for any resistive models: You can clear touch calibration by holding the BOOT button for 8 seconds while the screen is on.</p>
134134
<select id="select-install-btn" onchange="setInstallButton(getElementById('select-install-btn').value)">
135-
<option value="esp32-2432S024C-SD">ESP32-2432S024 (2.4" Capacitive)</option>
136-
<option selected value="esp32-2432S028R">ESP32-2432S028 (2.8" Resistive)</option>
137-
<option value="esp32-2432S032C-SD">ESP32-2432S032 (3.2" Capacitive)</option>
138-
<option value="esp32-3248S035C">ESP32-3248S035 (3.5" Capacitive)</option>
139-
<option value="esp32-3248S035C-V">ESP32-3248S035 (3.5" Capacitive) Vertical Orientation</option>
140-
<option value="esp32-4827S043C-SD">ESP32-4827S043 (4.3" 480x270 Capacitive)</option>
141-
<option value="esp32-8048S043C-SD">ESP32-8048S043 (4.3" 800x480 Capacitive)</option>
142-
<option value="esp32-8048S043C-SD-alt">ESP32-8048S043 Alt (4.3" 800x480 Capacitive)</option>
143-
<option value="esp32-CROWPANEL-28R">ESP32-CROWPANEL-28R (2.8" Resistive)</option>
144-
<option value="esp32-JC8048W550">Guition JC8048W550 (5" Capacitive)</option>
145-
<option value="esp32-CROWPANEL-35C">ESP32-CROWPANEL-35C (3.5" Capacitive)</option>
135+
{{%PORTS%}}
146136
</select>
147137
<span id="install-btn"></span>
148138
</section>

0 commit comments

Comments
 (0)