fix file export names for laser, sla. add device max power for lasers

This commit is contained in:
Stewart Allen 2024-12-04 13:56:35 -05:00
commit cbfa05e1da
9 changed files with 33 additions and 22 deletions

View file

@ -166,6 +166,10 @@ function round(v, zeros) {
return Math.round(v * pow) / pow;
}
function clamp(val, low, hi) {
return Math.max(low, Math.min(hi, val));
}
/**
* used by {@link Polygon.trace} and {@link Polygon.intersect}
*/
@ -590,6 +594,7 @@ base.util = {
sqr,
lerp,
time,
clamp,
comma,
round,
area2,

View file

@ -559,7 +559,8 @@ function exportGCode(settings, data) {
let dev = settings.device;
let proc = settings.process;
let space = dev.gcodeSpace ? ' ' : '';
let power = 255;
let max_power = dev.laserMaxPower || 255;
let power = max_power;
let cut_on = dev.gcodeLaserOn || dev.gcodeWaterOn || dev.gcodeKnifeDn || [];
let cut_off = dev.gcodeLaserOff || dev.gcodeWaterOff || dev.gcodeKnifeUp || [];
let knifeOn = proc.knifeOn;
@ -569,14 +570,14 @@ function exportGCode(settings, data) {
exportElements(
settings,
data,
function(min, max, power, speed) {
function(min, max, pct, speed) {
let width = (max.x - min.x),
height = (max.y - min.y);
dx = min.x;
dy = min.y;
feedrate = `${space}F${speed}`;
power = (256 * (power / 100)).toFixed(3);
power = (max_power * (pct / 100)).toFixed(3);
(dev.gcodePre || []).forEach(line => {
lines.push(line);

View file

@ -68,7 +68,7 @@ function init(kiri, api) {
print_min = print_min.toString().padStart(2,'0');
print_hrs = print_hrs.toString().padStart(2,'0');
$('print-filename').value = filename;
$('print-filename-sla').value = filename;
$('print-volume').value = (volume/1000).round(2);
$('print-layers').value = layers;
$('print-time').value = `${print_hrs}:${print_min}:${print_sec}`;
@ -94,7 +94,7 @@ function init(kiri, api) {
}
function saveFile(api, file, ext) {
api.util.download(file, $('print-filename').value + ext);
api.util.download(file, $('print-filename-sla').value + ext);
api.modal.hide();
}

View file

@ -593,6 +593,7 @@ const conf = exports({
bedDepth: 200,
bedHeight: 2.5,
maxHeight: 100,
laserMaxPower: 255,
gcodePre: [],
gcodePost: [],
gcodeFExt: "",

View file

@ -209,6 +209,7 @@ gapp.register("kiri.devices", (root, exports) => {
ui.gcodeStrip,
ui.gcodeLaserOn,
ui.gcodeLaserOff,
ui.laserMaxPower,
ui.extPrev,
ui.extNext,
ui.extAdd,

View file

@ -109,36 +109,36 @@ function exportLaserDialog(data, names) {
function download_svg() {
api.util.download(
driver.exportSVG(settings, data),
$('print-filename').value + ".svg"
$('print-filename-laser').value + ".svg"
);
}
function download_dxf() {
api.util.download(
driver.exportDXF(settings, data),
$('print-filename').value + ".dxf"
$('print-filename-laser').value + ".dxf"
);
}
function download_gcode() {
api.util.download(
driver.exportGCode(settings, data),
$('print-filename').value + ".gcode"
$('print-filename-laser').value + ".gcode"
);
}
// api.ajax("/kiri/output-laser.html", function(html) {
api.modal.show('xlaser');
let segments = 0;
data.forEach(layer => { segments += layer.length });
// ui.print.innerHTML = html;
$('print-filename').value = filename;
$('print-lines').value = util.comma(segments);
$('print-svg').onclick = download_svg;
$('print-dxf').onclick = download_dxf;
$('print-lg').onclick = download_gcode;
// api.modal.show('print');
// });
api.modal.show('xlaser');
let segments = 0;
data.forEach(layer => { segments += layer.length });
$('print-filename-laser').value = filename;
$('print-lines').value = util.comma(segments);
$('print-svg').onclick = download_svg;
$('print-dxf').onclick = download_dxf;
$('print-lg').onclick = download_gcode;
console.log('laser export', { fileroot, filename });
}
function bindField(field, varname) {

View file

@ -996,6 +996,7 @@ gapp.register("kiri.init", (root, exports) => {
_____: newGroup(LANG.dv_gr_out, null, {group:"dgco", inline}),
gcodeStrip: newBoolean(LANG.dv_strc_s, onBooleanClick, {title:LANG.dv_strc_l, modes:CAM}),
gcodeSpace: newBoolean(LANG.dv_tksp_s, onBooleanClick, {title:LANG.dv_tksp_l, modes:CAM_LZR}),
laserMaxPower: newInput(LANG.ou_maxp_s, {title:LANG.ou_maxp_l, modes:LASER, size:7, text:true}),
useLaser: newBoolean(LANG.dv_lazr_s, onBooleanClick, {title:LANG.dv_lazr_l, modes:CAM}),
gcodeFExt: newInput(LANG.dv_fext_s, {title:LANG.dv_fext_l, modes:CAM_LZR, size:7, text:true}),
gcodeEd: newGroup(LANG.dv_gr_gco, $('dg'), {group:"dgcp", inline, modes:GCODE}),

View file

@ -643,7 +643,7 @@
<div id="mod-x-sla" class="mod-print mdialog f-col">
<div class="header"><label>export</label></div>
<div id="print-info" class="f-col box">
<div><label>file name</label><input id="print-filename" size="20" spellcheck="false" /></div>
<div><label>file name</label><input id="print-filename-sla" size="20" spellcheck="false" /></div>
<div><label>resin used ML</label><input id="print-volume" size="10" spellcheck="false" /></div>
<div><label>layers</label><input id="print-layers" size="10" spellcheck="false" /></div>
<div><label>print time</label><input id="print-time" size="10" spellcheck="false" /></div>
@ -656,7 +656,7 @@
<div id="mod-x-laser" class="mod-print mdialog f-col">
<div class="header"><label>export</label></div>
<div id="print-info" class="f-col box">
<div><label>file name</label><input id="print-filename" size="20" spellcheck="false" /></div>
<div><label>file name</label><input id="print-filename-laser" size="20" spellcheck="false" /></div>
<div><label>segments</label><input id="print-lines" size="12" disabled="true" /></div>
</div>
<div class="header"><label>download</label></div>

View file

@ -694,6 +694,8 @@ self.kiri.lang['en-us'] = {
ou_drkn_l: ["enable drag knife","output in gcode","cut radii are added","to corners with","cut down passes"],
ou_stak_s: "3D stack",
ou_stak_l: ["output is a 3D stack of 2D paths rather than packing layers flat in 2D"],
ou_maxp_s: "max power",
ou_maxp_l: ["max power value in gcode. power % from settings will scale from 0 to this value"],
// OUTPUT FDM
ou_nozl_s: "nozzle temp",