Skip to content

Commit

Permalink
GrblHal Build date on Troubleshooting tab, and Restore AutoBackups
Browse files Browse the repository at this point in the history
  • Loading branch information
petervanderwalt committed Dec 5, 2024
1 parent 99ad875 commit ba00fe3
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 12 deletions.
45 changes: 40 additions & 5 deletions app/js/grbl-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ function loadGrblBackupFile(f) {
checkifchanged();
enableLimits(); // Enable or Disable
displayDirInvert();
$("#grblSettingsAdvTab").click();
}
}
}
Expand Down Expand Up @@ -78,6 +79,40 @@ function restoreAutoBackup(index) {
console.log('Restoring backup:', selectedBackup);
// Call your function to restore the backup here, e.g., update grblParams
// Example: grblParams = selectedBackup.grblParams;

// Retrieve grblParams from the backup
const grblParamsBackup = selectedBackup.grblParams;

// Iterate through the keys in the grblParams object and apply them using jQuery
for (const key in grblParamsBackup) {
if (grblParamsBackup.hasOwnProperty(key)) {
const paramValue = grblParamsBackup[key];
const parsedValue = parseFloat(paramValue);

// Check if the parsed value is a valid number
if (!isNaN(parsedValue)) {
// Update the input field based on the parameter using jQuery
const inputElement = $("#val-" + key.substring(1) + "-input");

if (inputElement.length) {
inputElement.val(parsedValue); // Apply the value to the input field
}
} else {
console.warn(`Invalid value for ${key}: ${paramValue}`);
}

// Optionally, fix or apply any GrblHAL-specific settings
fixGrblHALSettings(key.substring(1)); // Adjust as needed

// Optionally, other functions you might call for updating the machine state
// Example: checkifchanged(); enableLimits(); displayDirInvert();
}
}
// Call any post-restoration functions you need (e.g., re-enable limits, etc.)
checkifchanged();
enableLimits();
displayDirInvert();
$("#grblSettingsAdvTab").click();
}


Expand Down Expand Up @@ -189,8 +224,8 @@ function grblPopulate() {
<form id="grblSettingsTable">
<ul data-role="tabs" data-expand="true" class="mb-2">
<li onclick="showBasicSettings()"><a href="#"><small><i class="fas fa-fw fa-cog mr-1 fg-darkGreen"></i>Basic Settings</a></small></li>
<li onclick="showAdvSettings()"><a href="#"><small><i class="fas fa-fw fa-cogs mr-1 fg-darkRed"></i>Advanced Settings</a></small></li>
<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>
<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>
</ul>
Expand Down Expand Up @@ -521,9 +556,9 @@ function checkifchanged() {
(!compareAsNumber && newVal !== oldVal)) {
hasChanged = true;

console.log("changed: " + key);
console.log("old: " + oldVal);
console.log("new: " + newVal);
// console.log("changed: " + key);
// console.log("old: " + oldVal);
// console.log("new: " + newVal);

if (!$("#val-" + j + "-input").parent().is('td')) {
$("#val-" + j + "-input").parent().addClass('alert');
Expand Down
8 changes: 5 additions & 3 deletions app/js/websocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ function showGrbl(bool, firmware) {
if (localStorage.getItem('jogOverride')) {
jogOverride(localStorage.getItem('jogOverride'))
}
if (laststatus !== undefined) {
$("#firmwareversionstatus").html(laststatus.machine.firmware.platform + " " + laststatus.machine.firmware.version);
};

}

function printLogModern(icon, source, string, printLogCls) {
Expand Down Expand Up @@ -743,6 +741,10 @@ function initSocket() {
}


$("#firmwareversionstatus").html(status.machine.firmware.platform + " " + status.machine.firmware.version + " (" + status.machine.firmware.date + ")");






Expand Down
15 changes: 11 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1197,10 +1197,18 @@ io.on("connection", function(socket) {

// Grbl $I parser
if (data.indexOf("[VER:") === 0) {
status.machine.name = data.split(':')[2].split(']')[0].toLowerCase()
// Extracting the full version (1.1f)
const version = data.split(':')[1].split('.')[0] + '.' + data.split(':')[1].split('.')[1];
// Extracting the date (20240402)
const date = data.split(':')[1].split('.')[2];

status.machine.firmware.version = version;
status.machine.firmware.date = date;

io.sockets.emit("status", status);

status.machine.name = data.split(':')[2].split(']')[0].toLowerCase()
io.sockets.emit("machinename", data.split(':')[2].split(']')[0].toLowerCase());
status.machine.firmware.date = data.split(':')[1].split(".")[2];
}

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

// Log the initial systemInformation object
console.log(JSON.stringify(systemInformation, null, 2));
debug_log(JSON.stringify(systemInformation, null, 2));

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

0 comments on commit ba00fe3

Please sign in to comment.