Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/__tests__/interpreter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,16 @@ test('.G20 sets the units to inches', () => {
expect(job.state.units).toEqual('in');
});

test('.G21 sets the units to millimeters', () => {
const command = new GCodeCommand('G21', 'g21', {});
const interpreter = new Interpreter();
const job = new Job();

interpreter.G21(command, job);

expect(job.state.units).toEqual('mm');
});

test('.t0 sets the tool to 0', () => {
const command = new GCodeCommand('T0', 't0', {});
const interpreter = new Interpreter();
Expand Down
3 changes: 3 additions & 0 deletions src/gcode-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export enum Code {
G2 = 'G2',
G3 = 'G3',
G20 = 'G20',
G21 = 'G21',
T0 = 'T0',
T1 = 'T1',
T2 = 'T2',
Expand Down Expand Up @@ -98,6 +99,8 @@ export class GCodeCommand {
return Code.G3;
case 'g20':
return Code.G20;
case 'g21':
return Code.G21;
case 't0':
return Code.T0;
case 't1':
Expand Down
4 changes: 4 additions & 0 deletions src/interpreter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ export class Interpreter {
job.state.units = 'in';
}

G21(command: GCodeCommand, job: Job): void {
job.state.units = 'mm';
}

T0(command: GCodeCommand, job: Job): void {
job.state.tool = 0;
}
Expand Down