Skip to content

Commit 7db017a

Browse files
committed
Fix incorrect Marlin position reports in inch mode
1 parent c08f889 commit 7db017a

File tree

1 file changed

+13
-25
lines changed

1 file changed

+13
-25
lines changed

src/Controller.js

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ class Controller {
391391
let { $13 = 0 } = { ...this.settings.settings };
392392
$13 = Number($13) || 0;
393393

394-
// Machine position are reported in mm ($13=0) or inches ($13=1)
394+
// Machine position is reported in mm ($13=0) or inches ($13=1)
395395
return mapValues({
396396
...defaultMachinePosition,
397397
...mpos
@@ -402,19 +402,13 @@ class Controller {
402402

403403
// Marlin
404404
if (this.type === MARLIN) {
405-
const { pos, modal = {} } = this.state;
406-
const units = {
407-
'G20': IMPERIAL_UNITS,
408-
'G21': METRIC_UNITS
409-
}[modal.units];
405+
const { pos } = this.state;
410406

411-
// Machine position are reported in current units
412-
return mapValues({
407+
// Machine position is reported in mm regardless of the current units
408+
return {
413409
...defaultMachinePosition,
414410
...pos
415-
}, (val) => {
416-
return (units === IMPERIAL_UNITS) ? in2mm(val) : val;
417-
});
411+
};
418412
}
419413

420414
// Smoothieware
@@ -425,7 +419,7 @@ class Controller {
425419
'G21': METRIC_UNITS
426420
}[modal.units];
427421

428-
// Machine position are reported in current units
422+
// Machine position is reported in current units
429423
return mapValues({
430424
...defaultMachinePosition,
431425
...mpos
@@ -466,7 +460,7 @@ class Controller {
466460
let { $13 = 0 } = { ...this.settings.settings };
467461
$13 = Number($13) || 0;
468462

469-
// Work position are reported in mm ($13=0) or inches ($13=1)
463+
// Work position is reported in mm ($13=0) or inches ($13=1)
470464
return mapValues({
471465
...defaultWorkPosition,
472466
...wpos
@@ -477,19 +471,13 @@ class Controller {
477471

478472
// Marlin
479473
if (this.type === MARLIN) {
480-
const { pos, modal = {} } = this.state;
481-
const units = {
482-
'G20': IMPERIAL_UNITS,
483-
'G21': METRIC_UNITS
484-
}[modal.units];
474+
const { pos } = this.state;
485475

486-
// Work position are reported in current units
487-
return mapValues({
476+
// Work position is reported in mm regardless of the current units
477+
return {
488478
...defaultWorkPosition,
489479
...pos
490-
}, (val) => {
491-
return (units === IMPERIAL_UNITS) ? in2mm(val) : val;
492-
});
480+
};
493481
}
494482

495483
// Smoothieware
@@ -500,7 +488,7 @@ class Controller {
500488
'G21': METRIC_UNITS
501489
}[modal.units];
502490

503-
// Work position are reported in current units
491+
// Work position is reported in current units
504492
return mapValues({
505493
...defaultWorkPosition,
506494
...wpos
@@ -517,7 +505,7 @@ class Controller {
517505
'G21': METRIC_UNITS
518506
}[modal.units];
519507

520-
// Work position are reported in current units, and also apply any offsets.
508+
// Work position is reported in current units, and also apply any offsets.
521509
return mapValues({
522510
...defaultWorkPosition,
523511
...wpos

0 commit comments

Comments
 (0)