get sla working

This commit is contained in:
Stewart Allen 2025-07-05 18:52:53 -04:00
commit 01b81a101d
11 changed files with 142 additions and 157 deletions

2
.gitignore vendored
View file

@ -7,7 +7,7 @@ logs
mod mod
node_modules node_modules
package-lock.json package-lock.json
src/ext/three.js three.js
tmp tmp
.docusaurus .docusaurus
build build

View file

@ -1,11 +1,14 @@
/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */ /** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
export const client = { import { $ } from '../../moto/webui.js';
import { api } from '../../kiri/api.js';
export const SLA = {
init, init,
printDownload printDownload
}; }
function init(kiri, api) { export function init() {
api.event.on("mode.set", (mode) => { api.event.on("mode.set", (mode) => {
if (mode === 'SLA') { if (mode === 'SLA') {
api.ui.func.preview.classList.add('hide'); api.ui.func.preview.classList.add('hide');
@ -15,71 +18,66 @@ function init(kiri, api) {
}); });
} }
function printDownload(output, api, names) { export function printDownload(output, api, names) {
const { file, width, height, layers, volume } = output; const { file, width, height, layers, volume } = output;
const fileroot = names[0] || "print"; const fileroot = names[0] || "print";
const filename = `${fileroot}-${new Date().getTime().toString(36)}`; const filename = `${fileroot}-${new Date().getTime().toString(36)}`;
api.modal.show('xsla'); api.modal.show('xsla');
// api.ajax("/kiri/output-sla.html", html => {
// api.ui.print.innerHTML = html;
let settings = api.conf.get(), let settings = api.conf.get(),
process = settings.process, process = settings.process,
device = settings.device, device = settings.device,
print_sec = (process.slaBaseLayers * process.slaBaseOn) + print_sec = (process.slaBaseLayers * process.slaBaseOn) +
(layers - process.slaBaseLayers) * process.slaLayerOn; (layers - process.slaBaseLayers) * process.slaLayerOn;
// add peel lift/drop times to total print time // add peel lift/drop times to total print time
for (let i=0; i<layers; i++) { for (let i = 0; i < layers; i++) {
let dist = process.slaPeelDist, let dist = process.slaPeelDist,
lift = process.slaPeelLiftRate, lift = process.slaPeelLiftRate,
drop = process.slaPeelDropRate, drop = process.slaPeelDropRate,
off = process.slaLayerOff; off = process.slaLayerOff;
if (i < process.slaBaseLayers) { if (i < process.slaBaseLayers) {
dist = process.slaBasePeelDist; dist = process.slaBasePeelDist;
lift = process.slaBasePeelLiftRate; lift = process.slaBasePeelLiftRate;
off = process.slaBaseOff; off = process.slaBaseOff;
}
print_sec += (dist * lift) / 60;
print_sec += (dist * drop) / 60;
print_sec += off;
} }
print_sec += (dist * lift) / 60;
print_sec += (dist * drop) / 60;
print_sec += off;
}
let print_min = Math.floor(print_sec/60), let print_min = Math.floor(print_sec / 60),
print_hrs = Math.floor(print_min/60), print_hrs = Math.floor(print_min / 60),
download = $('print-sla'); download = $('print-sla');
// add lift/drop time // add lift/drop time
print_sec -= (print_min * 60); print_sec -= (print_min * 60);
print_min -= (print_hrs * 60); print_min -= (print_hrs * 60);
print_sec = Math.round(print_sec).toString().padStart(2,'0'); print_sec = Math.round(print_sec).toString().padStart(2, '0');
print_min = print_min.toString().padStart(2,'0'); print_min = print_min.toString().padStart(2, '0');
print_hrs = print_hrs.toString().padStart(2,'0'); print_hrs = print_hrs.toString().padStart(2, '0');
$('print-filename-sla').value = filename; $('print-filename-sla').value = filename;
$('print-volume').value = (volume/1000).round(2); $('print-volume').value = (volume / 1000).round(2);
$('print-layers').value = layers; $('print-layers').value = layers;
$('print-time').value = `${print_hrs}:${print_min}:${print_sec}`; $('print-time').value = `${print_hrs}:${print_min}:${print_sec}`;
switch (device.deviceName) { switch (device.deviceName) {
case 'Anycubic.Photon': case 'Anycubic.Photon':
download.innerText += " .photon"; download.innerText += " .photon";
download.onclick = () => { saveFile(api, file, ".photon") }; download.onclick = () => { saveFile(api, file, ".photon") };
break; break;
case 'Anycubic.Photon.S': case 'Anycubic.Photon.S':
download.innerText += " .photons"; download.innerText += " .photons";
download.onclick = () => { saveFile(api, file, ".photons") }; download.onclick = () => { saveFile(api, file, ".photons") };
break; break;
case 'Creality.Halot.Sky': case 'Creality.Halot.Sky':
default: default:
download.innerText += " .cxdlp"; download.innerText += " .cxdlp";
download.onclick = () => { saveFile(api, file, ".cxdlp") }; download.onclick = () => { saveFile(api, file, ".cxdlp") };
break; break;
} }
// api.modal.show('print');
// });
} }
function saveFile(api, file, ext) { function saveFile(api, file, ext) {

View file

@ -1,21 +1,30 @@
/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */ /** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
import { newPrint } from '../../kiri/print.js'; import { newPrint } from '../../kiri/print.js';
import { sla_slice } from './slice.js';
import { sla_export } from './export.js';
export const driver = { export const SLA = {
prepare, init,
legacy: false legacy: false,
slice: sla_slice,
prepare: sla_prepare,
export: sla_export,
}; };
if (driver.legacy) { if (SLA.legacy) {
console.log("SLA Driver in Legacy Mode"); console.log("SLA Driver in Legacy Mode");
} }
function init(worker) {
// console.log({ INIT_SLA: worker });
}
// runs in worker. would usually be in src/mode/sla/prepare.js // runs in worker. would usually be in src/mode/sla/prepare.js
// but the SLA driver skips the prepare step because there is no path routing // but the SLA driver skips the prepare step because there is no path routing
async function prepare(widgets, settings, update) { async function sla_prepare(widgets, settings, update) {
self.worker.print = newPrint(settings, widgets); self.kiri_worker.current.print = newPrint(settings, widgets);
if (!driver.wasm) { if (!SLA.wasm) {
fetch('/wasm/kiri-sla.wasm') fetch('/wasm/kiri-sla.wasm')
.then(response => response.arrayBuffer()) .then(response => response.arrayBuffer())
.then(bytes => WebAssembly.instantiate(bytes, { .then(bytes => WebAssembly.instantiate(bytes, {
@ -28,7 +37,7 @@ async function prepare(widgets, settings, update) {
let {module, instance} = results; let {module, instance} = results;
let {exports} = instance; let {exports} = instance;
let heap = new Uint8Array(exports.memory.buffer); let heap = new Uint8Array(exports.memory.buffer);
driver.wasm = { SLA.wasm = {
heap, heap,
memory: exports.memory, memory: exports.memory,
render: exports.render, render: exports.render,
@ -38,5 +47,3 @@ async function prepare(widgets, settings, update) {
} }
update(1); update(1);
} }
export { prepare };

View file

@ -1,14 +1,8 @@
/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */ /** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
import { base } from '../geo/base.js';
import { driver } from '../kiri-mode/sla/driver.js';
import { x_cxdlp } from '../kiri-mode/sla/x_cxdlp.js';
import { x_photon } from '../kiri-mode/sla/x_photon.js';
import { CXDLP } from './x_cxdlp.js';
const { base, kiri } = root import { photon } from './x_photon.js';
const { driver } = kiri; import { SLA } from './driver.js';
const { util } = base;
const { SLA } = driver;
/** /**
* DRIVER CONTRACT - runs in worker * DRIVER CONTRACT - runs in worker
@ -16,7 +10,7 @@ const { SLA } = driver;
* @param {Function} online streaming reply * @param {Function} online streaming reply
* @param {Function} ondone last reply * @param {Function} ondone last reply
*/ */
SLA.export = function(print, online, ondone) { export function sla_export(print, online, ondone) {
let widgets = print.widgets, let widgets = print.widgets,
settings = print.settings, settings = print.settings,
device = settings.device, device = settings.device,
@ -164,9 +158,6 @@ SLA.export = function(print, online, ondone) {
console.log('print.export', Date.now() - mark); console.log('print.export', Date.now() - mark);
}; };
function generateCXDLP(print, conf, progress) { export function generateCXDLP(print, conf, progress) {
console.log({generateCXDLP: print, conf, progress}); console.log({generateCXDLP: print, conf, progress});
} }
export { generateCXDLP, widgets, isPhoton, legacyMode, d, masks, i, render, index, param, exp_func, file, part1, part2, slices, thumb, tdata, x, y, p, r, g, b, v, preview1, pdata, preview2 };

View file

@ -1,20 +1,14 @@
/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */ /** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
import { base } from '../geo/base.js';
import { point } from '../geo/point.js';
import { polygon } from '../geo/polygon.js';
import { polygons } from '../geo/polygons.js';
import { slice } from '../kiri/slice.js';
import { driver } from '../kiri-mode/sla/driver.js';
import { pngjs } from '../ext/pngjs.js';
import { util } from '../../geo/base.js';
import { slicer } from '../../geo/slicer.js';
import { newPolygon } from '../../geo/polygon.js';
import { polygons as POLY } from '../../geo/polygons.js';
import { newSlice, newTop } from '../../kiri/slice.js';
import { doShells, doDiff, projectFlats, projectBridges } from '../fdm/slice.js';
import { PNG } from '../../ext/pngjs.esm.js';
import { SLA } from './driver.js';
const { base, kiri } = root;
const { driver, newSlice, newTop } = kiri;
const { util, newPoint, newPolygon, polygons } = base;
const { SLA } = driver;
const POLY = polygons;
const FDM = driver.FDM.share;
const tracker = util.pwait; const tracker = util.pwait;
let fill_cache; let fill_cache;
@ -26,9 +20,10 @@ let fill_cache;
* @param {Function} onupdate (called with % complete and optional message) * @param {Function} onupdate (called with % complete and optional message)
* @param {Function} ondone (called when complete with an array of Slice objects) * @param {Function} ondone (called when complete with an array of Slice objects)
*/ */
SLA.slice = function(settings, widget, onupdate, ondone) { export function sla_slice(settings, widget, onupdate, ondone) {
let { process, device, controller } = settings, let { minions } = self.kiri_worker,
isConcurrent = controller.threaded && kiri.minions.concurrent, { process, device, controller } = settings,
isConcurrent = controller.threaded && minions.concurrent,
work_total, work_total,
work_remain; work_remain;
@ -66,10 +61,10 @@ SLA.slice = function(settings, widget, onupdate, ondone) {
break; break;
} }
let sws = self.worker.snap.url; let sws = self.kiri_worker.current.snap.url;
let b64 = atob(sws.substring(sws.indexOf(',') + 1)); let b64 = atob(sws.substring(sws.indexOf(',') + 1));
let bin = Uint8Array.from(b64, c => c.charCodeAt(0)); let bin = Uint8Array.from(b64, c => c.charCodeAt(0));
let img = new png.PNG(); let img = new PNG();
img.parse(bin, (err, data) => { img.parse(bin, (err, data) => {
SLA.preview = img; SLA.preview = img;
SLA.previewSmall = samplePNG(img, smallDims.x, smallDims.y); SLA.previewSmall = samplePNG(img, smallDims.x, smallDims.y);
@ -154,14 +149,14 @@ SLA.slice = function(settings, widget, onupdate, ondone) {
work_remain = work_total; work_remain = work_total;
forSlices(slices, 5, (slice,index) => { forSlices(slices, 5, (slice,index) => {
if (process.slaShell) { if (process.slaShell) {
FDM.doShells(slice, 2, 0, process.slaShell); doShells(slice, 2, 0, process.slaShell);
} else { } else {
FDM.doShells(slice, 1, 0); doShells(slice, 1, 0);
} }
}, "shells"); }, "shells");
forSlices(slices, 10, (slice) => { forSlices(slices, 10, (slice) => {
if (slice.synth) return; if (slice.synth) return;
FDM.doDiff(slice, 0.000001, { doDiff(slice, 0.000001, {
sla: true, sla: true,
fakedown: !process.slaOpenBase fakedown: !process.slaOpenBase
}); });
@ -169,8 +164,8 @@ SLA.slice = function(settings, widget, onupdate, ondone) {
if (solidLayers) { if (solidLayers) {
forSlices(slices, 10, (slice) => { forSlices(slices, 10, (slice) => {
if (slice.synth) return; if (slice.synth) return;
FDM.projectFlats(slice, solidLayers); projectFlats(slice, solidLayers);
FDM.projectBridges(slice, solidLayers); projectBridges(slice, solidLayers);
}, "project"); }, "project");
async function doUnionSolid(slice) { async function doUnionSolid(slice) {
if (slice.synth) return; if (slice.synth) return;
@ -179,7 +174,7 @@ SLA.slice = function(settings, widget, onupdate, ondone) {
let trims = slice.solids || []; let trims = slice.solids || [];
traces.appendAll(trims); traces.appendAll(trims);
// slice.unioned = POLY.setZ(POLY.union(traces, undefined, true), slice.z); // slice.unioned = POLY.setZ(POLY.union(traces, undefined, true), slice.z);
slice.unioned = POLY.setZ(await kiri.minions.union(traces), slice.z); slice.unioned = POLY.setZ(await minions.union(traces), slice.z);
} else { } else {
slice.unioned = traces; slice.unioned = traces;
} }
@ -212,7 +207,7 @@ SLA.slice = function(settings, widget, onupdate, ondone) {
let bounds = widget.getBoundingBox(); let bounds = widget.getBoundingBox();
let points = widget.getPoints(); let points = widget.getPoints();
base.slice(points, { slicer.slice(points, {
indices: process.indices || process.xray, indices: process.indices || process.xray,
union: controller.healMesh, union: controller.healMesh,
debug: process.xray, debug: process.xray,
@ -222,7 +217,7 @@ SLA.slice = function(settings, widget, onupdate, ondone) {
zInc: height, zInc: height,
// slicer function (worker local or minion distributed) // slicer function (worker local or minion distributed)
slicer(z, points, opts) { slicer(z, points, opts) {
return (isConcurrent ? kiri.minions.sliceZ : base.sliceZ)(z, points, opts); return (isConcurrent ? minions.sliceZ : slicer.sliceZ)(z, points, opts);
}, },
onupdate(v) { onupdate(v) {
return onupdate(0.0 + v * 0.25); return onupdate(0.0 + v * 0.25);
@ -603,7 +598,7 @@ function fillPolys(slice, settings) {
if (!cached && seq_c !== 1) if (!cached && seq_c !== 1)
for (let x=start_x; x<end_x; x += step_x) { for (let x=start_x; x<end_x; x += step_x) {
fill.push( fill.push(
base.newPolygon().centerRectangle({ newPolygon().centerRectangle({
x: x + step_x/2, x: x + step_x/2,
y: 0, y: 0,
z: slice.z z: slice.z
@ -614,7 +609,7 @@ function fillPolys(slice, settings) {
if (!cached && seq_c !== 3) if (!cached && seq_c !== 3)
for (let y=start_y; y<end_y; y += step_y) { for (let y=start_y; y<end_y; y += step_y) {
fill.push( fill.push(
base.newPolygon().centerRectangle({ newPolygon().centerRectangle({
x: 0, x: 0,
y: y + step_y/2, y: y + step_y/2,
z: slice.z z: slice.z
@ -699,6 +694,3 @@ function samplePNG(png, width, height) {
return {width, height, data:buf, png}; return {width, height, data:buf, png};
} }
export { doupdate, forSlices, onSliceDone, doUnionSolid, doRender, computeSupports, projectSupport, projectPillar, fillPolys, pixAt, averageBlock, samplePNG, POLY, FDM, tracker, smallDims, largeDims, sws, b64, bin, img, height, cap, layers, outer, union, expand, s, slice, i, solidLayers, traces, trims, promises, bounds, points, slices, tops, render, poly, area, ops, mass_per_bear, rem_mass, ord, j, seq, flat, out, rec, num, track, sp, rp, isin, nusize, prec, nextpoint, x, close, p, d, newp, process, seq_i, y, idx, dat, th };

View file

@ -34,7 +34,7 @@ const data_term = 0x0d0a;
// CL-89 3840 x 2400 // CL-89 3840 x 2400
// CL-133 3840 x 2160 // CL-133 3840 x 2160
class CXDLP { export class CXDLP {
constructor() { constructor() {
Object.assign(this, default_values); Object.assign(this, default_values);
} }
@ -447,6 +447,3 @@ if (!self.navigator && self.process && self.process.env) {
} else if (self.navigator) { } else if (self.navigator) {
self.CXDLP = CXDLP; self.CXDLP = CXDLP;
} }
export { read_string, write_string, scaleMovePoly, writePoly, default_values, data_term, read, len, str, meta, layers, i, size, lines, cksum, out, rec, j, d1, d2, d3, y_start, y_end, x_end, color, output, pos, start, b1, b2, b3, b4, b5, ckpos, array, cxdlp, width2, count, area, points, p, inner, bounds, point, slice, polys, wasm, imagelen, writer, poly, image, x, lastv, y, v, fs, args, file, fpos, view };

View file

@ -1,9 +1,6 @@
/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */ /** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
const { base, kiri } = root; import { SLA } from './driver.js';
const { driver } = kiri;
const { util } = base;
const { SLA } = driver;
function generatePhoton(print, conf, progress) { function generatePhoton(print, conf, progress) {
let printset = print.settings, let printset = print.settings,
@ -529,12 +526,9 @@ function polyout(poly, ctx, opt) {
ctx.closePath(); ctx.closePath();
} }
self.photon = { export const photon = {
generatePhoton, generatePhoton,
generatePhotons, generatePhotons,
renderLayer, renderLayer,
renderLayerWasm renderLayerWasm
}; };
export { generatePhoton, generatePhotons, encodeLayers, rleEncode, rleByte, rleDecode, writePhotonImage, renderLayerWasm, scaleMovePoly, writePoly, renderLayer, polyout, printset, d, i, ccl, tcl, converted, count, lineDV, bits, bitsDV, subs, sl, s, view, mask, dv, codedlen, codelen, buflen, filebuf, filedat, printtime, hirez, layerpos, lorez, proppos, proplen, propstart, layers, layerat, sc, l, layer, clo, tlo, j, filePos, index, subindex, data, encoded, maxlen, newColor, bytes, hpos, pos, r, heap, width2, array, area, points, p, inner, bounds, point, slice, polys, wasm, imagelen, writer, poly, image, rlelen, opt, ctx, red };

View file

@ -19,6 +19,7 @@ import { Widget, newWidget } from '../kiri/widget.js';
import { CAM } from '../kiri-mode/cam/driver-be.js'; import { CAM } from '../kiri-mode/cam/driver-be.js';
import { FDM } from '../kiri-mode/fdm/driver-be.js'; import { FDM } from '../kiri-mode/fdm/driver-be.js';
import { LASER } from '../kiri-mode/laser/driver.js'; import { LASER } from '../kiri-mode/laser/driver.js';
import { SLA } from '../kiri-mode/sla/driver.js';
const { time } = util; const { time } = util;
@ -26,7 +27,8 @@ let debug = (self.debug === true),
drivers = { drivers = {
CAM, CAM,
FDM, FDM,
LASER LASER,
SLA
}, },
ccvalue = self.navigator ? self.navigator.hardwareConcurrency || 0 : 0, ccvalue = self.navigator ? self.navigator.hardwareConcurrency || 0 : 0,
concurrent = Math.min(4, self.Worker && ccvalue > 3 ? ccvalue - 1 : 0), concurrent = Math.min(4, self.Worker && ccvalue > 3 ? ccvalue - 1 : 0),
@ -757,5 +759,6 @@ const worker = self.kiri_worker = {
CAM.init(worker); CAM.init(worker);
FDM.init(worker); FDM.init(worker);
LASER.init(worker); LASER.init(worker);
SLA.init(worker);
broker.publish("worker.started", { dispatch, minions: minwork }); broker.publish("worker.started", { dispatch, minions: minwork });

View file

@ -5,6 +5,7 @@ import { api } from './api.js';
import { conf } from './conf.js'; import { conf } from './conf.js';
import { space } from '../moto/space.js'; import { space } from '../moto/space.js';
import { devices as devlist } from '../pack/devices.js'; import { devices as devlist } from '../pack/devices.js';
import { settings, conf as setconf } from './settings.js';
export const device = { export const device = {
clone: cloneDevice, clone: cloneDevice,
@ -22,15 +23,15 @@ export const devices = {
}; };
function isBelt() { function isBelt() {
return api.conf.get().device.bedBelt; return setconf.get().device.bedBelt;
} }
function currentDeviceName() { function currentDeviceName() {
return api.conf.get().filter[api.mode.get()]; return setconf.get().filter[api.mode.get()];
} }
function currentDeviceCode() { function currentDeviceCode() {
return api.conf.get().devices[currentDeviceName()]; return setconf.get().devices[currentDeviceName()];
} }
function getModeDevices() { function getModeDevices() {
@ -38,7 +39,7 @@ function getModeDevices() {
} }
export function showDevices() { export function showDevices() {
api.settings.sync.get().then(_showDevices); settings.sync.get().then(_showDevices);
} }
function _showDevices() { function _showDevices() {
@ -52,7 +53,7 @@ function updateDeviceList() {
function updateDeviceName(newname) { function updateDeviceName(newname) {
let selected = api.device.get(), let selected = api.device.get(),
devs = api.conf.get().devices; devs = setconf.get().devices;
if (newname !== selected) { if (newname !== selected) {
devs[newname] = devs[selected]; devs[newname] = devs[selected];
delete devs[selected]; delete devs[selected];
@ -62,18 +63,18 @@ function updateDeviceName(newname) {
} }
function putLocalDevice(devicename, obj) { function putLocalDevice(devicename, obj) {
api.conf.get().devices[devicename] = obj; setconf.get().devices[devicename] = obj;
api.conf.save(); setconf.save();
} }
function removeLocalDevice(devicename) { function removeLocalDevice(devicename) {
delete api.conf.get().devices[devicename]; delete setconf.get().devices[devicename];
api.conf.save(); setconf.save();
api.settings.sync.put(); settings.sync.put();
} }
function isLocalDevice(devicename) { function isLocalDevice(devicename) {
return api.conf.get().devices[devicename] ? true : false; return setconf.get().devices[devicename] ? true : false;
} }
function getSelectedDevice() { function getSelectedDevice() {
@ -82,9 +83,9 @@ function getSelectedDevice() {
function selectDevice(devicename) { function selectDevice(devicename) {
if (isLocalDevice(devicename)) { if (isLocalDevice(devicename)) {
setDeviceCode(api.conf.get().devices[devicename], devicename); setDeviceCode(setconf.get().devices[devicename], devicename);
} else { } else {
let code = devices[api.mode.get_lower()][devicename]; let code = devlist[api.mode.get_lower()][devicename];
if (code) { if (code) {
setDeviceCode(code, devicename); setDeviceCode(code, devicename);
} }
@ -94,7 +95,7 @@ function selectDevice(devicename) {
// only for local filters // only for local filters
function cloneDevice() { function cloneDevice() {
let name = `${getSelectedDevice().replace(/\./g,' ')}`; let name = `${getSelectedDevice().replace(/\./g,' ')}`;
let code = api.clone(api.conf.get().device); let code = api.clone(setconf.get().device);
code.mode = api.mode.get(); code.mode = api.mode.get();
if (name.toLowerCase().indexOf('my ') >= 0) { if (name.toLowerCase().indexOf('my ') >= 0) {
name = `${name} copy`; name = `${name} copy`;
@ -103,11 +104,11 @@ function cloneDevice() {
} }
putLocalDevice(name, code); putLocalDevice(name, code);
setDeviceCode(code, name); setDeviceCode(code, name);
api.settings.sync.put(); settings.sync.put();
} }
function updateLaserState() { function updateLaserState() {
const dev = api.conf.get().device; const dev = setconf.get().device;
$('laser-on').style.display = dev.useLaser ? 'flex' : 'none'; $('laser-on').style.display = dev.useLaser ? 'flex' : 'none';
$('laser-off').style.display = dev.useLaser ? 'flex' : 'none'; $('laser-off').style.display = dev.useLaser ? 'flex' : 'none';
} }
@ -119,7 +120,7 @@ function setDeviceCode(code, devicename) {
let mode = api.mode.get(), let mode = api.mode.get(),
lmode = mode.toLowerCase(), lmode = mode.toLowerCase(),
current = api.conf.get(), current = setconf.get(),
local = isLocalDevice(devicename), local = isLocalDevice(devicename),
dev = current.device = conf.device_from_code(code,mode), dev = current.device = conf.device_from_code(code,mode),
dproc = current.devproc[devicename], // last process name for this device dproc = current.devproc[devicename], // last process name for this device
@ -228,7 +229,7 @@ function setDeviceCode(code, devicename) {
} }
ui.deviceAdd.disabled = dev.noclone; ui.deviceAdd.disabled = dev.noclone;
api.conf.update_fields(); setconf.update_fields();
space.platform.setBelt(isBelt()); space.platform.setBelt(isBelt());
platform.update_size(); platform.update_size();
platform.update_origin(); platform.update_origin();
@ -242,12 +243,12 @@ function setDeviceCode(code, devicename) {
if (dproc) { if (dproc) {
// restore last process associated with this device // restore last process associated with this device
api.conf.load(null, dproc); setconf.load(null, dproc);
} else { } else {
api.conf.update(); setconf.update();
} }
api.conf.save(); setconf.save();
if (isBelt()) { if (isBelt()) {
// space.view.setHome(dev.bedBelt ? Math.PI/2 : 0, Math.PI / 2.5); // space.view.setHome(dev.bedBelt ? Math.PI/2 : 0, Math.PI / 2.5);
@ -276,7 +277,7 @@ function setDeviceCode(code, devicename) {
function renderDevices(devices) { function renderDevices(devices) {
let selected = api.device.get() || devices[0], let selected = api.device.get() || devices[0],
features = api.feature, features = api.feature,
devs = api.conf.get().devices, devs = setconf.get().devices,
dfilter = typeof(features.device_filter) === 'function' ? features.device_filter : undefined; dfilter = typeof(features.device_filter) === 'function' ? features.device_filter : undefined;
for (let local in devs) { for (let local in devs) {
@ -300,8 +301,8 @@ function renderDevices(devices) {
ui.deviceSave.onclick = function() { ui.deviceSave.onclick = function() {
event.emit('device.save'); event.emit('device.save');
api.function.clear(); api.function.clear();
api.conf.save(); setconf.save();
api.settings.sync.put(); settings.sync.put();
showDevices(); showDevices();
api.modal.hide(); api.modal.hide();
}; };
@ -320,8 +321,8 @@ function renderDevices(devices) {
api.uc.prompt(`Rename "${selected}`, selected).then(newname => { api.uc.prompt(`Rename "${selected}`, selected).then(newname => {
if (newname) { if (newname) {
updateDeviceName(newname); updateDeviceName(newname);
api.conf.save(); setconf.save();
api.settings.sync.put(); settings.sync.put();
showDevices(); showDevices();
} else { } else {
showDevices(); showDevices();
@ -333,7 +334,7 @@ function renderDevices(devices) {
version: kiri.version, version: kiri.version,
device: selected, device: selected,
process: api.process.code(), process: api.process.code(),
profiles: event.altKey ? api.settings.prof() : undefined, profiles: event.altKey ? settings.prof() : undefined,
code: devs[selected], code: devs[selected],
time: Date.now() time: Date.now()
}; };

View file

@ -7,7 +7,7 @@ import { local } from '../data/local.js';
import { util } from '../geo/base.js'; import { util } from '../geo/base.js';
import { MODES } from './consts.js'; import { MODES } from './consts.js';
import { LASER as laser_driver } from '../kiri-mode/laser/driver.js'; import { LASER as laser_driver } from '../kiri-mode/laser/driver.js';
import { client as sla_client } from '../kiri-mode/sla/client.js'; import { SLA as sla_client } from '../kiri-mode/sla/client.js';
let printSeq = parseInt(local['kiri-print-seq'] || local['print-seq'] || "0") + 1; let printSeq = parseInt(local['kiri-print-seq'] || local['print-seq'] || "0") + 1;

View file

@ -12,6 +12,7 @@ import { settings as set_ctrl } from './settings.js';
import { init as initCAM } from '../kiri-mode/cam/client.js'; import { init as initCAM } from '../kiri-mode/cam/client.js';
import { init as initFDM } from '../kiri-mode/fdm/client.js'; import { init as initFDM } from '../kiri-mode/fdm/client.js';
import { init as initLaser } from '../kiri-mode/laser/client.js'; import { init as initLaser } from '../kiri-mode/laser/client.js';
import { init as initSLA } from '../kiri-mode/sla/client.js';
let { CAM, SLA, FDM, LASER, DRAG, WJET, WEDM } = MODES, let { CAM, SLA, FDM, LASER, DRAG, WJET, WEDM } = MODES,
{ consts, client, catalog, platform, selection } = api, { consts, client, catalog, platform, selection } = api,
@ -402,7 +403,7 @@ function keyHandler(evt) {
case cca('p'): // prepare case cca('p'): // prepare
if (api.mode.get() !== 'SLA') { if (api.mode.get() !== 'SLA') {
// hidden in SLA mode // hidden in SLA mode
api.function.print(); api.function.prepare();
} }
break; break;
case cca('X'): // export case cca('X'): // export
@ -1366,6 +1367,7 @@ function init_one() {
initFDM(); initFDM();
initCAM(); initCAM();
initLaser(); initLaser();
initSLA();
// override old style settings two-button menu // override old style settings two-button menu
ui.settingsSave.onclick = () => { ui.settingsSave.onclick = () => {