From 494376ff782e13358f9f9b4be911083d1437f41f Mon Sep 17 00:00:00 2001 From: openbuilds-engineer Date: Tue, 7 May 2019 19:26:26 +0200 Subject: [PATCH] #59 Inch Modes --- app/index.html | 21 +++++----- app/js/grbl-defaults.js | 1 + app/js/grblsettings.js | 26 +----------- app/js/jog-realtime.js | 3 -- app/js/jog.js | 87 +++++++++++++++++++++++++++++++++++++---- app/js/keyboard.js | 6 ++- app/js/main.js | 3 -- app/js/viewer.js | 6 --- app/js/websocket.js | 87 +---------------------------------------- 9 files changed, 101 insertions(+), 139 deletions(-) delete mode 100644 app/js/jog-realtime.js diff --git a/app/index.html b/app/index.html index 94cee6f..427a88a 100644 --- a/app/index.html +++ b/app/index.html @@ -272,6 +272,10 @@ @@ -356,13 +360,13 @@
- +
@@ -600,28 +604,28 @@
- - - -
-//
-// -// - -clearWCO -clearSettings - function clearSettings() { Metro.dialog.create({ title: "Are you sure?", diff --git a/app/js/jog-realtime.js b/app/js/jog-realtime.js deleted file mode 100644 index aa16222..0000000 --- a/app/js/jog-realtime.js +++ /dev/null @@ -1,3 +0,0 @@ -function cancelJog() { - socket.emit('stop', true) -} \ No newline at end of file diff --git a/app/js/jog.js b/app/js/jog.js index 4ceb0f5..5f718d9 100644 --- a/app/js/jog.js +++ b/app/js/jog.js @@ -2,6 +2,36 @@ var allowContinuousJog = false; var jogdist = 10; var safeToUpdateSliders = true; + +function mmMode() { + unit = ' mm'; + $('#dist01label').html('0.1mm') + $('#dist1label').html('1mm') + $('#dist10label').html('10mm') + $('#dist100label').html('100mm') +} + +function inMode() { + unit = ' in'; + $('#dist01label').html('0.01"') + $('#dist1label').html('0.1"') + $('#dist10label').html('1"') + $('#dist100label').html('10"') + if (jogdist == 0.1) { + jogdist = .254 + } + if (jogdist == 1) { + jogdist = 2.54 + } + if (jogdist == 10) { + jogdist = 25.4 + } + if (jogdist == 100) { + jogdist = 254 + } +} + + $(document).ready(function() { $(document).mousedown(function(e) { @@ -14,7 +44,11 @@ $(document).ready(function() { $("#xPos").click(function() { $("#xPos").hide() - $("#xPosInput").show().focus().val(laststatus.machine.position.work.x) + if (unit == " mm") { + $("#xPosInput").show().focus().val(laststatus.machine.position.work.x) + } else if (unit == " in") { + $("#xPosInput").show().focus().val((laststatus.machine.position.work.x / 25.4).toFixed(2)) + } }); $("#xPosInput").blur(function() { @@ -30,13 +64,22 @@ $(document).ready(function() { $("#xPosInput").hide() //Enable the textbox again if needed. $(this).removeAttr("disabled"); + if (unit == " mm") { + sendGcode("G21") + } else if (unit == " in") { + sendGcode("G20") + } sendGcode("G0 X" + $("#xPosInput").val()) } }); $("#yPos").click(function() { $("#yPos").hide() - $("#yPosInput").show().focus().val(laststatus.machine.position.work.y) + if (unit == " mm") { + $("#yPosInput").show().focus().val(laststatus.machine.position.work.y) + } else if (unit == " in") { + $("#yPosInput").show().focus().val((laststatus.machine.position.work.y / 25.4).toFixed(2)) + } }); $("#yPosInput").blur(function() { @@ -52,13 +95,22 @@ $(document).ready(function() { $("#yPosInput").hide() //Enable the textbox again if needed. $(this).removeAttr("disabled"); + if (unit == " mm") { + sendGcode("G21") + } else if (unit == " in") { + sendGcode("G20") + } sendGcode("G0 Y" + $("#yPosInput").val()) } }); $("#zPos").click(function() { $("#zPos").hide() - $("#zPosInput").show().focus().val(laststatus.machine.position.work.z) + if (unit == " mm") { + $("#zPosInput").show().focus().val(laststatus.machine.position.work.z) + } else if (unit == " in") { + $("#zPosInput").show().focus().val((laststatus.machine.position.work.z / 25.4).toFixed(2)) + } }); $("#zPosInput").blur(function() { @@ -74,13 +126,22 @@ $(document).ready(function() { $("#zPosInput").hide() //Enable the textbox again if needed. $(this).removeAttr("disabled"); + if (unit == " mm") { + sendGcode("G21") + } else if (unit == " in") { + sendGcode("G20") + } sendGcode("G0 Z" + $("#zPosInput").val()) } }); $('#dist01').on('click', function(ev) { - jogdist = 0.1; + if (unit == " mm") { + jogdist = 0.1; + } else if (unit == " in") { + jogdist = 0.254; + } $('.distbtn').removeClass('bd-openbuilds') $('#dist01').addClass('bd-openbuilds') $('.jogdist').removeClass('fg-openbuilds') @@ -90,7 +151,11 @@ $(document).ready(function() { }) $('#dist1').on('click', function(ev) { - jogdist = 1; + if (unit == " mm") { + jogdist = 1; + } else if (unit == " in") { + jogdist = 2.54; + } $('.distbtn').removeClass('bd-openbuilds') $('#dist1').addClass('bd-openbuilds') $('.jogdist').removeClass('fg-openbuilds') @@ -100,7 +165,11 @@ $(document).ready(function() { }) $('#dist10').on('click', function(ev) { - jogdist = 10; + if (unit == " mm") { + jogdist = 10; + } else if (unit == " in") { + jogdist = 25.4; + } $('.distbtn').removeClass('bd-openbuilds') $('#dist10').addClass('bd-openbuilds') $('.jogdist').removeClass('fg-openbuilds') @@ -110,7 +179,11 @@ $(document).ready(function() { }) $('#dist100').on('click', function(ev) { - jogdist = 100; + if (unit == " mm") { + jogdist = 100; + } else if (unit == " in") { + jogdist = 254.0; + } $('.distbtn').removeClass('bd-openbuilds') $('#dist100').addClass('bd-openbuilds') $('.jogdist').removeClass('fg-openbuilds') diff --git a/app/js/keyboard.js b/app/js/keyboard.js index 93eb70b..759faeb 100644 --- a/app/js/keyboard.js +++ b/app/js/keyboard.js @@ -1,5 +1,9 @@ var keyboardShortcuts = false; -// + +function cancelJog() { + socket.emit('stop', true) +} + $(document).ready(function() { if (localStorage.getItem('continuousJog')) { if (JSON.parse(localStorage.getItem('continuousJog')) == true) { diff --git a/app/js/main.js b/app/js/main.js index d7e163d..0996fd8 100644 --- a/app/js/main.js +++ b/app/js/main.js @@ -18,9 +18,6 @@ function getChangelog() { template2 += `` $("#changelog").html(template2); }); - // if (!Metro.dialog.isOpen('#settingsmodal')) { - // Metro.dialog.open('#splashModal') - // } } $(document).ready(function() { diff --git a/app/js/viewer.js b/app/js/viewer.js index b1b8f31..eb25e5c 100644 --- a/app/js/viewer.js +++ b/app/js/viewer.js @@ -117,12 +117,6 @@ function drawWorkspace(xmin, xmax, ymin, ymax) { side: THREE.DoubleSide }); - // var skyMat = new THREE.MeshPhongMaterial({ - // color: 0x0000ff, - // specular: 0x0000ff, - // shininess: 00 - // }); - sky = new THREE.Mesh(skyGeo, skyMat); sky.name = "Skydome" workspace.add(sky); diff --git a/app/js/websocket.js b/app/js/websocket.js index 378962a..9265326 100644 --- a/app/js/websocket.js +++ b/app/js/websocket.js @@ -9,6 +9,7 @@ var laststatus var simstopped = false; var bellstate = false; var toast = Metro.toast.create; +var unit = " mm" $(document).ready(function() { initSocket(); @@ -47,25 +48,6 @@ function printLog(string) { } } -// function printUpdateLog(string) { -// if (string.isString) { -// // split(/\r\n|\n|\r/); -// string = string.replace(/\r\n|\n|\r/, "
"); -// } -// if ($('#console p').length > 100) { -// // remove oldest if already at 300 lines -// $('#console p').first().remove(); -// } -// var template = '

