From 85d4ecc76d3ceb305b529f1c7b6913328b40fa87 Mon Sep 17 00:00:00 2001
From: openbuilds-engineer
Date: Fri, 21 Dec 2018 15:56:11 +0200
Subject: [PATCH] Save machine profile to
---
app/js/grbl-defaults.js | 1 +
app/js/grblsettings.js | 5 +++++
app/js/websocket.js | 26 +++++++++++++++-----------
index.js | 11 +++++++++++
4 files changed, 32 insertions(+), 11 deletions(-)
diff --git a/app/js/grbl-defaults.js b/app/js/grbl-defaults.js
index 32589d6..bfe6152 100644
--- a/app/js/grbl-defaults.js
+++ b/app/js/grbl-defaults.js
@@ -652,6 +652,7 @@ function selectMachine(type) {
}
lastSelectedMachine = type;
+ sendGcode('$I=' + lastSelectedMachine)
checkifchanged()
};
diff --git a/app/js/grblsettings.js b/app/js/grblsettings.js
index 2287885..77845d4 100644
--- a/app/js/grblsettings.js
+++ b/app/js/grblsettings.js
@@ -249,6 +249,10 @@ function grblPopulate() {
} else {
$('#limitsinstalled:checkbox').prop('checked', false);
}
+
+ setTimeout(function() {
+ setMachineButton(laststatus.machine.name)
+ }, 500)
}
function checkifchanged() {
@@ -332,6 +336,7 @@ function refreshGrblSettings() {
$('#grblconfig').append("Please Wait...
Requesting updated parameters from the controller firmware...");
setTimeout(function() {
sendGcode('$$');
+ sendGcode('$I');
setTimeout(function() {
grblPopulate();
}, 500);
diff --git a/app/js/websocket.js b/app/js/websocket.js
index 4b2c175..c18b957 100644
--- a/app/js/websocket.js
+++ b/app/js/websocket.js
@@ -125,7 +125,7 @@ function initSocket() {
});
socket.on('data', function(data) {
- console.log(data)
+ // console.log(data)
var toPrint = escapeHTML(data.response);
// Parse Grbl Settings Feedback
@@ -150,6 +150,7 @@ function initSocket() {
function showGrbl(bool) {
if (bool) {
sendGcode('$$')
+ sendGcode('$I')
$("#grblButtons").show()
$("#firmwarename").html('Grbl')
} else {
@@ -362,11 +363,11 @@ function initSocket() {
$('#commstatus').html(string);
$('#runstatus').html(status.comms.runStatus);
$('#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.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) {
@@ -406,11 +407,11 @@ function initSocket() {
// $('#units').html("NOCOMM");
// }
//
- // if (status.comms.interfaces.activePort) {
- // $('#activeportstatus').html(status.comms.interfaces.activePort)
- // } else {
- // $('#activeportstatus').html("none")
- // }
+ if (status.comms.interfaces.activePort) {
+ $('#activeportstatus').html(status.comms.interfaces.activePort)
+ } else {
+ $('#activeportstatus').html("none")
+ }
//
// }
@@ -493,7 +494,10 @@ function populatePortsMenu() {
response += ``
var select = $("#portUSB").data("select");
select.data(response);
+ var select2 = $("#portUSB2").data("select");
+ select2.data(response);
$('#portUSB').parent(".select").removeClass('disabled')
+ $('#portUSB2').parent(".select").removeClass('disabled')
$("#connectBtn").attr('disabled', false);
}
diff --git a/index.js b/index.js
index 2a1e407..bbdeb3a 100644
--- a/index.js
+++ b/index.js
@@ -1,3 +1,5 @@
+process.env.ELECTRON_DISABLE_SECURITY_WARNINGS = '1';
+
console.log("Starting OpenBuilds CONTROL v" + require('./package').version)
var config = {};
@@ -247,6 +249,7 @@ var status = {
ipaddress: ip.address(),
},
machine: {
+ name: '',
inputs: [],
tools: {
hotend1: false,
@@ -810,6 +813,14 @@ io.on("connection", function(socket) {
port.on("data", function(data) {
var command = sentBuffer[0];
+ // Grbl $I parser
+
+ if (data.indexOf("[VER:") === 0) {
+ status.machine.name = data.split(':')[2].split(']')[0].toLowerCase()
+ io.sockets.emit("status", status);
+ }
+
+
// Machine Identification
if (data.indexOf("Grbl") === 0) { // Check if it's Grbl
status.comms.blocked = false;