Skip to content

Commit

Permalink
feat: allow inverting axis
Browse files Browse the repository at this point in the history
  • Loading branch information
cadriel committed Nov 12, 2020
1 parent fcbe166 commit cf6a993
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/components/cards/settings/CameraSettingsCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
icon="$camera">
<v-card-text>
<v-switch
class="mt-0"
label="Enabled"
hide-details
v-model="enabled">
Expand Down
1 change: 1 addition & 0 deletions src/components/cards/settings/MacroSettingsCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<v-row>
<v-col cols="12" md="6" class="py-0" v-for="(macro) in macros" :key="macro.name">
<v-switch
class="mt-0 mb-4"
:input-value="macro.visible"
@change="changeMacro(macro, $event)"
:label="macro.name"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
icon="$clock">
<v-card-text>
<v-radio-group
class="mt-0 mb-0"
v-model="printTimeEstimationsType"
:mandatory="true">
<v-radio label="Duration only" value="totals"></v-radio>
Expand Down
42 changes: 42 additions & 0 deletions src/components/cards/settings/ToolheadSettingsCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,24 @@
cardKey="ToolSettings"
icon="$printer3dNozzle">
<v-card-text>
<v-switch
class="mt-0 mb-4"
label="Invert X"
hide-details
v-model="invertX">
</v-switch>
<v-switch
class="mt-0 mb-4"
label="Invert Y"
hide-details
v-model="invertY">
</v-switch>
<v-switch
class="mt-0 mb-4"
label="Invert Z"
hide-details
v-model="invertZ">
</v-switch>
<v-text-field
filled
label="Default Extrude Length"
Expand Down Expand Up @@ -58,5 +76,29 @@ export default class ToolHeadSettingsCard extends Mixins(UtilsMixin) {
set defaultToolheadMoveLength (value: number) {
this.$store.dispatch('config/saveGeneric', { key: 'fileConfig.general.defaultToolheadMoveLength', value })
}
get invertX () {
return this.$store.state.config.fileConfig.general.axis.x.inverted
}
set invertX (value: boolean) {
this.$store.dispatch('config/saveGeneric', { key: 'fileConfig.general.axis.x.inverted', value })
}
get invertY () {
return this.$store.state.config.fileConfig.general.axis.y.inverted
}
set invertY (value: boolean) {
this.$store.dispatch('config/saveGeneric', { key: 'fileConfig.general.axis.y.inverted', value })
}
get invertZ () {
return this.$store.state.config.fileConfig.general.axis.z.inverted
}
set invertZ (value: boolean) {
this.$store.dispatch('config/saveGeneric', { key: 'fileConfig.general.axis.z.inverted', value })
}
}
</script>
1 change: 0 additions & 1 deletion src/components/inputs/BtnCollapse.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export default class BtnCollapse extends Vue {
value!: boolean
emitChange (value: boolean) {
console.log('emitting ', value)
this.$emit('input', value)
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/components/widgets/ToolheadMovesWidget.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<v-row no-gutters justify="start" class="mb-3">
<v-col cols="auto">
<btn-toolhead-move
@click="sendMoveGcode('X', '-' + toolheadMoveLength)"
@click="sendMoveGcode('X', toolheadMoveLength, true)"
:disabled="hasWaits || !xyHomed || !klippyConnected"
icon="$left">
</btn-toolhead-move>
Expand Down Expand Up @@ -53,14 +53,14 @@
<v-row no-gutters justify="start" class="mb-3">
<v-col cols="auto" class="ml-13 mr-8">
<btn-toolhead-move
@click="sendMoveGcode('Y', '-' + toolheadMoveLength)"
@click="sendMoveGcode('Y', toolheadMoveLength, true)"
:disabled="hasWaits || !xyHomed || !klippyConnected"
icon="$down">
</btn-toolhead-move>
</v-col>
<v-col cols="auto" class="ml-8">
<btn-toolhead-move
@click="sendMoveGcode('Z', '-' + toolheadMoveLength)"
@click="sendMoveGcode('Z', toolheadMoveLength, true)"
:disabled="hasWaits || !zHomed || !klippyConnected"
icon="$down">
</btn-toolhead-move>
Expand Down
10 changes: 8 additions & 2 deletions src/mixins/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,15 @@ export default class UtilsMixin extends Vue {
/**
* Send a move gcode script.
*/
sendMoveGcode (axes: string, distance: string) {
sendMoveGcode (axis: string, distance: string, negative = false) {
axis = axis.toLowerCase()
const inverted = this.$store.state.config.fileConfig.general.axis[axis].inverted || false
distance = ((negative && !inverted) || (!negative && inverted))
? '-' + distance
: distance

this.sendGcode(`G91
G1 ${axes}${distance} F6000
G1 ${axis}${distance} F6000
G90`)
}

Expand Down
6 changes: 6 additions & 0 deletions src/store/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ export const state: ConfigState = {
jobsInMenu: true,
jobsInDash: false,
darkMode: true,
axis: {
x: { inverted: false },
y: { inverted: false },
z: { inverted: false }
},
invertZControl: false,
printTimeEstimationsType: 'file',
defaultExtrudeLength: 10,
defaultExtrudeSpeed: 5,
Expand Down
10 changes: 10 additions & 0 deletions src/store/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,22 @@ export interface GeneralConfig {
jobsInMenu: boolean;
jobsInDash: boolean;
darkMode: boolean;
axis: Axis;
invertZControl: boolean;
defaultExtrudeLength: number;
defaultExtrudeSpeed: number;
defaultToolheadMoveLength: string;
printTimeEstimationsType: 'file' | 'slicer' | 'filament' | 'totals';
}

export interface Axis {
[key: string]: AxisConfig;
}

export interface AxisConfig {
inverted: boolean;
}

export interface CameraConfig {
enabled: boolean;
url: string;
Expand Down

0 comments on commit cf6a993

Please sign in to comment.