Skip to content
Permalink
Browse files

reset to default option for gcode

a button for resetting gcode to default seemed wise after some testing
  • Loading branch information...
Adukra committed Sep 7, 2018
1 parent c648543 commit 7b304172eacb1cf70f731d7c720fecf9d8502d25
Showing with 30 additions and 5 deletions.
  1. +2 −1 css/main.css
  2. +4 −2 index.html
  3. +24 −2 js/main.js
@@ -54,7 +54,8 @@
}

#sidebar .info-value,
#sidebar .form-control {
#sidebar .form-control,
#sidebar .btn-reset {
width: 40%;
float: left;
}
@@ -350,11 +350,13 @@ <h3 class="panel-title">GCode</h3>
</div>
<div id="gcode-body" class="panel-body collapse">
<div class="form-group">
<label for="start" style="width: 100%; float: none;" >Start</label>
<label for="resetStart" >Start</label>
<span class="btn btn-default btn-xs btn-reset" id="resetStart" title="Reset to default Start GCode" >Reset</span>
<textarea id="start" class="form-control" rows="5" style="width: 100%; float: none;" ></textarea>
</div>
<div class="form-group">
<label for="end" style="width: 100%; float: none;" >End</label>
<label for="resetEnd" >End</label>
<span class="btn btn-default btn-xs btn-reset" id="resetEnd" title="Reset to default End GCode" >Reset</span>
<textarea id="end" class="form-control" rows="5" style="width: 100%; float: none;" ></textarea>
</div>
</div>
@@ -86,8 +86,8 @@ var settings = new SLAcer.Settings({
}
},
gcode: {
start : 'G21;\nG91;\nM17;\nM106 S0;\nG28 Z0;\n;W:480;\n;H:854;\n',
end: 'M106 S0;\nG1 Z20.0;\nG4 S300;\nM18;',
start : getDefaultGcodeStart(),
end: getDefaultGcodeEnd(),
panel: {
collapsed: true,
position : 8
@@ -1088,6 +1088,8 @@ $sliceColor.colorpicker().on('changeColor.colorpicker', function(e) {
var $gcodeBody = initPanel('gcode');
var $gcodeStart = $gcodeBody.find('#start');
var $gcodeEnd = $gcodeBody.find('#end');
var $gcodeResetStart = $gcodeBody.find('#resetStart');
var $gcodeResetEnd = $gcodeBody.find('#resetEnd');

function updateGcodeUI() {
var gcode = settings.get('gcode');
@@ -1106,8 +1108,28 @@ function updateGcodeSettings() {
});
}

function resetGcodeStart() {
$gcodeStart.val(getDefaultGcodeStart());
updateGcodeSettings();
}

function resetGcodeEnd() {
$gcodeEnd.val(getDefaultGcodeEnd());
updateGcodeSettings();
}

function getDefaultGcodeStart() {
return 'G21;\nG91;\nM17;\nM106 S0;\nG28 Z0;\n;W:480;\n;H:854;\n';
}

function getDefaultGcodeEnd() {
return 'M106 S0;\nG1 Z20.0;\nG4 S300;\nM18;';
}

$gcodeStart.on('change', updateGcodeSettings);
$gcodeEnd.on('change', updateGcodeSettings);
$gcodeResetStart.on('click', resetGcodeStart);
$gcodeResetEnd.on('click', resetGcodeEnd);

updateGcodeUI();

0 comments on commit 7b30417

Please sign in to comment.
You can’t perform that action at this time.