Skip to content

Commit

Permalink
Merge branch 'develop' into release/v2.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
meteyou committed Jan 18, 2022
2 parents 28a6f5a + 595c937 commit c5aaa2f
Show file tree
Hide file tree
Showing 7 changed files with 130 additions and 61 deletions.
31 changes: 24 additions & 7 deletions src/components/inputs/FirmwareRetractionSettingsInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
@click:append="resetLimit"
:label="label"
:suffix="unit"
:append-icon="this.value !== this.defaultValue ? 'mdi-restart' : ''"
:error="(this.value < this.min) || ((this.value > this.max) && this.max !== null)"
:append-icon="value !== defaultValue ? 'mdi-restart' : ''"
:error="error = ((value < min) || ((value > max) && max !== null))"
:step="step"
:min="min"
:max="max"
Expand All @@ -25,10 +25,24 @@
outlined
dense
>
<template v-slot:append-outer>
<template v-if="hasSpinner" v-slot:append-outer>
<div class="_spin_button_group">
<v-btn @click="increment" class="mt-n3" icon plain small><v-icon>mdi-chevron-up</v-icon></v-btn>
<v-btn @click="decrement" class="mb-n3" icon plain small><v-icon>mdi-chevron-down</v-icon></v-btn>
<v-btn
@click="increment"
:disabled="((value >= max) && max !== null) || error"
class="mt-n3"
icon plain small
>
<v-icon>mdi-chevron-up</v-icon>
</v-btn>
<v-btn
@click="decrement"
:disabled="(value <= min) || error"
class="mb-n3"
icon plain small
>
<v-icon>mdi-chevron-down</v-icon>
</v-btn>
</div>
</template>
</v-text-field>
Expand All @@ -44,9 +58,12 @@ import BaseMixin from '@/components/mixins/base'
@Component
export default class FirmwareRetractionSettingsInput extends Mixins(BaseMixin) {
private value: number = 0
private error: boolean | undefined
@Prop({ type: String, required: true }) readonly label!: string
@Prop({ type: Number, required: false , default: 1 }) readonly step!: number
@Prop({ type: Boolean, required: false , default: false }) readonly hasSpinner!: number
@Prop({ type: Number, required: false , default: 1 }) readonly spinnerFactor!: number
@Prop({ type: Number, required: true , default: 0 }) readonly min!: number
@Prop({ type: Number, default: null }) readonly max!: number | null
@Prop({ type: Number, required: true , default: 0 }) readonly dec!: number
Expand All @@ -71,12 +88,12 @@ export default class FirmwareRetractionSettingsInput extends Mixins(BaseMixin) {
}
decrement(): void {
this.value = (this.value > this.min) ? Math.round((this.value - this.step) * (10 ** this.dec)) / (10 ** this.dec) : this.min
this.value = (this.value > this.min) ? Math.round((this.value - this.step * this.spinnerFactor) * (10 ** this.dec)) / (10 ** this.dec) : this.min
this.sendCmd()
}
increment(): void {
this.value = (this.value < this.max! || this.max === null) ? Math.round((this.value + this.step) * (10 ** this.dec)) / (10 ** this.dec) : this.max
this.value = (this.value < this.max! || this.max === null) ? Math.round((this.value + this.step * this.spinnerFactor) * (10 ** this.dec)) / (10 ** this.dec) : this.max
this.sendCmd()
}
Expand Down
31 changes: 24 additions & 7 deletions src/components/inputs/MotionSettingsInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
@click:append="resetLimit"
:label="label"
:suffix="unit"
:append-icon="this.value !== this.defaultValue ? 'mdi-restart' : ''"
:error="(this.value < this.min) || ((this.value > this.max) && this.max !== null)"
:append-icon="value !== defaultValue ? 'mdi-restart' : ''"
:error="error = ((value < min) || ((value > max) && max !== null))"
:step="step"
:min="min"
:max="max"
Expand All @@ -25,10 +25,24 @@
outlined
dense
>
<template v-slot:append-outer>
<template v-if="hasSpinner" v-slot:append-outer>
<div class="_spin_button_group">
<v-btn @click="increment" class="mt-n3" icon plain small><v-icon>mdi-chevron-up</v-icon></v-btn>
<v-btn @click="decrement" class="mb-n3" icon plain small><v-icon>mdi-chevron-down</v-icon></v-btn>
<v-btn
@click="increment"
:disabled="((value >= max) && max !== null) || error"
class="mt-n3"
icon plain small
>
<v-icon>mdi-chevron-up</v-icon>
</v-btn>
<v-btn
@click="decrement"
:disabled="(value <= min) || error"
class="mb-n3"
icon plain small
>
<v-icon>mdi-chevron-down</v-icon>
</v-btn>
</div>
</template>
</v-text-field>
Expand All @@ -44,9 +58,12 @@ import BaseMixin from '@/components/mixins/base'
@Component
export default class MotionSettingsInput extends Mixins(BaseMixin) {
private value: number = 0
private error: boolean | undefined
@Prop({ type: String, required: true }) readonly label!: string
@Prop({ type: Number, required: false , default: 1 }) readonly step!: number
@Prop({ type: Boolean, required: false , default: false }) readonly hasSpinner!: number
@Prop({ type: Number, required: false , default: 1 }) readonly spinnerFactor!: number
@Prop({ type: Number, required: true , default: 0 }) readonly min!: number
@Prop({ type: Number, default: null }) readonly max!: number | null
@Prop({ type: Number, required: true , default: 0 }) readonly dec!: number
Expand All @@ -71,12 +88,12 @@ export default class MotionSettingsInput extends Mixins(BaseMixin) {
}
decrement(): void {
this.value = (this.value > this.min) ? Math.round((this.value - this.step) * (10 ** this.dec)) / (10 ** this.dec) : this.min
this.value = (this.value > this.min) ? Math.round((this.value - this.step * this.spinnerFactor) * (10 ** this.dec)) / (10 ** this.dec) : this.min
this.sendCmd()
}
increment(): void {
this.value = (this.value < this.max! || this.max === null) ? Math.round((this.value + this.step) * (10 ** this.dec)) / (10 ** this.dec) : this.max
this.value = (this.value < this.max! || this.max === null) ? Math.round((this.value + this.step * this.spinnerFactor) * (10 ** this.dec)) / (10 ** this.dec) : this.max
this.sendCmd()
}
Expand Down
31 changes: 24 additions & 7 deletions src/components/inputs/PressureAdvanceSettingsInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
@click:append="resetLimit"
:label="label"
:suffix="unit"
:append-icon="this.value !== this.defaultValue ? 'mdi-restart' : ''"
:error="(this.value < this.min) || ((this.value > this.max) && this.max !== null)"
:append-icon="value !== defaultValue ? 'mdi-restart' : ''"
:error="error = ((value < min) || ((value > max) && max !== null))"
:step="step"
:min="min"
:max="max"
Expand All @@ -25,10 +25,24 @@
outlined
dense
>
<template v-slot:append-outer>
<template v-if="hasSpinner" v-slot:append-outer>
<div class="_spin_button_group">
<v-btn @click="increment" class="mt-n3" icon plain small><v-icon>mdi-chevron-up</v-icon></v-btn>
<v-btn @click="decrement" class="mb-n3" icon plain small><v-icon>mdi-chevron-down</v-icon></v-btn>
<v-btn
@click="increment"
:disabled="((value >= max) && max !== null) || error"
class="mt-n3"
icon plain small
>
<v-icon>mdi-chevron-up</v-icon>
</v-btn>
<v-btn
@click="decrement"
:disabled="(value <= min) || error"
class="mb-n3"
icon plain small
>
<v-icon>mdi-chevron-down</v-icon>
</v-btn>
</div>
</template>
</v-text-field>
Expand All @@ -44,9 +58,12 @@ import BaseMixin from '@/components/mixins/base'
@Component
export default class PressureAdvanceSettingsInput extends Mixins(BaseMixin) {
private value: number = 0
private error: boolean | undefined
@Prop({ type: String, required: true }) readonly label!: string
@Prop({ type: Number, required: false , default: 1 }) readonly step!: number
@Prop({ type: Boolean, required: false , default: false }) readonly hasSpinner!: number
@Prop({ type: Number, required: false , default: 1 }) readonly spinnerFactor!: number
@Prop({ type: Number, required: true , default: 0 }) readonly min!: number
@Prop({ type: Number, default: null }) readonly max!: number | null
@Prop({ type: Number, required: true , default: 0 }) readonly dec!: number
Expand All @@ -72,12 +89,12 @@ export default class PressureAdvanceSettingsInput extends Mixins(BaseMixin) {
}
decrement(): void {
this.value = (this.value > this.min) ? Math.round((this.value - this.step) * (10 ** this.dec)) / (10 ** this.dec) : this.min
this.value = (this.value > this.min) ? Math.round((this.value - this.step * this.spinnerFactor) * (10 ** this.dec)) / (10 ** this.dec) : this.min
this.sendCmd()
}
increment(): void {
this.value = (this.value < this.max! || this.max === null) ? Math.round((this.value + this.step) * (10 ** this.dec)) / (10 ** this.dec) : this.max
this.value = (this.value < this.max! || this.max === null) ? Math.round((this.value + this.step * this.spinnerFactor) * (10 ** this.dec)) / (10 ** this.dec) : this.max
this.sendCmd()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
<v-row>
<v-col class="col-12 col-md-6">
<firmware-retraction-settings-input
:label="$t('Panels.MachineSettingsPanel.FirmwareRetractionSettings.RetractLength')"
:label="$t('Panels.MachineSettingsPanel.FirmwareRetractionSettings.RetractLength').toString()"
:target="current_retract_length"
:default-value="config_retract_length"
:hasSpinner="true"
:spinnerFactor="10"
:step="0.01"
:min="0"
:max="null"
Expand All @@ -16,9 +18,11 @@
</v-col>
<v-col class="col-12 col-md-6">
<firmware-retraction-settings-input
:label="$t('Panels.MachineSettingsPanel.FirmwareRetractionSettings.RetractSpeed')"
:label="$t('Panels.MachineSettingsPanel.FirmwareRetractionSettings.RetractSpeed').toString()"
:target="current_retract_speed"
:default-value="config_retract_speed"
:hasSpinner="true"
:spinnerFactor="5"
:step="1"
:min="1"
:max="null"
Expand All @@ -31,9 +35,11 @@
<v-row>
<v-col class="col-12 col-md-6">
<firmware-retraction-settings-input
:label="$t('Panels.MachineSettingsPanel.FirmwareRetractionSettings.UnretractExtraLength')"
:label="$t('Panels.MachineSettingsPanel.FirmwareRetractionSettings.UnretractExtraLength').toString()"
:target="current_unretract_extra_length"
:default-value="config_unretract_extra_length"
:hasSpinner="true"
:spinnerFactor="10"
:step="0.01"
:min="0"
:max="null"
Expand All @@ -44,9 +50,11 @@
</v-col>
<v-col class="col-12 col-md-6">
<firmware-retraction-settings-input
:label="$t('Panels.MachineSettingsPanel.FirmwareRetractionSettings.UnretractSpeed')"
:label="$t('Panels.MachineSettingsPanel.FirmwareRetractionSettings.UnretractSpeed').toString()"
:target="current_unretract_speed"
:default-value="config_unretract_speed"
:hasSpinner="true"
:spinnerFactor="5"
:step="1"
:min="1"
:max="null"
Expand All @@ -71,35 +79,35 @@ import FirmwareRetractionSettingsInput from '@/components/inputs/FirmwareRetract
export default class FirmwareRetractionSettings extends Mixins(BaseMixin) {
get current_retract_length(): number {
return this.$store.state.printer?.firmware_retraction?.retract_length ?? 0
return Math.floor((this.$store.state.printer?.firmware_retraction?.retract_length ?? 0) * 100) / 100
}
get current_retract_speed(): number {
return this.$store.state.printer?.firmware_retraction?.retract_speed ?? 20
return Math.trunc(this.$store.state.printer?.firmware_retraction?.retract_speed ?? 20)
}
get current_unretract_extra_length(): number {
return this.$store.state.printer?.firmware_retraction?.unretract_extra_length ?? 0
return Math.floor((this.$store.state.printer?.firmware_retraction?.unretract_extra_length ?? 0) * 100) / 100
}
get current_unretract_speed(): number {
return this.$store.state.printer?.firmware_retraction?.unretract_speed ?? 10
return Math.trunc(this.$store.state.printer?.firmware_retraction?.unretract_speed ?? 10)
}
get config_retract_length(): number {
return this.$store.state.printer?.configfile?.settings?.firmware_retraction?.retract_length ?? 0
return Math.floor((this.$store.state.printer?.configfile?.settings?.firmware_retraction?.retract_length ?? 0) * 100) / 100
}
get config_retract_speed(): number {
return this.$store.state.printer?.configfile?.settings?.firmware_retraction?.retract_speed ?? 20
return Math.trunc(this.$store.state.printer?.configfile?.settings?.firmware_retraction?.retract_speed ?? 20)
}
get config_unretract_extra_length(): number {
return this.$store.state.printer?.configfile?.settings?.firmware_retraction?.unretract_extra_length ?? 0
return Math.floor((this.$store.state.printer?.configfile?.settings?.firmware_retraction?.unretract_extra_length ?? 0) * 100) / 100
}
get config_unretract_speed(): number {
return this.$store.state.printer?.configfile?.settings?.firmware_retraction?.unretract_speed ?? 10
return Math.trunc(this.$store.state.printer?.configfile?.settings?.firmware_retraction?.unretract_speed ?? 0)
}
}
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@
<panel
v-if="klipperReadyForGui"
icon="mdi-engine"
:title="$t('Panels.MachineSettingsPanel.Headline')"
:title="$t('Panels.MachineSettingsPanel.Headline').toString()"
:collapsible="true"
card-class="machine-settings-panel"
>
<div>
<sub-panel
:title="$t('Panels.MachineSettingsPanel.MotionSettings.Motion')"
:title="$t('Panels.MachineSettingsPanel.MotionSettings.Motion').toString()"
sub-panel-class="motion-settings-subpanel"
>
<motion-settings></motion-settings>
</sub-panel>
<sub-panel
:title="$t('Panels.MachineSettingsPanel.PressureAdvanceSettings.PressureAdvance')"
:title="$t('Panels.MachineSettingsPanel.PressureAdvanceSettings.PressureAdvance').toString()"
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')"
:title="$t('Panels.MachineSettingsPanel.FirmwareRetractionSettings.FirmwareRetraction').toString()"
sub-panel-class="firmware-retraction-settings-subpanel"
>
<firmware-retraction-settings></firmware-retraction-settings>
Expand Down
Loading

0 comments on commit c5aaa2f

Please sign in to comment.