Skip to content

Commit

Permalink
Merge pull request #301 from sharmstr/resume-with-spindle
Browse files Browse the repository at this point in the history
Improve Resume Wizard (Spindle Control)
  • Loading branch information
petervanderwalt authored Mar 9, 2023
2 parents 424635a + 189ddb6 commit 4cef4d0
Showing 1 changed file with 35 additions and 5 deletions.
40 changes: 35 additions & 5 deletions app/wizards/resume/resume.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ function startFromHere(lineNumber) {
var lineF = "";
var lineFmin = 0;
var lineFmax = 0;
var line = ''
var line = '';
var spindle = null;


var foundZUp = false;
var foundZUpLine = 0;



for (var i = 1; i < lineNumber; i++) {

currentLine = editor.session.getLine(i);
if (currentLine.length > 0) {
currentLine = currentLine.split(/[;(]/); // Remove everything after ; or ( = comment
Expand Down Expand Up @@ -139,6 +139,7 @@ function startFromHere(lineNumber) {
<ul>
<li>Keep the first <span class="tally dark" id="resumeZUpLine"></span> lines of the file as header</li>
<li>Raise Z with the GCODE: <span class="tally dark" id="resumeZUp"></span></li>
<li><span id="spindleMsg"><span class="bg-red fg-white">Spindle ON command not found!</span></span><span class="tally dark" id="resumeSpindle"></span></li>
<li>Move to entry position with GCODE: <span class="tally dark" id="resumeXYA"></span></li>
<li>Move to cutting height with GCODE: <span class="tally dark" id="resumeZm"></span></li>
<li>Run GCODE starting at line <span class="tally dark" id="resumeLastLine"></span> and continue with the job</li>
Expand All @@ -147,10 +148,29 @@ function startFromHere(lineNumber) {
</div>
</form>
<div class="remark warning">
NOTE: Use this tool at your own risk. Recovering GCODE is a risky operation. You are also responsible for ensuring that work origin is correctly set. Use at your own risk.
NOTE: Use this tool at your own risk. Recovering GCODE is a risky operation. You are also responsible for ensuring that work origin is correctly set</span>. Use at your own risk.
</div>
`

// Search backwards from start line to find last instance of spindle cmd
for (var i = lineNumber - 1; i >= 0; i--) {
currentLine = editor.session.getLine(i);
if (currentLine.length > 0) {
currentLine = currentLine.split(/[;(]/); // Remove everything after ; or ( = comment
line = currentLine[0]
line = line.toUpperCase();

if ( line.indexOf('M3') != -1 || line.indexOf('M4') != -1 ) {
foundSpindle = true;
spindle = line;
// Search forward one line for pause cmd
if (editor.session.getLine(i + 1).toUpperCase().indexOf('G4') != -1) {
console.log('pause line? ' + editor.session.getLine(i + 1))
spindle += '\n' + editor.session.getLine(i + 1).toUpperCase();
}
break;
}
}
}

Metro.dialog.create({
title: "<i class='fas fa-fw fa-route'></i> Recover Job From Line Number",
Expand Down Expand Up @@ -179,6 +199,11 @@ function startFromHere(lineNumber) {
$('#resumeXYA').html(GcodeLineXYA);
$('#resumeZm').html(GcodeLineZDown);

if (spindle) {
$('#spindleMsg').html("Turn spindle ON: ");
$('#resumeSpindle').html(spindle);
}

//Metro.dialog.open("#ResumeFileDialog");
}

Expand All @@ -191,13 +216,18 @@ function redoJob() {
var ZGcode = $('#resumeZm').html();
var resumeLineNumber = $('#resumeLastLine').html();
var resumeLastNumber = editor.session.getLength();
var spindleGcode = $('#resumeSpindle').html();


for (var i = 0; i < startLineNumber; i++) {
line = editor.session.getLine(i);
gcode += line + '\n'
}

if (spindleGcode != '') {
gcode += spindleGcode + '\n';
}

gcode += XYAGcode + '\n';
gcode += ZGcode + '\n';

Expand Down

0 comments on commit 4cef4d0

Please sign in to comment.