Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MODVFD Support for Firmware Tool #514

Merged
merged 1 commit into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/app/containers/Firmware/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ export const convertValueToArray = (value, possibilities) => {
export const applyNewSettings = (settings, eeprom, setSettingsToApply) => {
let index22 = 200; // index of $22 - default is 200 because we have less eeprom values than that, so it will never be set to this value
let index2021 = -1; // index of $20 or $21, whichever comes first
let tableNeedsReparsing = false;
let changedSettings = settings
.filter(item => eeprom[item.setting] !== item.value) // Only retrieve settings that have been modified
.map((item, i) => { // Create array of set eeprom value strings (ex. "$0=1")
Expand All @@ -185,6 +186,9 @@ export const applyNewSettings = (settings, eeprom, setSettingsToApply) => {
// we are going to have to switch it with $20, so save the index.
index2021 = i;
}
if (item.setting === '$511' || item.setting === '$512' || item.setting === '$513') {
tableNeedsReparsing = true;
}
return `${item.setting}=${item.value}`;
});

Expand All @@ -196,6 +200,13 @@ export const applyNewSettings = (settings, eeprom, setSettingsToApply) => {
changedSettings[index2021] = setting22;
}
changedSettings.push('$$'); // Add setting refresh to end so tool updates values
if (tableNeedsReparsing) {
// if 511-513 have changed, reparse the table
changedSettings.push('$ES', '$ESH');
// if we disable MODVFD, there will still be the extra settings in the runner's list,
// so reset the list whenever 511-513 is changed
controller.command('runner:resetSettings');
}
controller.command('gcode', changedSettings);
setSettingsToApply(false);
Toaster.pop({
Expand Down
3 changes: 3 additions & 0 deletions src/server/controllers/Grblhal/GrblHalController.js
Original file line number Diff line number Diff line change
Expand Up @@ -2159,6 +2159,9 @@ class GrblHalController {
'updateRotaryMode': () => {
const [isInRotaryMode] = args;
this.isInRotaryMode = isInRotaryMode;
},
'runner:resetSettings': () => {
this.runner.deleteSettings();
}
}[cmd];

Expand Down
4 changes: 4 additions & 0 deletions src/server/controllers/Grblhal/GrblHalRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,10 @@ class GrblHalRunner extends events.EventEmitter {
forceOK() {
this.emit('ok', { raw: 'force ok' });
}

deleteSettings() {
this.settings.settings = {};
}
}

export default GrblHalRunner;
Loading