88 METRIC_UNITS ,
99 // Controller
1010 GRBL ,
11+ MARLIN ,
1112 SMOOTHIE ,
1213 TINYG
1314} from './constants' ;
@@ -350,7 +351,7 @@ class Controller {
350351 // Gets the machine state.
351352 // @return {string|number } Returns the machine state.
352353 getMachineState ( ) {
353- if ( [ GRBL , SMOOTHIE , TINYG ] . indexOf ( this . type ) < 0 ) {
354+ if ( [ GRBL , MARLIN , SMOOTHIE , TINYG ] . indexOf ( this . type ) < 0 ) {
354355 return '' ;
355356 }
356357
@@ -362,6 +363,8 @@ class Controller {
362363
363364 if ( this . type === GRBL ) {
364365 machineState = this . state . machineState ;
366+ } else if ( this . type === MARLIN ) {
367+ machineState = this . state . machineState ;
365368 } else if ( this . type === SMOOTHIE ) {
366369 machineState = this . state . machineState ;
367370 } else if ( this . type === TINYG ) {
@@ -397,6 +400,23 @@ class Controller {
397400 } ) ;
398401 }
399402
403+ // Marlin
404+ if ( this . type === MARLIN ) {
405+ const { pos, modal = { } } = this . state ;
406+ const units = {
407+ 'G20' : IMPERIAL_UNITS ,
408+ 'G21' : METRIC_UNITS
409+ } [ modal . units ] ;
410+
411+ // Machine position are reported in current units
412+ return mapValues ( {
413+ ...defaultMachinePosition ,
414+ ...pos
415+ } , ( val ) => {
416+ return ( units === IMPERIAL_UNITS ) ? in2mm ( val ) : val ;
417+ } ) ;
418+ }
419+
400420 // Smoothieware
401421 if ( this . type === SMOOTHIE ) {
402422 const { mpos, modal = { } } = this . state ;
@@ -455,6 +475,23 @@ class Controller {
455475 } ) ;
456476 }
457477
478+ // Marlin
479+ if ( this . type === MARLIN ) {
480+ const { pos, modal = { } } = this . state ;
481+ const units = {
482+ 'G20' : IMPERIAL_UNITS ,
483+ 'G21' : METRIC_UNITS
484+ } [ modal . units ] ;
485+
486+ // Work position are reported in current units
487+ return mapValues ( {
488+ ...defaultWorkPosition ,
489+ ...pos
490+ } , ( val ) => {
491+ return ( units === IMPERIAL_UNITS ) ? in2mm ( val ) : val ;
492+ } ) ;
493+ }
494+
458495 // Smoothieware
459496 if ( this . type === SMOOTHIE ) {
460497 const { wpos, modal = { } } = this . state ;
@@ -514,6 +551,13 @@ class Controller {
514551 } ;
515552 }
516553
554+ if ( this . type === MARLIN ) {
555+ return {
556+ ...defaultModalState ,
557+ ...this . state . modal
558+ } ;
559+ }
560+
517561 if ( this . type === SMOOTHIE ) {
518562 return {
519563 ...defaultModalState ,
0 commit comments