Skip to content

Commit

Permalink
feat: add machine limits card (currently disabled..)
Browse files Browse the repository at this point in the history
  • Loading branch information
cadriel committed Oct 15, 2020
1 parent 2b2b368 commit b03fe61
Show file tree
Hide file tree
Showing 15 changed files with 264 additions and 73 deletions.
47 changes: 36 additions & 11 deletions src/components/inputs/InputSlider.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
<div>
<div class="d-flex justify-start">
<div class="grey--text text--darken-1 align-self-end">{{ label }}</div>
<div class="grey--text text-h5 ml-auto" :class="{ 'text--darken-2': disabled, 'text--lighten-1': !disabled }">{{ newValue.toFixed() }}%</div>
<div class="grey--text text-h5 ml-auto" :class="{ 'text--darken-2': disabled, 'text--lighten-1': !disabled }">{{ newValue.toFixed() }}<small>{{valueSuffix}}</small></div>
</div>
<v-slider
@change="emitChange(newValue)"
@click="emitChange(newValue)"
@input="updateValue"
:value="value"
@update:error="updateError"
:value="newValue"
:rules="rules"
:min="min"
:max="max"
:readonly="readonly"
Expand All @@ -19,8 +21,11 @@
>
<template v-slot:prepend>
<v-btn
:disabled="readonly || disabled"
@click="emitChange(newValue - 1)"
:disabled="
readonly ||
disabled ||
newValue === 0"
@click="clickChange(newValue - 1)"
:min-width="40"
class="pa-0"
small
Expand All @@ -33,8 +38,8 @@

