Skip to content

Commit

Permalink
Change abort behavior for Grbl and Smoothie
Browse files Browse the repository at this point in the history
  • Loading branch information
cheton committed Dec 8, 2016
1 parent 7cabba9 commit e2abb57
Showing 1 changed file with 38 additions and 7 deletions.
45 changes: 38 additions & 7 deletions src/app/controllers/Grbl/GrblController.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ import {
import {
GRBL,
GRBL_ACTIVE_STATE_RUN,
GRBL_ACTIVE_STATE_HOLD,
GRBL_REALTIME_COMMANDS
} from './constants';
import {
SMOOTHIE
SMOOTHIE,
SMOOTHIE_ACTIVE_STATE_HOLD
} from '../Smoothie/constants';

const noop = _.noop;
Expand Down Expand Up @@ -147,6 +147,11 @@ class GrblController {
return;
}

if (this.workflowState !== WORKFLOW_STATE_RUNNING) {
log.error(`[Grbl] Unexpected workflow state: ${this.workflowState}`);
return;
}

gcode = ('' + gcode).trim();
if (gcode.length > 0) {
this.serialport.write(gcode + '\n');
Expand Down Expand Up @@ -538,11 +543,32 @@ class GrblController {
this.workflowState = WORKFLOW_STATE_IDLE;
this.sender.rewind(); // rewind sender queue

if (activeState === GRBL_ACTIVE_STATE_RUN) {
this.write(socket, '!');
this.write(socket, '\x18'); // ctrl-x
} else if (activeState === GRBL_ACTIVE_STATE_HOLD) {
this.write(socket, '\x18'); // ctrl-x
// Grbl
if (this.firmware === GRBL) {
let delay = 0;

if (activeState === GRBL_ACTIVE_STATE_RUN) {
this.write(socket, '!'); // hold
delay = 50; // 50ms delay
}

setTimeout(() => {
this.write(socket, '\x18'); // ctrl-x
}, delay);
}

// Smoothie
if (this.firmware === SMOOTHIE) {
let delay = 0;

if (activeState === SMOOTHIE_ACTIVE_STATE_HOLD) {
this.write(socket, '~'); // resume
delay = 50; // 50ms delay
}

setTimeout(() => {
this.write(socket, '\x18'); // ctrl-x
}, delay);
}
},
'pause': () => {
Expand Down Expand Up @@ -576,6 +602,11 @@ class GrblController {
}
},
'reset': () => {
if (this.workflowState !== WORKFLOW_STATE_IDLE) {
this.workflowState = WORKFLOW_STATE_IDLE;
this.sender.rewind(); // rewind sender queue
}

this.write(socket, '\x18'); // ^x
},
'unlock': () => {
Expand Down

0 comments on commit e2abb57

Please sign in to comment.