Skip to content

Commit

Permalink
Printers: support accelerometer = 'none' and add mk3s test
Browse files Browse the repository at this point in the history
  • Loading branch information
miklschmidt committed Dec 27, 2024
1 parent 1172331 commit 334c000
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 10 deletions.
82 changes: 82 additions & 0 deletions src/__tests__/fixtures/prusa-mk3s.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{
"printer": "prusa-mk3s",
"controlboard": "prusa-einsy",
"toolheads": [
{
"hotend": "v6",
"thermistor": "ATC Semitec 104GT-2",
"extruder": "mk3s",
"xEndstop": "endstop",
"yEndstop": "endstop",
"hotendFan": "4pin-dedicated",
"partFan": "4pin-dedicated",
"nozzle": {
"type": "Regular",
"diameter": 0.4
},
"probe": "superpinda",
"axis": "x",
"xAccelerometer": "none",
"yAccelerometer": "none"
}
],
"size": {
"x": 250,
"y": 210,
"z": 210
},
"controllerFan": "none",
"performanceMode": false,
"stealthchop": false,
"standstillStealth": false,
"rails": [
{
"axis": "x",
"axisDescription": "The X axis motor moves the print head left and right.",
"driver": "PRUSA-EINSY-RAMBO-TMC2130",
"voltage": 24,
"stepper": "LDO-42STH40-1684AC",
"invertStepperDirection": false,
"current": 0.4,
"rotationDistance": 32,
"homingSpeed": 25,
"microstepping": 16
},
{
"axis": "y",
"axisDescription": "The Y axis motor moves the print bed forward and backward.",
"driver": "PRUSA-EINSY-RAMBO-TMC2130",
"voltage": 24,
"stepper": "LDO-42STH40-1684AC",
"invertStepperDirection": false,
"current": 0.4,
"rotationDistance": 32,
"homingSpeed": 25,
"microstepping": 16
},
{
"axis": "z",
"axisDescription": "The Z axis motor moves the print head up and down.",
"driver": "PRUSA-EINSY-RAMBO-TMC2130",
"voltage": 24,
"stepper": "LDO-42STH40-1684AC",
"invertStepperDirection": false,
"current": 0.4,
"rotationDistance": 8,
"homingSpeed": 10,
"microstepping": 16
},
{
"axis": "extruder",
"axisDescription": "The extruder motor used for your toolhead",
"driver": "PRUSA-EINSY-RAMBO-TMC2130",
"voltage": 24,
"stepper": "LDO-42STH40-1684AC",
"invertStepperDirection": false,
"current": 0.52,
"rotationDistance": 0,
"homingSpeed": 10,
"microstepping": 16
}
]
}
21 changes: 13 additions & 8 deletions src/__tests__/server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -811,22 +811,27 @@ describe('server', async () => {
}
});
});
for (const { line, param } of offendingLines) {
try {
expect(splitRes[line + 1].startsWith('\t') || splitRes[line + 1].startsWith(' ')).toBeTruthy();
} catch (e) {
throw new Error(
`Illegal parameter "${param}" at line ${line + 1}:\n${annotatedLines.slice(Math.max(line - 4, 0), Math.min(line + 5, annotatedLines.length)).join('\n')}`,
);
try {
expect(offendingLines.length).toBe(0);
} catch (e) {
let errorMsg = '';
for (const { line, param } of offendingLines) {
errorMsg += `Illegal parameter "${param}" at line ${line + 1}:\n${annotatedLines.slice(Math.max(line - 4, 0), Math.min(line + 5, annotatedLines.length)).join('\n')}`;
}
throw new Error(errorMsg);
}
});
test.concurrent('properly indents gcode blocks', async () => {
const gcodeBlocks: number[] = [];
splitRes.forEach((l, i) => l.includes('gcode:') && gcodeBlocks.push(i));
for (const block of gcodeBlocks) {
try {
expect(splitRes[block + 1].startsWith('\t') || splitRes[block + 1].startsWith(' ')).toBeTruthy();
expect(
splitRes[block + 1].startsWith('\t') ||
splitRes[block + 1].startsWith('#\t') ||
splitRes[block + 1].startsWith(' ') ||
splitRes[block + 1].startsWith('# '),
).toBeTruthy();
} catch (e) {
throw new Error(
`Failed to indent gcode block at line ${block + 1}:\n${annotatedLines.slice(Math.max(block - 4, 0), Math.min(block + 5, annotatedLines.length)).join('\n')}`,
Expand Down
4 changes: 2 additions & 2 deletions src/server/routers/printer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,10 @@ export const deserializeToolheadConfiguration = async (
)
: null;

if (xAccel == null && serializedXAccel != null) {
if (xAccel == null && serializedXAccel != null && serializedXAccel.id != 'none') {
throw new Error(`Accelerometer type could not be determined for ${serializedXAccel.id}`);
}
if (yAccel == null && serializedYAccel != null) {
if (yAccel == null && serializedYAccel != null && serializedYAccel.id != 'none') {
throw new Error(`Accelerometer type could not be determined for ${serializedYAccel.id}`);
}

Expand Down

0 comments on commit 334c000

Please sign in to comment.