Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into MI-1388-Jog-UI-Valu…
Browse files Browse the repository at this point in the history
…es-Conversion-Issue
  • Loading branch information
kglovern committed Mar 11, 2024
2 parents 5bd0fb3 + c80d208 commit b69a0fc
Show file tree
Hide file tree
Showing 12 changed files with 116 additions and 90 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ jobs:
PACKAGE_VERSION=`node -e "console.log(require('./src/package.json').version)"`
mkdir -p releases/macos
ls -al output
cp -af "output/${PACKAGE_NAME}-${PACKAGE_VERSION}-x64.dmg" "releases/macos/gSender-${PACKAGE_VERSION}-Mac-Intel-64Bit.dmg"
cp -af "output/${PACKAGE_NAME}-${PACKAGE_VERSION}-x64.dmg" "releases/macos/gSender-${PACKAGE_VERSION}-Mac-Universal.dmg"
ls -al output releases/macos
if [[ "$GITHUB_REF_TYPE" == "branch" && "$GITHUB_REF_NAME" == "master" ]]; then
yarn github-release delete \
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gSender",
"version": "1.4.4-RC1",
"version": "1.4.4-RC2",
"description": "Electron sender for GRBL based CNC machines",
"author": {
"name": "Sienci Labs <hi@sienci.com>",
Expand Down
74 changes: 20 additions & 54 deletions src/app/lib/GCodeVirtualizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,6 @@ class GCodeVirtualizer extends EventEmitter {
];
feedrateCounter = 0;

hasSetV1 = false;

handlers = {
// G0: Rapid Linear Move
'G0': (params) => {
Expand Down Expand Up @@ -244,19 +242,11 @@ class GCodeVirtualizer extends EventEmitter {
this.updateBounds(targetPosition);
this.setPosition(targetPosition.x, targetPosition.y, targetPosition.z, targetPosition.a);

if (!this.hasSetV1) {
this.data[this.totalLines].lineData = {
v1: this.offsetG92(v1),
v2: this.offsetG92(v2),
shouldUseAddCurve: isCurvedLine && angleDiff > ANGLE_THRESHOLD,
};
this.hasSetV1 = true;
} else {
this.data[this.totalLines].lineData = {
v2: this.offsetG92(v2),
shouldUseAddCurve: isCurvedLine && angleDiff > ANGLE_THRESHOLD,
};
}
this.data[this.totalLines].lineData = {
v1: this.offsetG92(v1),
v2: this.offsetG92(v2),
shouldUseAddCurve: isCurvedLine && angleDiff > ANGLE_THRESHOLD,
};
},
// G1: Linear Move
// Usage
Expand Down Expand Up @@ -307,19 +297,11 @@ class GCodeVirtualizer extends EventEmitter {
this.updateBounds(targetPosition);
this.setPosition(targetPosition.x, targetPosition.y, targetPosition.z, targetPosition.a);

if (!this.hasSetV1) {
this.data[this.totalLines].lineData = {
v1: this.offsetG92(v1),
v2: this.offsetG92(v2),
shouldUseAddCurve: isCurvedLine && angleDiff > ANGLE_THRESHOLD,
};
this.hasSetV1 = true;
} else {
this.data[this.totalLines].lineData = {
v2: this.offsetG92(v2),
shouldUseAddCurve: isCurvedLine && angleDiff > ANGLE_THRESHOLD,
};
}
this.data[this.totalLines].lineData = {
v1: this.offsetG92(v1),
v2: this.offsetG92(v2),
shouldUseAddCurve: isCurvedLine && angleDiff > ANGLE_THRESHOLD,
};
},
// G2 & G3: Controlled Arc Move
// Usage
Expand Down Expand Up @@ -410,19 +392,11 @@ class GCodeVirtualizer extends EventEmitter {
this.updateBounds(targetPosition);
this.setPosition(targetPosition.x, targetPosition.y, targetPosition.z);

if (!this.hasSetV1) {
this.data[this.totalLines].lineData = {
v1: this.offsetG92(v1),
v2: this.offsetG92(v2),
v0: this.offsetG92(v0)
};
this.hasSetV1 = true;
} else {
this.data[this.totalLines].lineData = {
v2: this.offsetG92(v2),
v0: this.offsetG92(v0)
};
}
this.data[this.totalLines].lineData = {
v1: this.offsetG92(v1),
v2: this.offsetG92(v2),
v0: this.offsetG92(v0)
};
},
'G3': (params) => {
if (this.modal.motion !== 'G3') {
Expand Down Expand Up @@ -494,19 +468,11 @@ class GCodeVirtualizer extends EventEmitter {
this.updateBounds(targetPosition);
this.setPosition(targetPosition.x, targetPosition.y, targetPosition.z);

if (!this.hasSetV1) {
this.data[this.totalLines].lineData = {
v1: this.offsetG92(v1),
v2: this.offsetG92(v2),
v0: this.offsetG92(v0)
};
this.hasSetV1 = true;
} else {
this.data[this.totalLines].lineData = {
v2: this.offsetG92(v2),
v0: this.offsetG92(v0)
};
}
this.data[this.totalLines].lineData = {
v1: this.offsetG92(v1),
v2: this.offsetG92(v2),
v0: this.offsetG92(v0)
};
},
// G4: Dwell
// Parameters
Expand Down
11 changes: 9 additions & 2 deletions src/app/lib/gamepad/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ import { GamepadListener } from 'gamepad.js';
import shuttleEvents from 'app/lib/shuttleEvents';
import store from 'app/store';
import { Toaster, TOASTER_INFO } from 'app/lib/toaster/ToasterLib';
import { debounce } from 'lodash';
import { debounce, noop } from 'lodash';

const macroCallbackDebounce = debounce((action) => shuttleEvents.allShuttleControlEvents.MACRO(null, { macroID: action }), 500);
let buttonPressDebounce = noop;
let currentShuttleEvent = {};

class Gamepad extends GamepadListener {
constructor() {
Expand Down Expand Up @@ -183,7 +185,12 @@ export const runAction = ({ event }) => {
const shuttleEvent = shuttleControlEvents[action];

if (shuttleEvent?.callback) {
shuttleEvent.callback(null, shuttleEvent.payload);
// gamepads emit many signals on button press, so this stops the shortcut from running a bunch of times
if (currentShuttleEvent.cmd !== shuttleEvent.cmd) {
currentShuttleEvent = shuttleEvent;
buttonPressDebounce = debounce(() => shuttleEvent.callback(null, shuttleEvent.payload));
}
buttonPressDebounce();
}
} else {
macroCallbackDebounce(action);
Expand Down
13 changes: 11 additions & 2 deletions src/app/sagas/controllerSagas.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ import {
ERROR,
JOB_TYPES,
JOB_STATUS,
GRBL,
} from 'app/constants';
import { connectToLastDevice } from 'app/containers/Firmware/utils/index';
import { updateWorkspaceMode } from 'app/lib/rotary';
Expand Down Expand Up @@ -617,14 +618,22 @@ export function* initialize() {
pubsub.publish('firmware:update', status);
});

controller.addListener('error', (error) => {
controller.addListener('error', (error, wasRunning) => {
const homingEnabled = _get(reduxStore.getState(), 'controller.settings.settings.$22');

if (ALARM_ERROR_TYPES.includes(error.type)) {
updateAlarmsErrors(error);
}
// if (isElectron() && (alarmReg.test(error.type) || errorReg.test(error.type))) {
// window.ipcRenderer.send('logError:electron', error);
// }
pubsub.publish('error', error);

// set need recovery for start from line when alarm happens
if (error.type === ALARM && wasRunning) {
console.log(error.lineNumber);
pubsub.publish('disconnect:recovery', error.lineNumber, homingEnabled);
}
});

controller.addListener('wizard:next', (stepIndex, substepIndex) => {
Expand All @@ -648,7 +657,7 @@ export function* initialize() {
}
}

if (type === FILE_TYPE.FOUR_AXIS && controller.type === 'Grbl') {
if (type === FILE_TYPE.FOUR_AXIS && controller.type === GRBL) {
Confirm({
title: '4 Axis File Loaded',
content: 'G-Code contains 4 simultaneous axis commands which are not supported at this time and cannot be run.',
Expand Down
6 changes: 5 additions & 1 deletion src/app/widgets/JogControl/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,11 @@ class AxesWidget extends PureComponent {
preventDefault(event);
}

this.handleShortcutStop(payload);
if (this.state.isContinuousJogging) {
this.handleShortcutStop(payload);
} else {
controller.command('jog:stop');
}
},
},
SET_R_JOG_PRESET: {
Expand Down
61 changes: 51 additions & 10 deletions src/app/widgets/Spindle/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,14 @@ class SpindleWidget extends PureComponent {
},
handleLaserPowerChange: (e) => {
const { laser } = this.state;
const { power, maxPower } = laser;
const { spindle, laserMax } = this.props;

let { power, maxPower } = laser;

if (spindle.value === 'SLB_LASER') {
maxPower = laserMax;
}

const value = Number(e.target.value);
if (this.isLaserOn) {
this.debounceLaserPower(power, maxPower);
Expand All @@ -202,7 +209,12 @@ class SpindleWidget extends PureComponent {
},
runLaserTest: () => {
const { laser } = this.state;
const { power, duration, maxPower } = laser;
const { laserMax, spindle } = this.props;
let { power, duration, maxPower } = laser;

if (spindle.label === 'SLB_LASER') {
maxPower = laserMax;
}

controller.command('lasertest:on', power, duration, maxPower);
setTimeout(() => {
Expand All @@ -212,7 +224,6 @@ class SpindleWidget extends PureComponent {
}, laser.duration);
},
handleHALSpindleSelect: (spindle) => {
console.log(spindle);
controller.command('gcode', [
`M104 Q${spindle.value}`,
'$spindles'
Expand Down Expand Up @@ -409,8 +420,6 @@ class SpindleWidget extends PureComponent {
const { wpos, $13 } = this.props;
let { x, y } = wpos;

console.log(units);

if ($13 === '1' || units === 'G20') {
units = 'G20';
x /= 25.4;
Expand All @@ -421,11 +430,20 @@ class SpindleWidget extends PureComponent {

getLaserOffsetCode(preferredUnits) {
const laser = this.config.get('laser');
const { controllerType, laserXOffset, laserYOffset } = this.props;

this.setState({
laser
});
let { xOffset, yOffset } = laser;

// If using grblHAL AND SLB_LASER, use the eeprom laser offset values
if (controllerType === GRBLHAL) {
xOffset = laserXOffset;
yOffset = laserYOffset;
}


if (preferredUnits === 'G20') {
xOffset = convertToImperial(xOffset);
yOffset = convertToImperial(yOffset);
Expand All @@ -434,7 +452,6 @@ class SpindleWidget extends PureComponent {
yOffset = roundMetric(yOffset);
}
const [xoffsetAdjusted, yOffsetAdjusted] = this.calculateAdjustedOffsets(xOffset, yOffset, preferredUnits);
console.log(`x: ${xoffsetAdjusted}, y: ${yOffsetAdjusted}`);

let offsetQuery = [];
if (xOffset === 0 && yOffset !== 0) {
Expand All @@ -454,12 +471,22 @@ class SpindleWidget extends PureComponent {
}

getSpindleOffsetCode(preferredUnits) {
const { controllerType, laserXOffset, laserYOffset } = this.props;

const laser = this.config.get('laser');
this.setState({
laser
});
let offsetQuery = [];

let { xOffset, yOffset } = laser;

// If using grblHAL AND SLB_LASER, use the eeprom laser offset values
if (controllerType === GRBLHAL) {
xOffset = laserXOffset;
yOffset = laserYOffset;
}

xOffset = Number(xOffset) * -1;
yOffset = Number(yOffset) * -1;
if (preferredUnits === 'G20') {
Expand Down Expand Up @@ -541,7 +568,7 @@ class SpindleWidget extends PureComponent {
}

render() {
const { embedded, spindleModal, spindleMin, spindleMax, availableSpindles, spindle } = this.props;
const { embedded, spindleModal, spindleMin, spindleMax, availableSpindles, spindle, laserMax, laserMin } = this.props;
const { minimized, isFullscreen } = this.state;
const controllerType = store.get('widgets.connection.controller.type', '-');

Expand All @@ -550,6 +577,9 @@ class SpindleWidget extends PureComponent {
spindleModal,
spindleMin,
spindleMax,
laserMax,
laserMin,
controllerType,
spindle,
canClick: this.canClick(),
};
Expand Down Expand Up @@ -598,6 +628,7 @@ class SpindleWidget extends PureComponent {
}

export default connect((store) => {
const controllerType = get(store, 'controller.type', 'grbl');
const workflow = get(store, 'controller.workflow');
const state = get(store, 'controller.state');
const isConnected = get(store, 'connection.isConnected');
Expand All @@ -612,8 +643,12 @@ export default connect((store) => {
const units = get(store, 'controller.modal.units', {});
const availableSpindles = get(store, 'controller.spindles', []);
const $13 = get(store, 'controller.settings.settings.$13', '0');


// SLB - 730 max, 731 min laser
// SLB - 741 laser X offset, 742 laser Y offset
const laserMax = Number(get(store, 'controller.settings.settings.$730', 255));
const laserMin = Number(get(store, 'controller.settings.settings.$731', 0));
const laserXOffset = Number(get(store, 'controller.settings.settings.$741', 0));
const laserYOffset = Number(get(store, 'controller.settings.settings.$742', 0));
let enabledSpindle;

const enabledSpindleIndex = findIndex(availableSpindles, o => o.enabled);
Expand Down Expand Up @@ -641,6 +676,12 @@ export default connect((store) => {
units,
availableSpindles,
$13,
spindle: enabledSpindle
spindle: enabledSpindle,
// SLB specific laser values
laserMax,
laserMin,
laserXOffset,
laserYOffset,
controllerType
};
})(SpindleWidget);
12 changes: 8 additions & 4 deletions src/app/widgets/Visualizer/Visualizer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ class Visualizer extends Component {

vizualization = null;

colorsWorker = null;

renderCallback = null;

machineProfile = store.get('workspace.machineProfile');
Expand Down Expand Up @@ -829,6 +831,7 @@ class Visualizer extends Component {
pubsub.subscribe('colors:load', (_, data) => {
const { colorArray, savedColors } = data;
this.handleSceneRender(this.vizualization, colorArray, savedColors, this.renderCallback);
this.colorsWorker.terminate();
})
];
this.pubsubTokens = this.pubsubTokens.concat(tokens);
Expand Down Expand Up @@ -1764,15 +1767,16 @@ class Visualizer extends Component {
const shouldRenderVisualization = liteMode ? !disabledLite : !disabled;

if (shouldRenderVisualization) {
console.log(vizualization);
this.vizualization = vizualization;
this.renderCallback = callback;
let colorsWorker = new ColorsWorker();
colorsWorker.onmessage = colorsResponse;
colorsWorker.postMessage({
this.colorsWorker = new ColorsWorker();
this.colorsWorker.onmessage = colorsResponse;
this.colorsWorker.postMessage({
colors: vizualization.colors,
frames: vizualization.frames,
spindleSpeeds: vizualization.spindleSpeeds,
isLazer: vizualization.isLazer,
isLaser: vizualization.isLaser,
spindleChanges: vizualization.spindleChanges,
theme: currentTheme
});
Expand Down
Loading

0 comments on commit b69a0fc

Please sign in to comment.