Skip to content

Commit 106472b

Browse files
authored
Add Ender 5 Pro preset and endstop state config (#44)
1 parent c3a4f04 commit 106472b

4 files changed

Lines changed: 127 additions & 1 deletion

File tree

.github/workflows/firmware-build.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,39 @@ jobs:
159159
sed -i "s/^#define INVERT_E0_DIR.*/#define INVERT_E0_DIR $INVERT_E/" marlin/Marlin/Configuration.h
160160
fi
161161
162+
# === ENDSTOP HIT STATES ===
163+
ENDSTOP_X=$(echo "$CUSTOMIZATIONS" | jq -r '.endstopX // empty')
164+
ENDSTOP_Y=$(echo "$CUSTOMIZATIONS" | jq -r '.endstopY // empty')
165+
ENDSTOP_Z=$(echo "$CUSTOMIZATIONS" | jq -r '.endstopZ // empty')
166+
ENDSTOP_C=$(echo "$CUSTOMIZATIONS" | jq -r '.endstopC // empty')
167+
ENDSTOP_B=$(echo "$CUSTOMIZATIONS" | jq -r '.endstopB // empty')
168+
169+
if [ -n "$ENDSTOP_X" ]; then
170+
sed -i "s/^#define X_MIN_ENDSTOP_HIT_STATE.*/#define X_MIN_ENDSTOP_HIT_STATE $ENDSTOP_X/" marlin/Marlin/Configuration.h
171+
sed -i "s/^#define X_MAX_ENDSTOP_HIT_STATE.*/#define X_MAX_ENDSTOP_HIT_STATE $ENDSTOP_X/" marlin/Marlin/Configuration.h
172+
echo "Set X endstop hit state to $ENDSTOP_X"
173+
fi
174+
if [ -n "$ENDSTOP_Y" ]; then
175+
sed -i "s/^#define Y_MIN_ENDSTOP_HIT_STATE.*/#define Y_MIN_ENDSTOP_HIT_STATE $ENDSTOP_Y/" marlin/Marlin/Configuration.h
176+
sed -i "s/^#define Y_MAX_ENDSTOP_HIT_STATE.*/#define Y_MAX_ENDSTOP_HIT_STATE $ENDSTOP_Y/" marlin/Marlin/Configuration.h
177+
echo "Set Y endstop hit state to $ENDSTOP_Y"
178+
fi
179+
if [ -n "$ENDSTOP_Z" ]; then
180+
sed -i "s/^#define Z_MIN_ENDSTOP_HIT_STATE.*/#define Z_MIN_ENDSTOP_HIT_STATE $ENDSTOP_Z/" marlin/Marlin/Configuration.h
181+
sed -i "s/^#define Z_MAX_ENDSTOP_HIT_STATE.*/#define Z_MAX_ENDSTOP_HIT_STATE $ENDSTOP_Z/" marlin/Marlin/Configuration.h
182+
echo "Set Z endstop hit state to $ENDSTOP_Z"
183+
fi
184+
if [ -n "$ENDSTOP_C" ]; then
185+
sed -i "s/^#define I_MIN_ENDSTOP_HIT_STATE.*/#define I_MIN_ENDSTOP_HIT_STATE $ENDSTOP_C/" marlin/Marlin/Configuration.h
186+
sed -i "s/^#define I_MAX_ENDSTOP_HIT_STATE.*/#define I_MAX_ENDSTOP_HIT_STATE $ENDSTOP_C/" marlin/Marlin/Configuration.h
187+
echo "Set C endstop hit state to $ENDSTOP_C"
188+
fi
189+
if [ -n "$ENDSTOP_B" ]; then
190+
sed -i "s/^#define J_MIN_ENDSTOP_HIT_STATE.*/#define J_MIN_ENDSTOP_HIT_STATE $ENDSTOP_B/" marlin/Marlin/Configuration.h
191+
sed -i "s/^#define J_MAX_ENDSTOP_HIT_STATE.*/#define J_MAX_ENDSTOP_HIT_STATE $ENDSTOP_B/" marlin/Marlin/Configuration.h
192+
echo "Set B endstop hit state to $ENDSTOP_B"
193+
fi
194+
162195
# === IK PARAMETERS ===
163196
IK_LC=$(echo "$CUSTOMIZATIONS" | jq -r '.ikLC // empty')
164197
IK_LB=$(echo "$CUSTOMIZATIONS" | jq -r '.ikLB // empty')

tools/firmware-builder/index.html

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ <h3 class="text-2xl font-bold text-gray-900 mb-2">Printer dimensions</h3>
180180
<option value="ender3v3se" selected>Ender 3 V3 SE (220×220×270)</option>
181181
<option value="ender3pro">Ender 3 Pro (220×220×250)</option>
182182
<option value="ender3v2">Ender 3 V2 (220×220×250)</option>
183+
<option value="ender5pro">Ender 5 Pro (220×220×300)</option>
183184
</select>
184185
</div>
185186

@@ -662,6 +663,51 @@ <h4 class="font-medium text-gray-900 mb-4">Stepper drivers</h4>
662663
</p>
663664
</div>
664665
</div>
666+
667+
<div class="section-divider">
668+
<span>Endstop switches</span>
669+
</div>
670+
671+
<p class="text-sm text-gray-600 mb-2">Select <strong>NO</strong> (normally open) or <strong>NC</strong> (normally closed) based on your switch wiring.</p>
672+
673+
<!-- Endstop hit states -->
674+
<div class="grid grid-cols-3 gap-4">
675+
<div>
676+
<label class="block text-sm text-gray-600 mb-1">X endstop</label>
677+
<select id="endstopX" class="config-input w-full">
678+
<option value="HIGH" selected>NO (normally open)</option>
679+
<option value="LOW">NC (normally closed)</option>
680+
</select>
681+
</div>
682+
<div>
683+
<label class="block text-sm text-gray-600 mb-1">Y endstop</label>
684+
<select id="endstopY" class="config-input w-full">
685+
<option value="HIGH" selected>NO (normally open)</option>
686+
<option value="LOW">NC (normally closed)</option>
687+
</select>
688+
</div>
689+
<div>
690+
<label class="block text-sm text-gray-600 mb-1">Z endstop</label>
691+
<select id="endstopZ" class="config-input w-full">
692+
<option value="HIGH" selected>NO (normally open)</option>
693+
<option value="LOW">NC (normally closed)</option>
694+
</select>
695+
</div>
696+
<div>
697+
<label class="block text-sm text-gray-600 mb-1">C endstop</label>
698+
<select id="endstopC" class="config-input w-full">
699+
<option value="HIGH" selected>NO (normally open)</option>
700+
<option value="LOW">NC (normally closed)</option>
701+
</select>
702+
</div>
703+
<div>
704+
<label class="block text-sm text-gray-600 mb-1">B endstop</label>
705+
<select id="endstopB" class="config-input w-full">
706+
<option value="HIGH">NO (normally open)</option>
707+
<option value="LOW" selected>NC (normally closed)</option>
708+
</select>
709+
</div>
710+
</div>
665711
</div>
666712
</div>
667713
</div>

tools/firmware-builder/js/app.js

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@ const printerPresets = {
3131
xHomeDir: -1,
3232
yHomeDir: -1,
3333
zHomeDir: -1
34+
},
35+
'ender5pro': {
36+
name: 'Ender 5 Pro',
37+
xBedSize: 220,
38+
yBedSize: 220,
39+
zMaxPos: 300,
40+
xHomeDir: -1,
41+
yHomeDir: -1,
42+
zHomeDir: 1
3443
}
3544
};
3645

