Skip to content

Commit 155de26

Browse files
GhostTypesclaude
andcommitted
fix(creator5): turn tools off with 0
The Creator 5 firmware's per-nozzle temperature parser only treats a literal 0 as "off" inside the temperatureCtl_cmd `nozzles` array; it ignores the -100 sentinel (which the scalar platform/chamber/rightNozzle fields do accept), so the tool kept heating. cancelToolTemp and the Creator 5 path of cancelExtruderTemp now write 0 to the targeted nozzle. Bed/chamber/extruder(rightNozzle) off-paths are unchanged. Confirmed by a Creator 5 Pro tester: setting a tool to 0 turns it off, the OFF button (which sent -100) did not. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 17227f3 commit 155de26

2 files changed

Lines changed: 21 additions & 9 deletions

File tree

src/api/controls/TempControl.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,12 +244,12 @@ describe('TempControl', () => {
244244
);
245245
});
246246

247-
it('cancelToolTemp turns a single tool off (-100)', async () => {
247+
it('cancelToolTemp turns a single tool off via 0 (firmware ignores -100 in nozzles[])', async () => {
248248
await httpTempControl.cancelToolTemp(0);
249249

250250
expect(mockSendControlCommand).toHaveBeenCalledWith(
251251
'temperatureCtl_cmd',
252-
expect.objectContaining({ nozzles: [-100, -200, -200, -200] })
252+
expect.objectContaining({ nozzles: [0, -200, -200, -200] })
253253
);
254254
});
255255

@@ -332,7 +332,7 @@ describe('TempControl', () => {
332332
leftNozzle: -200,
333333
platform: -200,
334334
chamber: -200,
335-
nozzles: [-100, -200, -200, -200],
335+
nozzles: [0, -200, -200, -200], // NOZZLE_OFF — firmware ignores -100 in nozzles[]
336336
});
337337
});
338338

src/api/controls/TempControl.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,18 @@ import { Commands } from '../server/Commands';
1414
* (partial update). Sending a real 0 / -100 would turn the heater off.
1515
*/
1616
const TEMP_NO_CHANGE = -200;
17-
/** `temperatureCtl_cmd` value that turns a heater off. */
17+
/**
18+
* `temperatureCtl_cmd` value that turns a SCALAR heater (platform / chamber /
19+
* rightNozzle) off.
20+
*/
1821
const TEMP_OFF = -100;
22+
/**
23+
* Value that turns a tool/nozzle OFF inside the `nozzles` array. Unlike the scalar
24+
* heater fields (which accept {@link TEMP_OFF} = -100), the Creator 5 firmware's
25+
* per-nozzle parser only treats a literal 0 as "off" — it ignores -100 in the
26+
* `nozzles` array and the tool keeps heating. (Firmware-confirmed via tester report.)
27+
*/
28+
const NOZZLE_OFF = 0;
1929
/**
2030
* Number of tool/nozzle entries the Creator 5 firmware requires in the
2131
* `nozzles` array. The firmware ignores the array unless its length is exactly
@@ -110,8 +120,9 @@ export class TempControl {
110120
/**
111121
* Sets the target temperatures for all tools/nozzles on a Creator 5 series
112122
* tool-changer in one command. Use {@link TEMP_NO_CHANGE} (-200) to leave a
113-
* tool unchanged or {@link TEMP_OFF} (-100) to turn one off. Must contain
114-
* exactly {@link NOZZLE_COUNT} entries.
123+
* tool unchanged or {@link NOZZLE_OFF} (0) to turn one off (the firmware ignores
124+
* the -100 sentinel inside the `nozzles` array). Must contain exactly
125+
* {@link NOZZLE_COUNT} entries.
115126
* @param temps Per-tool target temperatures, ordered T0..T3.
116127
* @returns A Promise resolving to true if the command is acknowledged.
117128
*/
@@ -130,7 +141,7 @@ export class TempControl {
130141
* @returns A Promise resolving to true if the command is acknowledged.
131142
*/
132143
public async cancelToolTemp(toolIndex: number): Promise<boolean> {
133-
const nozzles = this.buildNozzleArray(toolIndex, TEMP_OFF);
144+
const nozzles = this.buildNozzleArray(toolIndex, NOZZLE_OFF);
134145
if (nozzles === null) return false;
135146
return await this.sendHttpTempCommand({ nozzles });
136147
}
@@ -177,9 +188,10 @@ export class TempControl {
177188
public async cancelExtruderTemp(): Promise<boolean> {
178189
if (this.client.httpOnly) {
179190
// See setExtruderTemp: Creator 5 tools are driven only via `nozzles`. Turn
180-
// the primary tool (T0) off while leaving the other tools unchanged.
191+
// the primary tool (T0) off (target 0, not the -100 sentinel the nozzles array
192+
// ignores) while leaving the other tools unchanged.
181193
if (this.client.isCreator5) {
182-
const nozzles = this.buildNozzleArray(0, TEMP_OFF);
194+
const nozzles = this.buildNozzleArray(0, NOZZLE_OFF);
183195
if (nozzles === null) return false;
184196
return await this.sendHttpTempCommand({ nozzles });
185197
}

0 commit comments

Comments
 (0)