Skip to content

Commit

Permalink
[FIX] m2 triangular; UI cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
zaneclaes committed Sep 21, 2020
1 parent 09b479f commit d4da0c5
Show file tree
Hide file tree
Showing 7 changed files with 168 additions and 132 deletions.
4 changes: 3 additions & 1 deletion docs/machines/cnc/index.md
Expand Up @@ -8,6 +8,8 @@ has_children: true

# CNC

Find your machine, below, and click on the appropriate link for the latest firmware.

## Maslow

_Please read the [Maslow-specific instructions](/machines/cnc/maslow)._
Expand All @@ -27,6 +29,6 @@ _Please read the [Maslow-specific instructions](/machines/cnc/maslow)._
- [Grbl](https://github.com/gnea/grbl) ([Download](https://github.com/gnea/grbl/releases))
- [Grbl-Mega](https://github.com/gnea/grbl-Mega) ([Download](https://github.com/gnea/grbl-Mega/releases))

### Tested On
#### Tested On

- SainSmart Genmitsu 3180 Pro (Baud Rate: 115200)
4 changes: 2 additions & 2 deletions src/app/lib/Maslow/MaslowCalibration.jsx
Expand Up @@ -132,9 +132,9 @@ class MaslowCalibration {
return 0;
}
if (Math.abs(skewRight) > Math.abs(skewLeft)) {
return skewRight;
return Math.round(skewRight);
} else {
return skewLeft;
return Math.round(skewLeft);
}
}

Expand Down
6 changes: 6 additions & 0 deletions src/app/lib/active-state.js
@@ -1,5 +1,7 @@
import _ from 'lodash';
import {
IMPERIAL_UNITS,
METRIC_UNITS,
GRBL,
MASLOW,
MARLIN,
Expand Down Expand Up @@ -135,6 +137,10 @@ class ActiveState {
return this._state;
}

get units() {
return this.isImperialUnits ? IMPERIAL_UNITS : METRIC_UNITS;
}

get isImperialUnits() {
return this.modal.units === 'G20';
}
Expand Down
1 change: 1 addition & 0 deletions src/app/widgets/Axes/Axes.jsx
Expand Up @@ -22,6 +22,7 @@ const Axes = (props) => {
<Keypad
workspaceId={props.workspaceId}
canClick={state.canClick}
canChangeUnits={true}
units={state.units}
axes={state.axes}
jog={state.jog}
Expand Down
6 changes: 3 additions & 3 deletions src/app/widgets/Axes/Keypad.jsx
Expand Up @@ -31,6 +31,7 @@ class Keypad extends PureComponent {
static propTypes = {
workspaceId: PropTypes.string.isRequired,
canClick: PropTypes.bool,
canChangeUnits: PropTypes.bool,
units: PropTypes.oneOf([IMPERIAL_UNITS, METRIC_UNITS]),
axes: PropTypes.array,
jog: PropTypes.object,
Expand Down Expand Up @@ -167,8 +168,7 @@ class Keypad extends PureComponent {
}

render() {
const { canClick, units, axes, jog } = this.props;
const canChangeUnits = canClick;
const { canClick, units, axes, jog, canChangeUnits } = this.props;
const canChangeStep = canClick;
const imperialJogSteps = this.workspace.imperialJogSteps;
const metricJogSteps = this.workspace.metricJogSteps;
Expand Down Expand Up @@ -434,7 +434,7 @@ class Keypad extends PureComponent {
style={{
width: '100%'
}}
disabled={!canChangeUnits}
disabled={!canChangeUnits || !canClick}
>
<Dropdown.Toggle
btnStyle="flat"
Expand Down
241 changes: 130 additions & 111 deletions src/app/widgets/Maslow/CalibrationModal.jsx

Large diffs are not rendered by default.

38 changes: 23 additions & 15 deletions src/app/widgets/Maslow/MeasureChainsFlow.jsx
Expand Up @@ -3,15 +3,17 @@ import PropTypes from 'prop-types';
import Workspaces from 'app/lib/workspaces';
import Keypad from 'app/widgets/Axes/Keypad';
import {
METRIC_UNITS,
} from '../../constants';
IMPERIAL_UNITS,
} from 'app/constants';
// import i18n from 'app/lib/i18n';

class MeasureChainsFlow extends PureComponent {
static propTypes = {
workspaceId: PropTypes.string.isRequired,
calibration: PropTypes.object.isRequired,
setChains: PropTypes.func.isRequired,
setStep: PropTypes.func.isRequired,
step: PropTypes.string,
measureCenterOffset: PropTypes.func.isRequired,
moveToCenter: PropTypes.func.isRequired,
};
Expand All @@ -23,7 +25,6 @@ class MeasureChainsFlow extends PureComponent {
pages = ['Preparation', 'Alignment', 'Slack', 'Attachment', 'Measurement', 'Axes'];

state = {
page: this.pages[0],
jog: {
metric: {
step: 0,
Expand All @@ -47,12 +48,12 @@ class MeasureChainsFlow extends PureComponent {
}

get pageNum() {
return this.pages.indexOf(this.state.page);
return this.pages.indexOf(this.props.step) || 0;
}

set pageNum(pn) {
pn = Math.max(0, Math.min(pn, this.pages.length - 1));
this.setState({ page: this.pages[pn] });
this.props.setStep(this.pages[pn]);
}

setPage(name) {
Expand All @@ -67,13 +68,18 @@ class MeasureChainsFlow extends PureComponent {
this.pageNum -= 1;
}

get isImperialUnits() {
return this.props.units === IMPERIAL_UNITS;
}

updateJogStep(callback) {
const v = callback(this.state.jog.metric.step);
const metricJogSteps = this.workspace.metricJogSteps;
const step = Math.max(0, Math.min(v, metricJogSteps.length - 1));
const key = this.isImperialUnits ? 'imperial' : 'metric';
const v = callback(this.state.jog[key].step);
const jogSteps = this.isImperialUnits ? this.workspace.imperialJogSteps : this.workspace.metricJogSteps;
const step = Math.max(0, Math.min(v, jogSteps.length - 1));
this.setState({
jog: {
metric: {
[key]: {
step: step,
}
}
Expand All @@ -82,9 +88,10 @@ class MeasureChainsFlow extends PureComponent {

keypadActions = {
getJogDistance: () => {
const step = this.state.jog.metric.step;
const metricJogSteps = this.workspace.metricJogSteps;
const distance = Number(metricJogSteps[step]) || 0;
const key = this.isImperialUnits ? 'imperial' : 'metric';
const step = this.state.jog[key].step;
const jogSteps = this.isImperialUnits ? this.workspace.imperialJogSteps : this.workspace.metricJogSteps;
const distance = Number(jogSteps[step]) || 0;
return distance;
},
stepBackward: () => {
Expand All @@ -105,7 +112,8 @@ class MeasureChainsFlow extends PureComponent {
<Keypad
workspaceId={this.workspace.id}
canClick={true}
units={METRIC_UNITS}
canChangeUnits={false}
units={this.workspace.activeState.units}
axes={axes}
jog={this.state.jog}
actions={this.keypadActions}
Expand Down Expand Up @@ -361,8 +369,8 @@ class MeasureChainsFlow extends PureComponent {
}

render() {
// TODO: before shutting, run Home. We know there's no chain sag already.
return this[`render${this.state.page}`]();
const step = this.props.step || this.pages[0];
return this[`render${step}`]();
}
}

Expand Down

0 comments on commit d4da0c5

Please sign in to comment.