Skip to content

Commit

Permalink
Use joystick throw for single axis feedrate
Browse files Browse the repository at this point in the history
  • Loading branch information
walidkayhan committed Nov 17, 2023
1 parent fa22c40 commit 419fb95
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/app/widgets/JogControl/JoystickLoop.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,12 @@ export class JoystickLoop {
return [];
}

_runJog = ({ activeAxis }) => {
const axes = this._getAxesAndDirection({ degrees: this.degrees, activeAxis });
_runJog = () => {
const { degrees, activeAxis, multiplier: { leftStick, rightStick } } = this;

const axes = this._getAxesAndDirection({ degrees, activeAxis });

const numberOfAxes = axes.reduce((acc, curr) => (curr !== null ? acc + 1 : acc), 0);

const timer = (new Date() - this.jogMovementStartTime);

Expand All @@ -216,13 +220,11 @@ export class JoystickLoop {
return;
}

const { leftStick, rightStick } = this.multiplier;

const multiplier = [leftStick, leftStick, rightStick, rightStick][activeAxis];
const feedrate = this._computeFeedrate(multiplier);

const axesData = activeAxis < 2 ? axesValues.slice(0, 2) : axesValues.slice(2, 4);

const feedrate = this._computeFeedrate(numberOfAxes === 1 ? Math.max(...axesData.map(item => Math.abs(item))) : multiplier);

const updatedAxes = axesData.reduce((acc, curr, index) => {
const axesData = axes[index];

Expand Down Expand Up @@ -284,12 +286,13 @@ export class JoystickLoop {
}, {});
}

setOptions = ({ gamepadProfile, feedrate, axes, multiplier, degrees }) => {
setOptions = ({ gamepadProfile, feedrate, axes, multiplier, degrees, activeAxis }) => {
this.gamepadProfile = gamepadProfile;
this.feedrate = feedrate;
this.axes = axes;
this.multiplier = multiplier;
this.degrees = degrees;
this.activeAxis = activeAxis;
}

start = (activeAxis) => {
Expand Down

0 comments on commit 419fb95

Please sign in to comment.