Skip to content

Commit ba00fe3

Browse files
GrblHal Build date on Troubleshooting tab, and Restore AutoBackups
1 parent 99ad875 commit ba00fe3

File tree

3 files changed

+56
-12
lines changed

3 files changed

+56
-12
lines changed

app/js/grbl-settings.js

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ function loadGrblBackupFile(f) {
3636
checkifchanged();
3737
enableLimits(); // Enable or Disable
3838
displayDirInvert();
39+
$("#grblSettingsAdvTab").click();
3940
}
4041
}
4142
}
@@ -78,6 +79,40 @@ function restoreAutoBackup(index) {
7879
console.log('Restoring backup:', selectedBackup);
7980
// Call your function to restore the backup here, e.g., update grblParams
8081
// Example: grblParams = selectedBackup.grblParams;
82+
83+
// Retrieve grblParams from the backup
84+
const grblParamsBackup = selectedBackup.grblParams;
85+
86+
// Iterate through the keys in the grblParams object and apply them using jQuery
87+
for (const key in grblParamsBackup) {
88+
if (grblParamsBackup.hasOwnProperty(key)) {
89+
const paramValue = grblParamsBackup[key];
90+
const parsedValue = parseFloat(paramValue);
91+
92+
// Check if the parsed value is a valid number
93+
if (!isNaN(parsedValue)) {
94+
// Update the input field based on the parameter using jQuery
95+
const inputElement = $("#val-" + key.substring(1) + "-input");
96+
97+
if (inputElement.length) {
98+
inputElement.val(parsedValue); // Apply the value to the input field
99+
}
100+
} else {
101+
console.warn(`Invalid value for ${key}: ${paramValue}`);
102+
}
103+
104+
// Optionally, fix or apply any GrblHAL-specific settings
105+
fixGrblHALSettings(key.substring(1)); // Adjust as needed
106+
107+
// Optionally, other functions you might call for updating the machine state
108+
// Example: checkifchanged(); enableLimits(); displayDirInvert();
109+
}
110+
}
111+
// Call any post-restoration functions you need (e.g., re-enable limits, etc.)
112+
checkifchanged();
113+
enableLimits();
114+
displayDirInvert();
115+
$("#grblSettingsAdvTab").click();
81116
}
82117

83118

@@ -189,8 +224,8 @@ function grblPopulate() {
189224
<form id="grblSettingsTable">
190225
191226
<ul data-role="tabs" data-expand="true" class="mb-2">
192-
<li onclick="showBasicSettings()"><a href="#"><small><i class="fas fa-fw fa-cog mr-1 fg-darkGreen"></i>Basic Settings</a></small></li>
193-
<li onclick="showAdvSettings()"><a href="#"><small><i class="fas fa-fw fa-cogs mr-1 fg-darkRed"></i>Advanced Settings</a></small></li>
227+
<li id="grblSettingsBasicTab" onclick="showBasicSettings()"><a href="#"><small><i class="fas fa-fw fa-cog mr-1 fg-darkGreen"></i>Basic Settings</a></small></li>
228+
<li id="grblSettingsAdvTab" onclick="showAdvSettings()"><a href="#"><small><i class="fas fa-fw fa-cogs mr-1 fg-darkRed"></i>Advanced Settings</a></small></li>
194229
</ul>
195230
196231
@@ -521,9 +556,9 @@ function checkifchanged() {
521556
(!compareAsNumber && newVal !== oldVal)) {
522557
hasChanged = true;
523558

524-
console.log("changed: " + key);
525-
console.log("old: " + oldVal);
526-
console.log("new: " + newVal);
559+
// console.log("changed: " + key);
560+
// console.log("old: " + oldVal);
561+
// console.log("new: " + newVal);
527562

528563
if (!$("#val-" + j + "-input").parent().is('td')) {
529564
$("#val-" + j + "-input").parent().addClass('alert');

app/js/websocket.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,7 @@ function showGrbl(bool, firmware) {
6060
if (localStorage.getItem('jogOverride')) {
6161
jogOverride(localStorage.getItem('jogOverride'))
6262
}
63-
if (laststatus !== undefined) {
64-
$("#firmwareversionstatus").html(laststatus.machine.firmware.platform + " " + laststatus.machine.firmware.version);
65-
};
63+
6664
}
6765

6866
function printLogModern(icon, source, string, printLogCls) {
@@ -743,6 +741,10 @@ function initSocket() {
743741
}
744742

745743

744+
$("#firmwareversionstatus").html(status.machine.firmware.platform + " " + status.machine.firmware.version + " (" + status.machine.firmware.date + ")");
745+
746+
747+
746748

747749

748750

index.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1197,10 +1197,18 @@ io.on("connection", function(socket) {
11971197

11981198
// Grbl $I parser
11991199
if (data.indexOf("[VER:") === 0) {
1200-
status.machine.name = data.split(':')[2].split(']')[0].toLowerCase()
1200+
// Extracting the full version (1.1f)
1201+
const version = data.split(':')[1].split('.')[0] + '.' + data.split(':')[1].split('.')[1];
1202+
// Extracting the date (20240402)
1203+
const date = data.split(':')[1].split('.')[2];
1204+
1205+
status.machine.firmware.version = version;
1206+
status.machine.firmware.date = date;
1207+
12011208
io.sockets.emit("status", status);
1209+
1210+
status.machine.name = data.split(':')[2].split(']')[0].toLowerCase()
12021211
io.sockets.emit("machinename", data.split(':')[2].split(']')[0].toLowerCase());
1203-
status.machine.firmware.date = data.split(':')[1].split(".")[2];
12041212
}
12051213

12061214
if (data.indexOf("[OPT:") === 0) {
@@ -1393,7 +1401,6 @@ io.on("connection", function(socket) {
13931401
io.sockets.emit('data', output);
13941402
}
13951403
}
1396-
status.machine.firmware.date = "";
13971404
// debug_log("GRBL detected");
13981405
// setTimeout(function() {
13991406
// io.sockets.emit('grbl', status.machine.firmware)
@@ -4002,7 +4009,7 @@ async function getSystemInfo() {
40024009
}, 60000); // 60,000 ms = 1 minute
40034010

40044011
// Log the initial systemInformation object
4005-
console.log(JSON.stringify(systemInformation, null, 2));
4012+
debug_log(JSON.stringify(systemInformation, null, 2));
40064013

40074014
// Return the systemInformation object (if needed for further use)
40084015
io.sockets.emit("sysinfo", systemInformation);

0 commit comments

Comments
 (0)