<template v-slot:append>
<v-btn
:disabled="readonly || disabled"
@click="emitChange(newValue + 1)"
:disabled="readonly || disabled || newValue === max"
@click="clickChange(newValue + 1)"
:min-width="40"
class="pa-0"
small
Expand All @@ -51,12 +56,16 @@
<script lang="ts">
import { Component, Prop, Watch, Mixins } from 'vue-property-decorator'
import UtilsMixin from '@/mixins/utils'
import { InputValidationRules } from 'vuetify'
@Component({})
export default class InputSlider extends Mixins(UtilsMixin) {
@Prop({ type: Number, required: true })
public value!: number
@Prop({ required: false })
public rules!: InputValidationRules
@Prop({ type: String, required: true })
public label!: string
Expand All @@ -75,21 +84,37 @@ export default class InputSlider extends Mixins(UtilsMixin) {
@Prop({ type: Number, default: 100 })
public max!: number;
@Prop({ type: String, required: false })
public valueSuffix!: string;
@Watch('value')
onValueChange (val: number) {
this.newValue = val
}
newValue = 0;
newValue = 0
error = false
updateValue (e: string) {
this.newValue = parseInt(e)
updateValue (e: number) {
this.newValue = e
}
emitChange (val: number) {
clickChange (val: number) {
this.$emit('input', val)
}
emitChange (val: number) {
if (!this.error) {
this.$emit('input', val)
} else {
this.newValue = this.value
}
}
updateError (val: boolean) {
this.error = val
}
mounted () {
this.newValue = this.value
}
Expand Down
19 changes: 17 additions & 2 deletions src/components/widgets/FansWidget.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<template>
<v-row>
<!-- Fans -->
<v-col class="pa-2 pt-4 pb-0">
<v-col class="px-2 pt-0 pb-5">
<input-slider
label="Part Fan"
value-suffix="%"
:value="partFanSpeed"
:rules="rules"
:disabled="!klippyConnected"
@input="setPartFanSpeed($event)"
:readonly="printerPrinting">
Expand All @@ -17,6 +19,7 @@
import { Component, Mixins } from 'vue-property-decorator'
import InputSlider from '@/components/inputs/InputSlider.vue'
import UtilsMixin from '@/mixins/utils'
import { Waits } from '@/globals'
@Component({
components: {
Expand All @@ -28,9 +31,21 @@ export default class FansWidget extends Mixins(UtilsMixin) {
return this.$store.state.socket.printer.fan.speed * 100
}
get offBelow () {
const offBelow = parseFloat(this.$store.state.socket.printer.configfile.config.fan.off_below) || 0
return offBelow * 100
}
rules = [
(v: number) => {
if (this.offBelow <= 0) return true
return (v >= this.offBelow || v === 0) || 'min error'
}
]
setPartFanSpeed (target: number) {
target = Math.ceil(target * 2.55)
this.sendGcode(`M106 S${target}`)
this.sendGcode(`M106 S${target}`, Waits.onSetFanSpeed)
}
}
</script>
Expand Down
140 changes: 140 additions & 0 deletions src/components/widgets/PrinterLimitsWidget.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
<template>
<v-expansion-panels flat>
<v-expansion-panel>
<v-expansion-panel-header>Acceleration, Velocity &amp; Limits</v-expansion-panel-header>
<v-expansion-panel-content>
<!-- <v-col>
Velocity Limits
These are not persistent. They will reset to your printer configuration on host reboot.
<v-divider></v-divider>
</v-col> -->
<!-- Speed and Flow Adjust -->
<v-row>
<v-col cols="12" sm="6" class="px-2 pt-0 pb-5">
<input-slider
label="Velocity"
value-suffix="mm/s"
:value="velocity.current"
:min="0"
:max="velocity.max"
:disabled="!klippyConnected"
:loading="hasWait(waits.onSetVelocity)"
@input="setVelocity($event)">
</input-slider>
</v-col>
<v-col cols="12" sm="6" class="px-2 pt-0 pb-5">
<input-slider
label="Square Corner Velocity"
value-suffix="mm/s"
:value="scv.current"
:min="0"
:max="scv.max"
:disabled="!klippyConnected"
:loading="hasWait(waits.onSetSQV)"
@input="setSCV($event)">
</input-slider>
</v-col>
</v-row>
<v-row>
<v-col cols="12" sm="6" class="px-2 py-0">
<input-slider
label="Acceleration"
value-suffix="mm/s^2"
:value="accel.current"
:min="0"
:max="accel.max"
:disabled="!klippyConnected"
:loading="hasWait(waits.onSetAcceleration)"
@input="setAcceleration($event)">
</input-slider>
</v-col>
<v-col cols="12" sm="6" class="px-2 py-0">
<input-slider
label="Deceleration"
value-suffix="mm/s^2"
:value="decel.current"
:min="0"
:max="decel.max"
:disabled="!klippyConnected"
:loading="hasWait(waits.onSetDeceleration)"
@input="setDeceleration($event)">
</input-slider>
</v-col>
</v-row>
</v-expansion-panel-content>
</v-expansion-panel>
</v-expansion-panels>
</template>

<script lang="ts">
import { Component, Mixins } from 'vue-property-decorator'
import UtilsMixin from '@/mixins/utils'
import { Waits } from '@/globals'
import InputSlider from '@/components/inputs/InputSlider.vue'
@Component({
components: {
InputSlider
}
})
export default class PrinterLimitsWidget extends Mixins(UtilsMixin) {
waits = Waits
get velocity () {
const max = parseInt(this.$store.state.socket.printer.configfile.config.printer.max_velocity)
return {
current: this.$store.state.socket.printer.toolhead.max_velocity,
max
}
}
get accel () {
const max = parseInt(this.$store.state.socket.printer.configfile.config.printer.max_accel)
return {
current: this.$store.state.socket.printer.toolhead.max_accel,
max
}
}
get decel () {
const max = parseFloat(this.$store.state.socket.printer.configfile.config.printer.max_accel_to_decel) || this.accel.max / 2 // klippers default is half of accel
return {
current: this.$store.state.socket.printer.toolhead.max_accel_to_decel,
max
}
}
get scv () {
const max = parseInt(this.$store.state.socket.printer.configfile.config.printer.square_corner_velocity) || 5 // klippers default is 5.
return {
current: this.$store.state.socket.printer.toolhead.square_corner_velocity,
max
}
}
setVelocity (val: number) {
this.sendGcode(`SET_VELOCITY_LIMIT VELOCITY=${val}`, Waits.onSetVelocity)
}
setAcceleration (val: number) {
this.sendGcode(`SET_VELOCITY_LIMIT ACCEL=${val}`, Waits.onSetAcceleration)
}
setDeceleration (val: number) {
this.sendGcode(`SET_VELOCITY_LIMIT ACCEL_TO_DECEL=${val}`, Waits.onSetDeceleration)
}
setSCV (val: number) {
this.sendGcode(`SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY=${val}`, Waits.onSetSCV)
}
/**
* SET_VELOCITY_LIMIT
* [VELOCITY=<value>]
* [ACCEL=<value>]
* [ACCEL_TO_DECEL=<value>]
* [SQUARE_CORNER_VELOCITY=<value>]:
* Modify the printer's velocity limits. Note that one may only set values less than or equal to the limits specified in the config file.
*/
}
</script>
12 changes: 6 additions & 6 deletions src/components/widgets/SpeedAndFlowAdjustWidget.vue
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
<template>
<v-row>
<!-- Speed and Flow Adjust -->
<v-col cols="12" sm="6" class="pa-2 pt-0">
<v-col cols="12" sm="6" class="px-2 pt-0 pb-5">
<input-slider
label="Speed"
:value="speed"
value-suffix="%"
:disabled="!klippyConnected"
:loading="hasWait(waits.onSetSpeed)"
:min="0"
:max="200"
@input="setSpeed($event, waits.onSetSpeed)"
v-if="printerPrinting">
@input="setSpeed($event, waits.onSetSpeed)">
</input-slider>
</v-col>
<v-col cols="12" sm="6" class="pa-2 pt-0">
<v-col cols="12" sm="6" class="px-2 pt-0 pb-5">
<input-slider
label="Flow"
:value="flow"
value-suffix="%"
:disabled="!klippyConnected"
:loading="hasWait(waits.onSetFlow)"
:min="0"
:max="200"
@input="setFlow($event, waits.onSetFlow)"
v-if="printerPrinting">
@input="setFlow($event, waits.onSetFlow)">
</input-slider>
</v-col>
</v-row>
Expand Down
5 changes: 4 additions & 1 deletion src/components/widgets/ToolheadWidget.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<fans-widget></fans-widget>
<!-- Speed and Flow Adjustments -->
<speed-and-flow-adjust-widget></speed-and-flow-adjust-widget>
<!-- <printer-limits-widget></printer-limits-widget> -->
</v-col>
</v-row>
</v-container>
Expand All @@ -36,6 +37,7 @@ import ToolheadPositionWidget from '@/components/widgets/ToolheadPositionWidget.
import ZHeightAdjustWidget from '@/components/widgets/ZHeightAdjustWidget.vue'
import SpeedAndFlowAdjustWidget from '@/components/widgets/SpeedAndFlowAdjustWidget.vue'
import FansWidget from '@/components/widgets/FansWidget.vue'
import PrinterLimitsWidget from '@/components/widgets/PrinterLimitsWidget.vue'
@Component({
components: {
Expand All @@ -44,7 +46,8 @@ import FansWidget from '@/components/widgets/FansWidget.vue'
ToolheadPositionWidget,
ZHeightAdjustWidget,
SpeedAndFlowAdjustWidget,
FansWidget
FansWidget,
PrinterLimitsWidget
}
})
export default class ToolheadWidget extends Mixins(UtilsMixin) {}
Expand Down
22 changes: 0 additions & 22 deletions src/components/widgets/configuration/PrinterLimitsWidget.vue

This file was deleted.

Loading

0 comments on commit b03fe61

Please sign in to comment.