@@ -97,6 +106,13 @@ const wizardState = {
97106
invertB: false,
98107
invertE: false,
99108

109+
// Step 4: Endstop hit state (HIGH = NO, LOW = NC)
110+
endstopX: 'HIGH',
111+
endstopY: 'HIGH',
112+
endstopZ: 'HIGH',
113+
endstopC: 'HIGH',
114+
endstopB: 'LOW',
115+
100116
// Step 6: Kinematics
101117
ikLC: 2.30,
102118
ikLB: 52.87,
@@ -223,7 +239,12 @@ function setupInputListeners() {
223239
{ id: 'socketZ', key: 'socketZ' },
224240
{ id: 'socketC', key: 'socketC' },
225241
{ id: 'socketB', key: 'socketB' },
226-
{ id: 'socketE', key: 'socketE' }
242+
{ id: 'socketE', key: 'socketE' },
243+
{ id: 'endstopX', key: 'endstopX' },
244+
{ id: 'endstopY', key: 'endstopY' },
245+
{ id: 'endstopZ', key: 'endstopZ' },
246+
{ id: 'endstopC', key: 'endstopC' },
247+
{ id: 'endstopB', key: 'endstopB' }
227248
];
228249

229250
selectInputsString.forEach(({ id, key }) => {
@@ -547,6 +568,7 @@ function formatPrinterName(value) {
547568
'ender3v3se': 'Ender 3 V3 SE',
548569
'ender3pro': 'Ender 3 Pro',
549570
'ender3v2': 'Ender 3 V2',
571+
'ender5pro': 'Ender 5 Pro',
550572
'custom': 'Custom'
551573
};
552574
return names[value] || value;
@@ -695,6 +717,12 @@ async function buildFirmware() {
695717
invertC: config.invertC,
696718
invertB: config.invertB,
697719
invertE: config.invertE,
720+
// Endstop hit states
721+
endstopX: config.endstopX,
722+
endstopY: config.endstopY,
723+
endstopZ: config.endstopZ,
724+
endstopC: config.endstopC,
725+
endstopB: config.endstopB,
698726
// IK parameters
699727
ikLC: config.ikLC,
700728
ikLB: config.ikLB,
@@ -1024,6 +1052,13 @@ function applyImportedConfig(config) {
10241052
if (el) el.checked = config[field];
10251053
});
10261054

1055+
// === Endstop hit states ===
1056+
const endstopFields = ['endstopX', 'endstopY', 'endstopZ', 'endstopC', 'endstopB'];
1057+
endstopFields.forEach(field => {
1058+
const el = document.getElementById(field);
1059+
if (el && config[field]) el.value = config[field];
1060+
});
1061+
10271062
// === IK Parameters ===
10281063
document.getElementById('ikLC').value = config.ikLC;
10291064
document.getElementById('ikLB').value = config.ikLB;

tools/firmware-builder/worker/worker.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,12 @@ async function handleBuildRequest(request, env, corsHeaders) {
124124
invertC: body.invertC,
125125
invertB: body.invertB,
126126
invertE: body.invertE,
127+
// Endstop hit states
128+
endstopX: body.endstopX,
129+
endstopY: body.endstopY,
130+
endstopZ: body.endstopZ,
131+
endstopC: body.endstopC,
132+
endstopB: body.endstopB,
127133
// IK parameters
128134
ikLC: body.ikLC,
129135
ikLB: body.ikLB,
@@ -286,6 +292,12 @@ async function handleConfigRequest(buildId, env, corsHeaders) {
286292
invertC: buildData.invertC,
287293
invertB: buildData.invertB,
288294
invertE: buildData.invertE,
295+
// Endstop hit states
296+
endstopX: buildData.endstopX,
297+
endstopY: buildData.endstopY,
298+
endstopZ: buildData.endstopZ,
299+
endstopC: buildData.endstopC,
300+
endstopB: buildData.endstopB,
289301
// IK parameters
290302
ikLC: buildData.ikLC,
291303
ikLB: buildData.ikLB,

0 commit comments

Comments
 (0)