Skip to content

Commit

Permalink
feat: pressure advance settings on dashboard (mainsail-crew#459)
Browse files Browse the repository at this point in the history
* feat: pressure advance settings on dashboard

Signed-off-by: Dominik Willner <[email protected]>

* fix: motion setting input layout

Signed-off-by: Dominik Willner <[email protected]>

* fix: use restart icon instead of refresh icon

Signed-off-by: Dominik Willner <[email protected]>

* fix: fw retract settings input layout

Signed-off-by: Dominik Willner <[email protected]>

* refactor: move pressure advance settings

* move pressure advance settings from PrintsettingsPanel to MachineSettingsPanel

Signed-off-by: Dominik Willner <[email protected]>

* fix: hide spin buttons in fw retract input fields

Signed-off-by: Dominik Willner <[email protected]>

* fix: hide spin buttons in pa input fields

Signed-off-by: Dominik Willner <[email protected]>

* refactor: class assignment conditions in pa settings

Signed-off-by: Dominik Willner <[email protected]>

* chore: define function return types

Signed-off-by: Dominik Willner <[email protected]>

* refactor: remove unused imports

Signed-off-by: Stefan Dej <[email protected]>

Co-authored-by: Stefan Dej <[email protected]>
  • Loading branch information
dw-0 and meteyou committed Dec 25, 2021
1 parent 2ba22ab commit 5e88cdc
Show file tree
Hide file tree
Showing 10 changed files with 204 additions and 18 deletions.
5 changes: 3 additions & 2 deletions src/components/inputs/FirmwareRetractionSettingsInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
:step="step"
type="number"
min="0"
hide-spin-buttons
hide-details
outlined
dense
Expand Down Expand Up @@ -42,13 +43,13 @@ export default class FirmwareRetractionSettingsInput extends Mixins(BaseMixin) {
this.value = this.target
}
resetLimit() {
resetLimit(): void {
this.value = this.defaultValue
this.sendCmd()
}
sendCmd() {
sendCmd(): void {
const gcode = 'SET_RETRACTION ' + this.attributeName + '=' + Math.max(0, this.value).toFixed(2)
this.$store.dispatch('server/addEvent', {message: gcode, type: 'command'})
this.$socket.emit('printer.gcode.script', {script: gcode})
Expand Down
4 changes: 2 additions & 2 deletions src/components/inputs/MotionSettingsInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ export default class MotionSettingsInput extends Mixins(BaseMixin) {
this.value = this.target
}
resetLimit() {
resetLimit(): void {
this.value = this.defaultValue
this.sendCmd()
}
sendCmd() {
sendCmd(): void {
const gcode = 'SET_VELOCITY_LIMIT ' + this.attributeName + '=' + Math.max(1, this.value).toFixed(0)
this.$store.dispatch('server/addEvent', {message: gcode, type: 'command'})
this.$socket.emit('printer.gcode.script', {script: gcode})
Expand Down
62 changes: 62 additions & 0 deletions src/components/inputs/PressureAdvanceSettingsInput.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<template>
<form v-on:submit.prevent="sendCmd">
<v-text-field
v-model="value"
@click:append="resetLimit"
:label="label"
:suffix="unit"
:append-icon="this.value !== this.defaultValue ? 'mdi-restart' : ''"
:error="this.value < 0"
:step="step"
type="number"
min="0"
hide-spin-buttons
hide-details
outlined
dense
></v-text-field>
</form>
</template>

<script lang="ts">
import Component from 'vue-class-component'
import {Mixins, Prop, Watch} from 'vue-property-decorator'
import BaseMixin from '@/components/mixins/base'
@Component
export default class PressureAdvanceSettingsInput extends Mixins(BaseMixin) {
private value: any = 0
@Prop({ type: String, required: true }) readonly label!: string
@Prop({ type: Number, required: false }) readonly step!: string
@Prop({ type: Number, required: true, default: 0 }) readonly target!: number
@Prop({ type: Number, required: true, default: 0 }) readonly defaultValue!: number
@Prop({ type: String, required: true, default: 'extruder'}) readonly extruder!: string
@Prop({ type: Number, required: true, default: 100 }) readonly max!: number
@Prop({ type: String, required: true }) readonly attributeName!: string
@Prop({ type: String, required: true }) readonly unit!: string
@Watch('target')
targetChanged(newVal: number): void {
this.value = newVal
}
created(): void {
this.value = this.target
}
resetLimit(): void {
this.value = this.defaultValue
this.sendCmd()
}
sendCmd(): void {
const gcode = 'SET_PRESSURE_ADVANCE ' + 'EXTRUDER=' + this.extruder + ' '
+ this.attributeName + '=' + Math.max(0, this.value).toFixed(4)
this.$store.dispatch('server/addEvent', {message: gcode, type: 'command'})
this.$socket.emit('printer.gcode.script', {script: gcode})
}
}
</script>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<v-card-text>
<v-row>
<v-col class="col-12 col-sm-6">
<v-col class="col-12 col-md-6">
<firmware-retraction-settings-input
:label="$t('Panels.MachineSettingsPanel.FirmwareRetractionSettings.RetractLength')"
:target="current_retract_length"
Expand All @@ -11,7 +11,7 @@
attribute-name="RETRACT_LENGTH"
></firmware-retraction-settings-input>
</v-col>
<v-col class="col-12 col-sm-6">
<v-col class="col-12 col-md-6">
<firmware-retraction-settings-input
:label="$t('Panels.MachineSettingsPanel.FirmwareRetractionSettings.RetractSpeed')"
:target="current_retract_speed"
Expand All @@ -22,7 +22,7 @@
</v-col>
</v-row>
<v-row>
<v-col class="col-12 col-sm-6">
<v-col class="col-12 col-md-6">
<firmware-retraction-settings-input
:label="$t('Panels.MachineSettingsPanel.FirmwareRetractionSettings.UnretractExtraLength')"
:target="current_unretract_extra_length"
Expand All @@ -32,7 +32,7 @@
attribute-name="UNRETRACT_EXTRA_LENGTH"
></firmware-retraction-settings-input>
</v-col>
<v-col class="col-12 col-sm-6">
<v-col class="col-12 col-md-6">
<firmware-retraction-settings-input
:label="$t('Panels.MachineSettingsPanel.FirmwareRetractionSettings.UnretractSpeed')"
:target="current_unretract_speed"
Expand Down
13 changes: 10 additions & 3 deletions src/components/panels/MachineSettings/MachineSettingsPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,21 @@
:collapsible="true"
card-class="machine-settings-panel"
>
<motion-settings v-if="!existsFirmwareRetraction"></motion-settings>

<div v-if="existsFirmwareRetraction">
<div>
<sub-panel
:title="$t('Panels.MachineSettingsPanel.MotionSettings.Motion')"
sub-panel-class="motion-settings-subpanel"
>
<motion-settings></motion-settings>
</sub-panel>
<sub-panel
:title="$t('Panels.MachineSettingsPanel.PressureAdvanceSettings.PressureAdvance')"
sub-panel-class="pressure-advance-settings-subpanel"
>
<pressure-advance-settings></pressure-advance-settings>
</sub-panel>
<sub-panel
v-if="existsFirmwareRetraction"
:title="$t('Panels.MachineSettingsPanel.FirmwareRetractionSettings.FirmwareRetraction')"
sub-panel-class="firmware-retraction-settings-subpanel"
>
Expand All @@ -31,13 +36,15 @@ import BaseMixin from '@/components/mixins/base'
import Panel from '@/components/ui/Panel.vue'
import SubPanel from '@/components/ui/SubPanel.vue'
import MotionSettings from '@/components/panels/MachineSettings/MotionSettings.vue'
import PressureAdvanceSettings from '@/components/panels/MachineSettings/PressureAdvanceSettings.vue'
import FirmwareRetractionSettings from '@/components/panels/MachineSettings/FirmwareRetractionSettings.vue'
@Component({
components: {
Panel,
SubPanel,
MotionSettings,
PressureAdvanceSettings,
FirmwareRetractionSettings
}
})
Expand Down
8 changes: 4 additions & 4 deletions src/components/panels/MachineSettings/MotionSettings.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<v-card-text>
<v-row>
<v-col class="col-12 col-sm-6">
<v-col class="col-12 col-md-6">
<motion-settings-input
:label="$t('Panels.MachineSettingsPanel.MotionSettings.Velocity')"
:target="current_velocity"
Expand All @@ -11,7 +11,7 @@
attribute-name="VELOCITY"
></motion-settings-input>
</v-col>
<v-col class="col-12 col-sm-6">
<v-col class="col-12 col-md-6">
<motion-settings-input
:label="$t('Panels.MachineSettingsPanel.MotionSettings.SquareCornerVelocity')"
:target="current_square_corner_velocity"
Expand All @@ -23,7 +23,7 @@
</v-col>
</v-row>
<v-row>
<v-col class="col-12 col-sm-6">
<v-col class="col-12 col-md-6">
<motion-settings-input
:label="$t('Panels.MachineSettingsPanel.MotionSettings.Acceleration')"
:target="current_accel"
Expand All @@ -33,7 +33,7 @@
attribute-name="ACCEL"
></motion-settings-input>
</v-col>
<v-col class="col-12 col-sm-6">
<v-col class="col-12 col-md-6">
<motion-settings-input
:label="$t('Panels.MachineSettingsPanel.MotionSettings.Deceleration')"
:target="current_accel_to_decel"
Expand Down
101 changes: 101 additions & 0 deletions src/components/panels/MachineSettings/PressureAdvanceSettings.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<template>
<v-card-text>
<v-row>
<v-col v-if="this.all_extruders.length > 1" class="col-12 col-xl-4">
<div class="d-flex align-center">
<v-btn
v-if="this.selectedExtruder !== this.current_active_extruder"
@click="resetToActiveExtruder"
class="mr-2"
icon
plain
><v-icon>mdi-restart</v-icon>
</v-btn>
<v-select
v-model="selectedExtruder"
:label="$t('Panels.MachineSettingsPanel.PressureAdvanceSettings.Extruder')"
:items="all_extruders"
:value="current_active_extruder"
hide-details
outlined
dense
></v-select>
</div>
</v-col>
<v-col :class="(this.all_extruders.length > 1) ? 'col-12 col-md-6 col-xl-4' : 'col-12 col-md-6'">
<pressure-advance-settings-input
:label="$t('Panels.MachineSettingsPanel.PressureAdvanceSettings.Advance')"
:target="current_pressure_advance"
:step="0.001"
:max="1"
:default-value="config_pressure_advance"
:extruder="selectedExtruder"
unit="mm/s"
attribute-name="ADVANCE"
></pressure-advance-settings-input>
</v-col>
<v-col :class="(this.all_extruders.length > 1) ? 'col-12 col-md-6 col-xl-4' : 'col-12 col-md-6'">
<pressure-advance-settings-input
:label="$t('Panels.MachineSettingsPanel.PressureAdvanceSettings.SmoothTime')"
:target="current_smooth_time"
:step="0.01"
:max="0.2"
:default-value="config_smooth_time"
:extruder="selectedExtruder"
unit="s"
attribute-name="SMOOTH_TIME"
></pressure-advance-settings-input>
</v-col>
</v-row>
</v-card-text>
</template>

<script lang="ts">
import { Component, Mixins } from 'vue-property-decorator'
import BaseMixin from '@/components/mixins/base'
import Panel from '@/components/ui/Panel.vue'
import PressureAdvanceSettingsInput from '@/components/inputs/PressureAdvanceSettingsInput.vue'
@Component({
components: {Panel, PressureAdvanceSettingsInput}
})
export default class PressureAdvanceSettings extends Mixins(BaseMixin) {
private extruders: string[] = []
private selectedExtruder = ''
resetToActiveExtruder(): void {
this.selectedExtruder = this.$store.state.printer.toolhead?.extruder
}
get all_extruders(): string[] {
Object.keys(this.$store.state.printer).forEach((e) => {
(e.match(/^(extruder)\d*$/)) ? this.extruders.push(e) : {}
})
this.extruders.length === 1 ? this.resetToActiveExtruder() : {}
return this.extruders
}
get current_active_extruder(): string {
this.resetToActiveExtruder()
return this.$store.state.printer.toolhead?.extruder
}
get current_pressure_advance(): number {
return this.$store.state.printer?.[this.selectedExtruder]?.pressure_advance ?? 0
}
get current_smooth_time(): number {
return this.$store.state.printer?.[this.selectedExtruder]?.smooth_time ?? 0.04
}
get config_pressure_advance(): number {
return this.$store.state.printer.configfile?.settings?.[this.selectedExtruder]?.pressure_advance ?? 0
}
get config_smooth_time(): number {
return this.$store.state.printer.configfile?.settings?.[this.selectedExtruder]?.pressure_advance_smooth_time ?? 0.04
}
}
</script>
9 changes: 6 additions & 3 deletions src/components/panels/PrintsettingsPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,16 @@
</template>

<script lang="ts">
import {Component, Mixins} from 'vue-property-decorator'
import BaseMixin from '@/components/mixins/base'
import ToolSlider from '@/components/inputs/ToolSlider.vue'
import Panel from '@/components/ui/Panel.vue'
import ToolSlider from '@/components/inputs/ToolSlider.vue'
@Component({
components: {Panel, ToolSlider}
components: {
Panel,
ToolSlider
}
})
export default class PrintsettingsPanel extends Mixins(BaseMixin) {
Expand Down
6 changes: 6 additions & 0 deletions src/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,12 @@
"Deceleration": "Verlangsamung",
"SquareCornerVelocity": "Eck-Geschwindigkeit"
},
"PressureAdvanceSettings": {
"PressureAdvance": "Pressure Advance",
"Extruder": "Extruder",
"Advance": "Advance",
"SmoothTime": "Smooth Time"
},
"FirmwareRetractionSettings": {
"FirmwareRetraction": "Firmware Rückzug",
"RetractLength": "Rückzugslänge",
Expand Down
6 changes: 6 additions & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,12 @@
"Deceleration": "Deceleration",
"SquareCornerVelocity": "Square Corner Velocity"
},
"PressureAdvanceSettings": {
"PressureAdvance": "Pressure Advance",
"Extruder": "Extruder",
"Advance": "Advance",
"SmoothTime": "Smooth Time"
},
"FirmwareRetractionSettings": {
"FirmwareRetraction": "Firmware Retraction",
"RetractLength": "Retract Length",
Expand Down

0 comments on commit 5e88cdc

Please sign in to comment.