forked from mainsail-crew/mainsail
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: pressure advance settings on dashboard (mainsail-crew#459)
* 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
Showing
10 changed files
with
204 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
src/components/panels/MachineSettings/PressureAdvanceSettings.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters