checkpoint WireEDM feature development

This commit is contained in:
Stewart Allen 2024-06-11 13:16:02 -07:00
commit ce78873f76
7 changed files with 51 additions and 21 deletions

View file

@ -3,8 +3,8 @@
"internal": 0,
"imageURL": "",
"bedHeight": 2.5,
"bedWidth": 200,
"bedDepth": 100,
"bedWidth": 100,
"bedDepth": 200,
"maxHeight": 50,
"gcodePre": [
"G21 ; set units to MM (required)",

View file

@ -25,10 +25,14 @@ const DRIVER = driver.LASER = {
exportDXF
};
function init(kiri, api, driver) {
const state = {};
function init(kiri, api, current) {
api.event.on("settings.saved", settings => {
let ui = kiri.api.ui;
});
state.driver = current;
state.isWEDM = (current === driver.WEDM);
}
/**
@ -40,6 +44,8 @@ function init(kiri, api, driver) {
* @param {Function} ondone (called when complete with an array of Slice objects)
*/
function slice(settings, widget, onupdate, ondone) {
let { isWEDM } = state;
let proc = settings.process;
let offset = proc.ctSliceKerf || 0;
let color = settings.controller.dark ? 0xbbbbbb : 0;
@ -48,7 +54,7 @@ function slice(settings, widget, onupdate, ondone) {
return ondone("invalid slice height");
}
let { ctSliceSingle, ctSliceHeight, ctSliceHeightMin } = proc;
let { ctSliceSingle, ctSliceHeight, ctSliceHeightMin, ctOmitInner } = proc;
let bounds = widget.getBoundingBox();
let points = widget.getPoints();
let indices = [];
@ -92,6 +98,7 @@ function slice(settings, widget, onupdate, ondone) {
widget.slices = output.slices.map(data => {
let { z, lines, groups } = data;
let tops = POLY.nest(groups);
if (ctOmitInner) tops.forEach(top => delete top.inner);
let slice = newSlice(z).addTops(tops);
slice.index = indices.indexOf(z);
let offsets = slice.offset = offset ?
@ -191,6 +198,7 @@ async function prepare(widgets, settings, update) {
// filter ignored widgets
widgets = widgets.filter(w => !w.track.ignore && !w.meta.disabled);
// convert arc into line segments
function arc(center, s1, s2, out) {
let a1 = s1.angle;
let a2 = s2.angle;
@ -321,6 +329,7 @@ async function prepare(widgets, settings, update) {
// compute tile width / height
output.forEach(layerout => {
let min = {w:Infinity, h:Infinity}, max = {w:-Infinity, h:-Infinity}, p;
// compute bounding box for each layer
layerout.forEach(out => {
p = out.point;
out.point = p.clone(); // b/c first/last point are often shared
@ -356,7 +365,7 @@ async function prepare(widgets, settings, update) {
p = new kiri.Pack(dw, dh, process.ctOutTileSpacing).fit(c ,!sort);
}
if (pack)
if (true)
for (i = 0; i < c.length; i++) {
m = c[i];
m.fit.x += m.w + p.pad;

View file

@ -78,11 +78,9 @@ WEDM.init = (kiri, api, driver) => {
});
api.event.on("mode.set", (mode) => {
console.log({ dev_mode: mode });
});
api.event.on("view.set", (mode) => {
console.log({ view_mode: mode });
});
// Surface Selection Buttons

View file

@ -639,6 +639,7 @@ const conf = exports({
ctOutStack: false,
ctOutMerged: false,
ctOriginCenter: true,
ctOriginBounds: false,
outputInvertX: false,
outputInvertY: false,
ctOutKnifeDepth: 1,
@ -679,6 +680,7 @@ const conf = exports({
ctOutStack: false,
ctOutMerged: false,
ctOriginCenter: true,
ctOriginBounds: false,
outputInvertX: false,
outputInvertY: false,
ctOutKnifeDepth: 1,
@ -721,6 +723,7 @@ const conf = exports({
ctOutStack: false,
ctOutMerged: false,
ctOriginCenter: true,
ctOriginBounds: false,
outputInvertX: false,
outputInvertY: false,
ctOutKnifeDepth: 1,
@ -754,6 +757,7 @@ const conf = exports({
ctSliceHeight: 1,
ctSliceHeightMin: 0,
ctSliceSingle: true,
ctOmitInner: false,
ctOutTileSpacing: 1,
ctOutPower: 100,
ctOutSpeed: 1000,
@ -762,7 +766,8 @@ const conf = exports({
ctOutLayer: false,
ctOutStack: false,
ctOutMerged: false,
ctOriginCenter: true,
ctOriginCenter: false,
ctOriginBounds: true,
outputInvertX: false,
outputInvertY: false,
ctOutKnifeDepth: 1,

View file

@ -26,11 +26,13 @@ gapp.register("kiri.init", [], (root, exports) => {
STARTMODE = SETUP.sm && SETUP.sm.length === 1 ? SETUP.sm[0] : null,
{ CAM, SLA, FDM, LASER, DRAG, WJET, WEDM } = MODES,
TWOD = [LASER, DRAG, WJET, WEDM],
TWONED= [LASER, DRAG, WJET],
TWONED = [LASER, DRAG, WJET],
THREED = [FDM, CAM, SLA],
GCODE = [FDM, CAM, ...TWOD],
CAM_LZR = [CAM, ...TWOD],
FDM_LZR = [FDM, ...TWOD],
FDM_LZN = [FDM, ...TWONED],
NO_WEDM = [FDM, CAM, SLA, LASER, DRAG, WJET],
FDM_CAM = [FDM, CAM],
proto = location.protocol,
ver = Date.now().toString(36),
@ -1674,10 +1676,10 @@ gapp.register("kiri.init", [], (root, exports) => {
maxHeight: newInput('Z (height)', {title:LANG.dv_bedw_l, convert:toFloat, size:6, units:true, round:2, action:updateDeviceSize}),
resolutionX: newInput(LANG.dv_rezx_s, {title:LANG.dv_rezx_l, convert:toInt, size:6, modes:SLA}),
resolutionY: newInput(LANG.dv_rezy_s, {title:LANG.dv_rezy_l, convert:toInt, size:6, modes:SLA}),
_____: newDiv({ class: "f-col t-body t-inset", addto: $('dev-config'), set:true, modes:GCODE }),
_____: newGroup("firmware", null, {group:"dext", inline:true}),
_____: newDiv({ class: "f-col t-body t-inset", addto: $('dev-config'), set:true, modes:NO_WEDM }),
_____: newGroup("firmware", null, {group:"dext", inline:true, modes:NO_WEDM}),
fwRetract: newBoolean(LANG.dv_retr_s, onBooleanClick, {title:LANG.dv_retr_l, modes:FDM}),
deviceOrigin: newBoolean(LANG.dv_orgc_s, onBooleanClick, {title:LANG.dv_orgc_l, modes:FDM_LZR, show:() => !ui.deviceRound.checked}),
deviceOrigin: newBoolean(LANG.dv_orgc_s, onBooleanClick, {title:LANG.dv_orgc_l, modes:FDM_LZN, show:() => !ui.deviceRound.checked}),
deviceRound: newBoolean(LANG.dv_bedc_s, onBooleanClick, {title:LANG.dv_bedc_l, modes:FDM, trigger:true, show:isNotBelt}),
deviceBelt: newBoolean(LANG.dv_belt_s, onBooleanClick, {title:LANG.dv_belt_l, modes:FDM, trigger:true, show:() => !ui.deviceRound.checked}),
separator: newBlank({class:"pop-sep", modes:FDM, driven:true}),
@ -1942,11 +1944,12 @@ gapp.register("kiri.init", [], (root, exports) => {
_____: newGroup(LANG.sl_menu, $('lzr-slice'), { modes:TWOD, driven, separator }),
ctSliceKerf: newInput(LANG.ls_offs_s, {title:LANG.ls_offs_l, convert:toFloat}),
ctSliceHeight: newInput(LANG.ls_lahi_s, {title:LANG.ls_lahi_l, convert:toFloat, trigger: true, modes:TWONED}),
ctSliceHeightMin: newInput(LANG.ls_lahm_s, {title:LANG.ls_lahm_l, convert:toFloat, modes:TWONED, show:() => ui.ctSliceHeight.value == 0 && !ui.ctSliceSingle.checked }),
separator: newBlank({ class:"set-sep", driven, modes:TWONED }),
ctSliceSingle: newBoolean(LANG.ls_sngl_s, onBooleanClick, {title:LANG.ls_sngl_l, modes:TWONED}),
_____: newGroup('surfaces', $('lzr-surface'), { modes:WEDM, driven, separator }),
ctSliceHeight: newInput(LANG.ls_lahi_s, {title:LANG.ls_lahi_l, convert:toFloat, trigger: true}),
ctSliceHeightMin: newInput(LANG.ls_lahm_s, {title:LANG.ls_lahm_l, convert:toFloat, show:() => ui.ctSliceHeight.value == 0 && !ui.ctSliceSingle.checked }),
separator: newBlank({ class:"set-sep", driven }),
ctSliceSingle: newBoolean(LANG.ls_sngl_s, onBooleanClick, {title:LANG.ls_sngl_l}),
ctOmitInner: newBoolean(LANG.we_omit_s, onBooleanClick, {title:LANG.we_omit_l, modes:WEDM}),
_____: newGroup('surfaces', $('lzr-surface'), { modes:[-1], driven, separator }),
ctSurfaces: newRow([
(ui.faceAdd = newButton(undefined, onButtonClick, {icon:'<i class="fas fa-plus"></i>'})),
(ui.faceDun = newButton(undefined, onButtonClick, {icon:'<i class="fas fa-check"></i>'})),
@ -1956,13 +1959,14 @@ gapp.register("kiri.init", [], (root, exports) => {
ctOutKnifeDepth: newInput(LANG.dk_dpth_s, {title:LANG.dk_dpth_l, convert:toFloat, bound:bound(0.0,5.0) }),
ctOutKnifePasses: newInput(LANG.dk_pass_s, {title:LANG.dk_pass_l, convert:toInt, bound:bound(0,5) }),
ctOutKnifeTip: newInput(LANG.dk_offs_s, {title:LANG.dk_offs_l, convert:toFloat, bound:bound(0.0,10.0) }),
_____: newGroup(LANG.lo_menu, $('lzr-layout'), { modes:TWONED, driven, separator }),
_____: newGroup(LANG.lo_menu, $('lzr-layout'), { modes:TWOD, driven, separator }),
ctOutTileSpacing: newInput(LANG.ou_spac_s, {title:LANG.ou_spac_l, convert:toInt}),
ctOutMerged: newBoolean(LANG.ou_mrgd_s, onBooleanClick, {title:LANG.ou_mrgd_l}),
ctOutMerged: newBoolean(LANG.ou_mrgd_s, onBooleanClick, {title:LANG.ou_mrgd_l, modes:TWONED}),
ctOutGroup: newBoolean(LANG.ou_grpd_s, onBooleanClick, {title:LANG.ou_grpd_l, show:() => !ui.ctOutStack.checked}),
_____: newGroup(LANG.ou_menu, $('lzr-output'), { modes:TWOD, driven, separator }),
ctOutPower: newInput(LANG.ou_powr_s, {title:LANG.ou_powr_l, convert:toInt, bound:bound(1,100)}),
ctOutPower: newInput(LANG.ou_powr_s, {title:LANG.ou_powr_l, convert:toInt, bound:bound(1,100), modes:TWONED}),
ctOutSpeed: newInput(LANG.ou_sped_s, {title:LANG.ou_sped_l, convert:toInt}),
ctAdaptive: newBoolean('adaptive speed', onBooleanClick, {modes:WEDM, title:'controller determines best cutting speed based on material feedback at runtime'}),
separator: newBlank({ class:"set-sep", driven }),
ctOriginBounds: newBoolean(LANG.or_bnds_s, onBooleanClick, {title:LANG.or_bnds_l}),
ctOriginCenter: newBoolean(LANG.or_cntr_s, onBooleanClick, {title:LANG.or_cntr_l}),

View file

@ -41,6 +41,8 @@ function platformUpdateOrigin(update_bounds = true) {
const settings = current();
const { device, process, controller, stock, bounds } = settings;
const { FDM, CAM, SLA, LASER, DRAG, WJET, WEDM } = MODES;
const TWOD = [ LASER, DRAG, WJET, WEDM ];
const MODE = get_mode();
let ruler = controller.showRulers;
@ -62,7 +64,7 @@ function platformUpdateOrigin(update_bounds = true) {
origin.x = (-stock.x / 2) + stockCenter.x;
origin.y = (stock.y / 2) - stockCenter.y;
} else {
if (MODE === MODES.LASER && process.ctOriginBounds) {
if (TWOD.contains(MODE) && process.ctOriginBounds) {
let b = bounds;
origin.x = b.min.x,
origin.y = -b.min.y
@ -74,6 +76,14 @@ function platformUpdateOrigin(update_bounds = true) {
} else if (MODE === MODES.CAM) {
origin.x = stockCenter.x;
origin.y = -stockCenter.y;
} else if (TWOD.contains(MODE) && process.ctOriginBounds ) {
let b = bounds,
mx = bounds.min.x,
my = bounds.min.y,
xd = b.max.x - mx,
yd = b.max.y - my;
origin.x += (mx + xd / 2);
origin.y -= (my + yd / 2);
} else if (isBelt) {
origin.y = device.bedDepth / 2;
}

View file

@ -648,6 +648,10 @@ self.kiri.lang['en-us'] = {
dk_offs_s: "tip offset",
dk_offs_l: ["distance from blade tip","to center of tool","in millimeters"],
// WIRE EDM
we_omit_s: "omit inner",
we_omit_l: "omit inner polygons",
// LASER OUTPUT
ou_spac_s: "spacing",
ou_spac_l: ["distance between layer output","in millimeters"],