toggle ops adders based on device state

This commit is contained in:
Stewart Allen 2022-10-18 10:36:41 -04:00
commit cd42021e42
2 changed files with 26 additions and 0 deletions

View file

@ -190,6 +190,8 @@ CAM.init = function(kiri, api) {
let settings = API.conf.get();
let { process, device } = settings;
switch (ev.target.innerText) {
case "laser on": return func.opAddLaserOn();
case "laser off": return func.opAddLaserOff();
case "gcode": return func.opAddGCode();
case "level": return func.opAddLevel();
case "rough": return func.opAddRough();
@ -217,6 +219,14 @@ CAM.init = function(kiri, api) {
}
};
func.opAddLaserOn = () => {
func.opAdd(popOp['laser on'].new());
};
func.opAddLaserOff = () => {
func.opAdd(popOp['laser off'].new());
};
func.opAddGCode = () => {
func.opAdd(popOp.gcode.new());
};
@ -1249,6 +1259,14 @@ CAM.init = function(kiri, api) {
UC.newButton(LANG.cf_menu, func.opFlip)
], {class:"ext-buttons f-row"})
};
createPopOp('laser on', {
}).inputs = {
};
createPopOp('laser off', {
}).inputs = {
};
};
function createPopOp(type, map) {

View file

@ -269,6 +269,7 @@ gapp.register("kiri.init", [], (root, exports) => {
api.conf.update();
DOC.activeElement.blur();
api.event.emit("boolean.click");
updateLaserState();
}
function onButtonClick(ev) {
@ -744,6 +745,12 @@ gapp.register("kiri.init", [], (root, exports) => {
setDeviceCode(code, name);
}
function updateLaserState() {
const dev = settings().device;
$('laser-on').style.display = dev.useLaser ? 'flex' : 'none';
$('laser-off').style.display = dev.useLaser ? 'flex' : 'none';
}
function setDeviceCode(code, devicename) {
api.event.emit('device.select', {devicename, code});
try {
@ -883,6 +890,7 @@ gapp.register("kiri.init", [], (root, exports) => {
platform.update_size();
platform.update_origin();
platform.update();
updateLaserState();
// store current device name for this mode
current.filter[mode] = devicename;