Skip to content

Commit

Permalink
[MI-1484]: movement distance override adjusted for SLB
Browse files Browse the repository at this point in the history
  • Loading branch information
sophiabeluli committed May 29, 2024
1 parent cb2cf3e commit a5f983a
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/app/widgets/JogControl/JoystickLoop.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { throttle, inRange, get } from 'lodash';
import reduxStore from 'app/store/redux';

import gamepad, { checkButtonHold } from 'app/lib/gamepad';
import controller from 'app/lib/controller';
import { GRBLHAL } from '../../constants';

export const checkThumbsticskAreIdle = (axes, profile) => {
const deadZone = profile?.joystickOptions?.zeroThreshold && profile?.joystickOptions?.zeroThreshold / 100;
Expand Down Expand Up @@ -81,6 +83,8 @@ export class JoystickLoop {
};

_computeIncrementalDistance = ({ axis, feedrate: givenFeedrate }) => {
const controllerType = get(reduxStore.getState(), 'controller.type');

const { settings } = controller.settings;

const { joystickOptions: { movementDistanceOverride = 100 } } = this.gamepadProfile;
Expand All @@ -100,7 +104,9 @@ export class JoystickLoop {

const COMMAND_EXECUTION_TIME_IN_SECONDS = 0.06;

const incrementalDistance = (feedrateInMMPerSec * COMMAND_EXECUTION_TIME_IN_SECONDS) * (movementDistanceOverride / 100);
const multiplier = controllerType === GRBLHAL ? 14 : 1;
console.log(multiplier);
const incrementalDistance = (feedrateInMMPerSec * COMMAND_EXECUTION_TIME_IN_SECONDS) * (movementDistanceOverride * multiplier / 100);

return +(incrementalDistance.toFixed(2));
};
Expand Down Expand Up @@ -201,6 +207,8 @@ export class JoystickLoop {
_runJog = () => {
const { degrees, activeAxis, multiplier: { leftStick, rightStick } } = this;

const controllerType = get(reduxStore.getState(), 'controller.type');

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

const numberOfAxes = axes.reduce((acc, curr) => (curr !== null ? acc + 1 : acc), 0);
Expand Down Expand Up @@ -258,7 +266,9 @@ export class JoystickLoop {
const updatedAxesWithOverride = Object.entries(updatedAxes).reduce((acc, curr) => {
const [axis, value] = curr;

acc[axis] = +((value * (movementDistanceOverride / 100)).toFixed(3));
const multiplier = controllerType === GRBLHAL ? 14 : 1;

acc[axis] = +((value * (movementDistanceOverride * multiplier / 100)).toFixed(3));

return acc;
}, {});
Expand Down

0 comments on commit a5f983a

Please sign in to comment.