'; -// var time = new Date(); -// -// template += '[' + (time.getHours() < 10 ? '0' : '') + time.getHours() + ":" + (time.getMinutes() < 10 ? '0' : '') + time.getMinutes() + ":" + (time.getSeconds() < 10 ? '0' : '') + time.getSeconds() + '] '; -// template += string; -// $('#updateconsole').append(template); -// $('#updateconsole').scrollTop($("#updateconsole")[0].scrollHeight - $("#updateconsole").height()); -// } - - function initSocket() { socket = io.connect(server); // socket.io init printLog("[ Websocket ] Bidirectional Websocket Interface Started") @@ -116,8 +98,6 @@ function initSocket() { socket.on('updateready', function(data) { $('#availVersion').html(data) Metro.dialog.open('#downloadUpdate') - - // $('#applyupdatesbtn').prop('disabled', false); }); socket.on('updateprogress', function(data) { @@ -298,15 +278,6 @@ function initSocket() { $('#runStatus').html("Controller: " + status.comms.runStatus); - - // if (status.machine.firmware.state.units == "G20") { - // var unit = " in" - // } else if (status.machine.firmware.state.units == "G21") { - // var unit = " mm" - // } else { - var unit = " mm" - // } - if (unit == " mm") { var xpos = status.machine.position.work.x + unit; var ypos = status.machine.position.work.y + unit; @@ -346,11 +317,6 @@ function initSocket() { } } - // $('#T0CurTemp').html(status.machine.temperature.actual.t0.toFixed(1) + " / " + status.machine.temperature.setpoint.t0.toFixed(1)); - // $('#T1CurTemp').html(status.machine.temperature.actual.t1.toFixed(1) + " / " + status.machine.temperature.setpoint.t1.toFixed(1)); - // $('#B0CurTemp').html(status.machine.temperature.actual.b.toFixed(1) + " / " + status.machine.temperature.setpoint.b.toFixed(1)); - // setTemp(status.machine.temperature.actual.t0, status.machine.temperature.actual.t1, status.machine.temperature.actual.b) - if (safeToUpdateSliders) { if ($('#fro').data('slider') && $('#tro').data('slider')) { $('#fro').data('slider').val(status.machine.overrides.feedOverride) @@ -430,57 +396,12 @@ function initSocket() { } $('#commstatus').html(string); $('#drvqueue').html(status.comms.queue); - // if (status.machine.firmware.buffer.length > 0) { - // $('#buffstatus').html(status.machine.firmware.buffer[0] + " blocks / " + status.machine.firmware.buffer[1] + " bytes"); - // } else { - // $('#buffstatus').html("NOCOMM"); - // } - // if (status.machine.firmware.state) { - // if (status.machine.firmware.state.workoffset.length) { - // $('#wcostatus').html(status.machine.firmware.state.workoffset); - // } else { - // $('#wcostatus').html("NOCOMM"); - // } - // if (status.machine.firmware.state.plane.length) { - // $('#planestatus').html(status.machine.firmware.state.plane); - // } else { - // $('#planestatus').html("NOCOMM"); - // } - // if (status.machine.firmware.state.absrel.length) { - // if (status.machine.firmware.state.absrel == "G90") { - // $('#absrel').html(status.machine.firmware.state.absrel + " (absolute)"); - // } else if (status.machine.firmware.state.absrel == "G91") { - // $('#absrel').html(status.machine.firmware.state.absrel + " (relative)"); - // } - // } else { - // $('#absrel').html("NOCOMM"); - // } - // if (status.machine.firmware.state.units.length) { - // if (status.machine.firmware.state.units == "G20") { - // $('#units').html(status.machine.firmware.state.units + " (inches)"); - // $('#dist01label').html("0.1in"); - // $('#dist1label').html("1in"); - // $('#dist10label').html("10in"); - // $('#dist100label').html("100in"); - // } else if (status.machine.firmware.state.units == "G21") { - // $('#units').html(status.machine.firmware.state.units + " (mm)"); - // $('#dist01label').html("0.1mm"); - // $('#dist1label').html("1mm"); - // $('#dist10label').html("10mm"); - // $('#dist100label').html("100mm"); - // } - // } else { - // $('#units').html("NOCOMM"); - // } - // if (status.comms.interfaces.activePort) { $('#activeportstatus').html(status.comms.interfaces.activePort) } else { $('#activeportstatus').html("none") } - // - // } // Set the Connection Toolbar option setConnectBar(status.comms.connectionStatus, status); @@ -580,12 +501,6 @@ function sendGcode(gcode) { } } -// function ContextLineRun() { //Rightclick Contextmenu in Ace editor: Send single line of gcode -// sendGcode(editor.session.getLine(editor.getSelectionRange().start.row)); -// $('#editorContextMenu').hide(); -// } - - function feedOverride(step) { if (socket) { socket.emit('feedOverride', step);