add laser on/off gcode. cleanup help, export dialogs
This commit is contained in:
parent
8148eeee7e
commit
eb381f3417
13 changed files with 149 additions and 93 deletions
|
|
@ -387,7 +387,14 @@ var gs_base = exports;
|
|||
offsetPrecision : offsetPrecision,
|
||||
intersectRayLine : intersectRayLine,
|
||||
intersect : intersect,
|
||||
determinant : determinant
|
||||
determinant : determinant,
|
||||
comma: (v) => {
|
||||
let [lt,rt] = v.toString().split('.');
|
||||
lt = lt.toString().split('').reverse().map((v,i,a) => {
|
||||
return (i < a.length - 1 && i % 3 === 2) ? `,${v}` : v
|
||||
}).reverse().join('');
|
||||
return rt ? `${lt}.${rt}` : lt;
|
||||
}
|
||||
};
|
||||
|
||||
})();
|
||||
|
|
|
|||
|
|
@ -193,6 +193,12 @@ var gs_kiri_conf = exports;
|
|||
d:{
|
||||
bedWidth: 1,
|
||||
bedDepth: 1,
|
||||
gcodePre: 1,
|
||||
gcodePost: 1,
|
||||
gcodeFExt: 1,
|
||||
gcodeSpace: 1,
|
||||
gcodeLaserOn: 1,
|
||||
gcodeLaserOff: 1
|
||||
},
|
||||
// fields permitted in Laser:Process
|
||||
p:{
|
||||
|
|
@ -289,12 +295,14 @@ var gs_kiri_conf = exports;
|
|||
gcodeFan: "", // FDM fan command
|
||||
gcodeTrack: "", // FDM progress command
|
||||
gcodeLayer: "", // FDM layer output
|
||||
gcodeFExt: "", // CAM file extension
|
||||
gcodeSpace: "", // CAM token spacing
|
||||
gcodeStrip: true, // CAM strip comments
|
||||
gcodeDwell: ["G4 P{time}"], // CAM dwell script
|
||||
gcodeChange: ["M6 T{tool}"], // CAM tool change script
|
||||
gcodeSpindle: ["M3 S{speed}"], // CAM spindle speed
|
||||
gcodeFExt: "", // CAM file extension
|
||||
gcodeSpace: "", // CAM token spacing
|
||||
gcodeStrip: true // CAM strip comments
|
||||
gcodeLaserOn: ["M106 S{power}"],// LASER turn on
|
||||
gcodeLaserOff: ["M107"] // LASER turn off
|
||||
},
|
||||
// FDM/CAM/Laser
|
||||
process:{
|
||||
|
|
|
|||
|
|
@ -290,37 +290,52 @@ let gs_kiri_laser = exports;
|
|||
*
|
||||
*/
|
||||
function exportGCode(print) {
|
||||
let lines = [], dx = 0, dy = 0, feedrate, laser_on;
|
||||
let lines = [], dx = 0, dy = 0, feedrate;
|
||||
let dev = print.settings.device;
|
||||
let space = dev.gcodeSpace;
|
||||
let power = 255;
|
||||
let laser_on = dev.gcodeLaserOn || [];
|
||||
let laser_off = dev.gcodeLaserOff || [];
|
||||
|
||||
exportElements(
|
||||
print,
|
||||
function(min, max, power, speed) {
|
||||
let width = (max.x - min.x),
|
||||
height = (max.y - min.y);
|
||||
|
||||
dx = min.x;
|
||||
dy = min.y;
|
||||
feedrate = " F" + speed,
|
||||
laser_on = "M106 S" + UTIL.round(256 * (power / 100), 3);
|
||||
// pre
|
||||
feedrate = `${space}F${speed}`;
|
||||
power = (256 * (power / 100)).toFixed(3);
|
||||
|
||||
(dev.gcodePre || []).forEach(line => {
|
||||
lines.push(line);
|
||||
});
|
||||
},
|
||||
function(poly, color) {
|
||||
poly.forEach(function(point, index) {
|
||||
if (index === 0) {
|
||||
lines.push("G0 " + point);
|
||||
lines.push(`G0${space}${point}`);
|
||||
} else if (index === 1) {
|
||||
lines.push(laser_on);
|
||||
lines.push("G1 " + point + feedrate);
|
||||
laser_on.forEach(line => {
|
||||
lines.push(line.replace('{power}', power));
|
||||
});
|
||||
lines.push(`G1${space}${point}${feedrate}`);
|
||||
} else {
|
||||
lines.push("G1 " + point);
|
||||
lines.push(`G1${space}${point}`);
|
||||
}
|
||||
});
|
||||
lines.push("M107");
|
||||
laser_off.forEach(line => {
|
||||
lines.push(line);
|
||||
});
|
||||
},
|
||||
function() {
|
||||
// post
|
||||
(dev.gcodePost || []).forEach(line => {
|
||||
lines.push(line);
|
||||
});
|
||||
},
|
||||
function(point) {
|
||||
return "X" + UTIL.round(point.x - dx, 3) + " Y" + UTIL.round(point.y - dy, 3);
|
||||
return `X${(point.x - dx, 3).toFixed(3)}${space}Y${(point.y - dy, 3).toFixed(3)}`;
|
||||
}
|
||||
);
|
||||
|
||||
|
|
@ -333,6 +348,7 @@ let gs_kiri_laser = exports;
|
|||
function exportSVG(print, cut_color) {
|
||||
let lines = [], dx = 0, dy = 0, my;
|
||||
let colors = [
|
||||
"black",
|
||||
"purple",
|
||||
"blue",
|
||||
"red",
|
||||
|
|
@ -340,8 +356,7 @@ let gs_kiri_laser = exports;
|
|||
"yellow",
|
||||
"green",
|
||||
"brown",
|
||||
"gray",
|
||||
"black"
|
||||
"gray"
|
||||
];
|
||||
|
||||
exportElements(
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ let gs_kiri_export = exports;
|
|||
if (self.kiri.export) return;
|
||||
|
||||
let KIRI = self.kiri,
|
||||
BASE = self.base,
|
||||
UTIL = BASE.util,
|
||||
API = KIRI.api,
|
||||
SDB = API.sdb,
|
||||
UI = API.ui,
|
||||
|
|
@ -76,7 +78,7 @@ let gs_kiri_export = exports;
|
|||
currentPrint.output.forEach(layer => { segments += layer.length });
|
||||
UI.print.innerHTML = html;
|
||||
$('print-filename').value = filename;
|
||||
$('print-lines').value = segments;
|
||||
$('print-lines').value = UTIL.comma(segments);
|
||||
$('print-close').onclick = API.modal.hide;
|
||||
$('print-svg').onclick = download_svg;
|
||||
$('print-dxf').onclick = download_dxf;
|
||||
|
|
@ -353,9 +355,18 @@ let gs_kiri_export = exports;
|
|||
|
||||
function calcWeight() {
|
||||
try {
|
||||
let density = $('print-density');
|
||||
$('print-weight').value = (
|
||||
UTIL.round((Math.PI * UTIL.sqr(currentPrint.settings.device.filamentSize/2)) * currentPrint.distance * 1.25 / 1000, 2)
|
||||
);
|
||||
(Math.PI * UTIL.sqr(
|
||||
currentPrint.settings.device.filamentSize / 2
|
||||
)) *
|
||||
currentPrint.distance *
|
||||
(parseFloat(density.value) || 1.25) /
|
||||
1000
|
||||
).toFixed(2);
|
||||
density.onkeyup = (ev) => {
|
||||
if (ev.key === 'Enter') calcWeight();
|
||||
};
|
||||
} catch (e) { }
|
||||
}
|
||||
|
||||
|
|
@ -381,7 +392,7 @@ let gs_kiri_export = exports;
|
|||
$('print-filament-row').style.display = MODE === MODES.FDM ? '' : 'none';
|
||||
$('mill-info').style.display = MODE === MODES.CAM ? '' : 'none';
|
||||
$('print-filename').value = filename;
|
||||
$('print-filesize').value = currentPrint.bytes;
|
||||
$('print-filesize').value = UTIL.comma(currentPrint.bytes);
|
||||
$('print-filament').value = Math.round(currentPrint.distance);
|
||||
$('grid-host').onkeyup = gridhost_probe;
|
||||
$('grid-apik').onkeyup = gridhost_probe;
|
||||
|
|
|
|||
|
|
@ -118,14 +118,16 @@ var gs_kiri_init = exports;
|
|||
setDeviceTrack: UC.newInput(LANG.dev_prog, {title:LANG.dev_prog_desc, modes:FDM, size:17}),
|
||||
setDeviceLayer: UC.newText(LANG.dev_layer, {title:LANG.dev_layer_desc, modes:FDM, size:14, height: 2}),
|
||||
setDeviceToken: UC.newBoolean(LANG.dev_token, null, {title:LANG.dev_token_desc, modes:CAM_LASER}),
|
||||
setDeviceStrip: UC.newBoolean(LANG.dev_strip, null, {title:LANG.dev_strip_desc, modes:CAM_LASER}),
|
||||
setDeviceStrip: UC.newBoolean(LANG.dev_strip, null, {title:LANG.dev_strip_desc, modes:CAM}),
|
||||
setDeviceFExt: UC.newInput(LANG.dev_fext, {title:LANG.dev_fext_desc, modes:CAM_LASER, size:7}),
|
||||
setDeviceDwell: UC.newText(LANG.dev_dwell, {title:LANG.dev_dwell_desc, modes:CAM, size:14, height:2}),
|
||||
setDeviceChange: UC.newText(LANG.dev_tool, {title:LANG.dev_tool_desc, modes:CAM, size:14, height:2}),
|
||||
setDeviceSpindle: UC.newText(LANG.dev_speed, {title:LANG.dev_speed_desc, modes:CAM, size:14, height:2}),
|
||||
setDevicePause: UC.newText(LANG.dev_pause, {title:LANG.dev_pause_desc, modes:FDM, size:14, height:3}),
|
||||
setDevicePre: UC.newText(LANG.dev_head, {title:LANG.dev_head_desc, xmodes:FDM_CAM, size:14, height:3}),
|
||||
setDevicePost: UC.newText(LANG.dev_foot, {title:LANG.dev_foot_desc, xmodes:FDM_CAM, size:14, height:3}),
|
||||
setDeviceLaserOn: UC.newText(LANG.dev_lzon, {title:LANG.dev_lzon_desc, modes:LASER, size:14, height:3}),
|
||||
setDeviceLaserOff: UC.newText(LANG.dev_lzof, {title:LANG.dev_lzof_desc, modes:LASER, size:14, height:3}),
|
||||
setDevicePre: UC.newText(LANG.dev_head, {title:LANG.dev_head_desc, modes:ALL, size:14, height:3}),
|
||||
setDevicePost: UC.newText(LANG.dev_foot, {title:LANG.dev_foot_desc, modes:ALL, size:14, height:3}),
|
||||
|
||||
tools: $('tools'),
|
||||
toolsSave: $('tools-save'),
|
||||
|
|
@ -879,6 +881,8 @@ var gs_kiri_init = exports;
|
|||
post: UI.setDevicePost.value.split('\n'),
|
||||
pause: UI.setDevicePause.value.split('\n'),
|
||||
dwell: UI.setDeviceDwell.value.split('\n'),
|
||||
'laser-on': UI.setDeviceLaserOn.value.split('\n'),
|
||||
'laser-off': UI.setDeviceLaserOff.value.split('\n'),
|
||||
'tool-change': UI.setDeviceChange.value.split('\n'),
|
||||
'file-ext': UI.setDeviceFExt.value,
|
||||
'token-space': UI.setDeviceToken.checked ? ' ' : '',
|
||||
|
|
@ -927,7 +931,9 @@ var gs_kiri_init = exports;
|
|||
gcodeChange: valueOf(code['tool-change'], []),
|
||||
gcodeFExt: valueOf(code['file-ext'], 'gcode'),
|
||||
gcodeSpace: valueOf(code['token-space'], ''),
|
||||
gcodeStrip: valueOf(code['strip-comments'], false)
|
||||
gcodeStrip: valueOf(code['strip-comments'], false),
|
||||
gcodeLaserOn: valueOf(code['laser-on'], []),
|
||||
gcodeLaserOff: valueOf(code['laser-off'], [])
|
||||
};
|
||||
|
||||
let dev = current.device,
|
||||
|
|
@ -961,6 +967,9 @@ var gs_kiri_init = exports;
|
|||
UI.setDeviceFExt.value = dev.gcodeFExt;
|
||||
UI.setDeviceToken.checked = dev.gcodeSpace ? true : false;
|
||||
UI.setDeviceStrip.checked = dev.gcodeStrip;
|
||||
// LASER
|
||||
UI.setDeviceLaserOn.value = dev.gcodeLaserOn.join('\n');
|
||||
UI.setDeviceLaserOff.value = dev.gcodeLaserOff.join('\n');
|
||||
|
||||
// disable editing for non-local devices
|
||||
[
|
||||
|
|
@ -986,7 +995,9 @@ var gs_kiri_init = exports;
|
|||
UI.setDeviceChange,
|
||||
UI.setDeviceFExt,
|
||||
UI.setDeviceToken,
|
||||
UI.setDeviceStrip
|
||||
UI.setDeviceStrip,
|
||||
UI.setDeviceLaserOn,
|
||||
UI.setDeviceLaserOff
|
||||
].forEach(function(e) {
|
||||
e.disabled = !local;
|
||||
});
|
||||
|
|
@ -1002,7 +1013,7 @@ var gs_kiri_init = exports;
|
|||
e.parentNode.style.display = dev.spindleMax >= 0 ? 'none' : 'block';
|
||||
});
|
||||
|
||||
UI.deviceSave.disabled =
|
||||
UI.deviceSave.disabled = !local;
|
||||
UI.deviceDelete.disabled = !local;
|
||||
|
||||
API.view.update_fields();
|
||||
|
|
@ -1076,18 +1087,26 @@ var gs_kiri_init = exports;
|
|||
|
||||
UI.deviceSelect.innerHTML = '';
|
||||
let incr = 0;
|
||||
let faves = API.show.favorites();
|
||||
let found = false;
|
||||
let first = devices[0];
|
||||
// run through the list up to twice forcing faves off
|
||||
// the second time if incr === 0 (no devices shown)
|
||||
// if incr > 0, second loop is avoided
|
||||
for (let rep=0; rep<2; rep++)
|
||||
if (incr === 0)
|
||||
devices.forEach(function(device, index) {
|
||||
let opt = DOC.createElement('option'),
|
||||
fav = isFavoriteDevice(device),
|
||||
// force faves off for second try
|
||||
if (rep === 1) faves = false;
|
||||
let fav = isFavoriteDevice(device),
|
||||
loc = isLocalDevice(device);
|
||||
if (API.show.favorites() && !(fav || loc)) {
|
||||
if (faves && !(fav || loc)) {
|
||||
return;
|
||||
}
|
||||
if (incr === 0) {
|
||||
first = device;
|
||||
}
|
||||
let opt = DOC.createElement('option');
|
||||
opt.appendChild(DOC.createTextNode(device));
|
||||
opt.onclick = function() {
|
||||
selectDevice(device);
|
||||
|
|
@ -1328,7 +1347,7 @@ var gs_kiri_init = exports;
|
|||
|
||||
function showDevices() {
|
||||
if (deviceLock) return;
|
||||
|
||||
API.modal.hide();
|
||||
API.ajax("/api/filters-"+API.mode.get_lower(), function(flvalue) {
|
||||
if (!flvalue) return;
|
||||
renderDevices(js2o(flvalue));
|
||||
|
|
@ -1647,6 +1666,8 @@ var gs_kiri_init = exports;
|
|||
|
||||
API.space.restore(ondone) || checkSeed(ondone) || ondone();
|
||||
|
||||
// extend API
|
||||
API.show.devices = showDevices;
|
||||
};
|
||||
|
||||
})();
|
||||
|
|
|
|||
|
|
@ -90,7 +90,11 @@ var gs_kiri_lang = exports;
|
|||
dev_head: "header",
|
||||
dev_head_desc: "gcode header script",
|
||||
dev_foot: "footer",
|
||||
dev_foot_desc: "gcode footer script"
|
||||
dev_foot_desc: "gcode footer script",
|
||||
dev_lzon: "laser on",
|
||||
dev_lzon_desc: "gcode laser on script",
|
||||
dev_lzof: "laser off",
|
||||
dev_lzof_desc: "gcode laser off script"
|
||||
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue