fix belt settings mixture across mode changes. commend cleanup, rm dead code

This commit is contained in:
Stewart Allen 2024-07-08 17:34:43 -04:00
commit d88f603e38
4 changed files with 19 additions and 20 deletions

View file

@ -501,17 +501,14 @@ FDM.slice = function(settings, widget, onupdate, ondone) {
let y = poly.bounds.maxy; let y = poly.bounds.maxy;
let z = slice.z; let z = slice.z;
// at 45 degrees, 1mm in Z is 1mm in Y // at 45 degrees, 1mm in Z is 1mm in Y
// find formula for other angles
let by = (slope * z) - y; let by = (slope * z) - y;
if (by < miny) miny = by; if (by < miny) miny = by;
if (by < smin) smin = by; if (by < smin) smin = by;
} }
slice.belt = { miny, touch: miny.round(3) == 0 };
// console.log({ miny: miny.round(3), z:slice.z, touch: slice.belt.touch });
}
console.log({ smin: smin.round(5) });
// mark slices with tops touching belt // mark slices with tops touching belt
// also find max width of first 5 layers slice.belt = { miny, touch: miny.round(3) == 0 };
}
// find max width of first 5 layers for brim additions
let start; let start;
let minx = Infinity, maxx = -Infinity; let minx = Infinity, maxx = -Infinity;
let peek = 0; let peek = 0;
@ -522,13 +519,10 @@ FDM.slice = function(settings, widget, onupdate, ondone) {
maxx = Math.max(maxx, poly.bounds.maxx); maxx = Math.max(maxx, poly.bounds.maxx);
} }
} }
// mark slice as touching belt if near miny // find first slice touching belt for start of anchor
// if (Math.abs(slice.belt.miny - smin) < 0.01) { if (!start && slice.belt.touch) {
if (!start && slice.belt.touch) start = slice; start = slice;
// if (Math.abs(slice.belt.miny) < 0.01) { }
// slice.belt.touch = true;
// if (!start) start = slice;
// }
} }
// ensure we start against a layer with shells // ensure we start against a layer with shells
while (start && start.up && start.topShells().length === 0) { while (start && start.up && start.topShells().length === 0) {
@ -569,7 +563,6 @@ FDM.slice = function(settings, widget, onupdate, ondone) {
let snew = addto.addTop(splat).fill_sparse = [ splat ]; let snew = addto.addTop(splat).fill_sparse = [ splat ];
adds.push(snew); adds.push(snew);
start = addto; start = addto;
// console.log({ z: z.round(3), anchorlen: anchorlen.round(3) });
anchorlen -= (step * slope); anchorlen -= (step * slope);
} }
// add anchor bump // add anchor bump

View file

@ -259,6 +259,13 @@ gapp.register("kiri.init", [], (root, exports) => {
} }
function onBooleanClick(el) { function onBooleanClick(el) {
// copy some ui elements to target settings
let settings = api.conf.get();
settings.device.bedBelt = ui.deviceBelt.checked && api.mode.is_fdm();
settings.device.bedRound = ui.deviceRound.checked && api.mode.is_fdm();
settings.device.originCenter = ui.deviceOrigin.checked || ui.deviceRound.checked;
settings.device.fwRetract = ui.fwRetract.checked;
// refresh vars and other ui elements
uc.refresh(); uc.refresh();
api.conf.update(); api.conf.update();
DOC.activeElement.blur(); DOC.activeElement.blur();
@ -726,8 +733,6 @@ gapp.register("kiri.init", [], (root, exports) => {
try { try {
if (typeof(code) === 'string') code = js2o(code) || {}; if (typeof(code) === 'string') code = js2o(code) || {};
api.event.emit('device.set', devicename);
let mode = api.mode.get(), let mode = api.mode.get(),
lmode = mode.toLowerCase(), lmode = mode.toLowerCase(),
current = settings(), current = settings(),

View file

@ -931,7 +931,7 @@ gapp.register("kiri.main", [], (root, exports) => {
// restore cached device profile for this mode // restore cached device profile for this mode
if (current.cdev[mode]) { if (current.cdev[mode]) {
current.device = clone(current.cdev[mode]); current.device = clone(current.cdev[mode]);
api.event.emit('device.set', currentDeviceName()); api.event.emit('device.select', currentDeviceName());
} }
// hide/show // hide/show
api.uc.setVisible($('set-tools'), mode === 'CAM'); api.uc.setVisible($('set-tools'), mode === 'CAM');

View file

@ -46,10 +46,11 @@ function saveSettings() {
const mode = settings.mode; const mode = settings.mode;
settings.sproc[mode].default = settings.process; settings.sproc[mode].default = settings.process;
settings.sproc[mode][settings.process.processName] = settings.process; settings.sproc[mode][settings.process.processName] = settings.process;
settings.device.bedBelt = ui.deviceBelt.checked; // moved to init.onBooleanClick() -- delete later after confirming no side-effects
settings.device.bedRound = ui.deviceRound.checked; // settings.device.bedBelt = ui.deviceBelt.checked;
settings.device.originCenter = ui.deviceOrigin.checked || ui.deviceRound.checked; // settings.device.bedRound = ui.deviceRound.checked;
settings.device.fwRetract = ui.fwRetract.checked; // settings.device.originCenter = ui.deviceOrigin.checked || ui.deviceRound.checked;
// settings.device.fwRetract = ui.fwRetract.checked;
local.setItem('ws-settings', JSON.stringify(settings)); local.setItem('ws-settings', JSON.stringify(settings));
api.event.emit('settings.saved', settings); api.event.emit('settings.saved', settings);
} }