Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adds extrusion estimations #950

Merged
merged 6 commits into from
Nov 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ declare module 'vue' {
VExpansionPanelContent: typeof import('vuetify/lib')['VExpansionPanelContent']
VExpansionPanelHeader: typeof import('vuetify/lib')['VExpansionPanelHeader']
VExpansionPanels: typeof import('vuetify/lib')['VExpansionPanels']
VFadeTransition: typeof import('vuetify/lib')['VFadeTransition']
VFooter: typeof import('vuetify/lib')['VFooter']
VForm: typeof import('vuetify/lib')['VForm']
VIcon: typeof import('vuetify/lib')['VIcon']
Expand Down
1 change: 1 addition & 0 deletions src/components/widgets/toolhead/ExtruderSelection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
v-model="extruder"
:items="extruders"
:readonly="printerPrinting"
:disabled="!klippyReady"
item-value="key"
item-text="name"
hide-details
Expand Down
128 changes: 128 additions & 0 deletions src/components/widgets/toolhead/ExtruderStats.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
<template>
<div>
<v-divider />
<v-expansion-panels
accordion
multiple
flat
>
<v-expansion-panel>
<v-expansion-panel-header>
<template #default="{ open }">
<v-row no-gutters>
<v-col
class="text--secondary text-center"
:class="{ 'text--disabled': !klippyReady }"
>
<v-fade-transition>
<span v-if="!open">~ {{ estimatedExtrudedLength }} mm @ {{ estimatedVolumetricFlow }} mm³/s, {{ estimatedMaxSpeed }} mm/s</span>
</v-fade-transition>
</v-col>
</v-row>
</template>
</v-expansion-panel-header>
<v-expansion-panel-content>
<div
class="text-center"
:class="{ 'text--disabled': !klippyReady }"
>
<p
v-html="$t('app.tool.label.stats_active_extruder', {
filamentDiameter,
nozzleDiameter
})"
/>
<p
v-html="$t('app.tool.label.stats_volumetric_flow', {
extrudeSpeed,
estimatedVolumetricFlow
})"
/>
<p
v-html="$t('app.tool.label.stats_extruded_length', {
extrudeLength,
extrudeFactor: (extrudeFactor * 100).toFixed(),
estimatedExtrudedLength
})"
/>
<p
v-html="$t('app.tool.label.stats_max_speed', {
layerHeight,
estimatedMaxSpeed
})"
/>
</div>
</v-expansion-panel-content>
</v-expansion-panel>
</v-expansion-panels>
<v-divider />
</div>
</template>

<script lang="ts">
import { Component, Mixins } from 'vue-property-decorator'
import StateMixin from '@/mixins/state'
import ToolheadMixin from '@/mixins/toolhead'

@Component({})
export default class ExtruderMoves extends Mixins(StateMixin, ToolheadMixin) {
get maxExtrudeLength (): number {
return this.activeExtruder?.max_extrude_only_distance || 50
}

get filamentDiameter (): number {
return this.activeExtruder?.filament_diameter || 1.75
}

get nozzleDiameter (): number {
return this.activeExtruder?.nozzle_diameter || 0.4
}

get extrudeFactor (): number {
return this.$store.state.printer.printer.gcode_move.extrude_factor || 1
}

get layerHeight (): number {
return 0.2
}

get extrudeLength (): number {
const extrudeLength = this.$store.state.config.uiSettings.toolhead.extrudeLength

if (isNaN(+extrudeLength)) return 0

return extrudeLength === -1
? this.$store.state.config.uiSettings.general.defaultExtrudeLength
: extrudeLength
}

get extrudeSpeed (): number {
const extrudeSpeed = this.$store.state.config.uiSettings.toolhead.extrudeSpeed

if (isNaN(+extrudeSpeed)) return 0

return extrudeSpeed === -1
? this.$store.state.config.uiSettings.general.defaultExtrudeSpeed
: extrudeSpeed
}

get estimatedExtrudedLength (): number {
return Math.round(this.extrudeLength * this.extrudeFactor * (this.filamentDiameter ** 2 / this.nozzleDiameter ** 2) * 10) / 10
}

get estimatedVolumetricFlow (): number {
return Math.round(Math.PI / 4 * this.filamentDiameter ** 2 * this.extrudeSpeed * 10) / 10
}

get estimatedMaxSpeed (): number {
return Math.round(this.estimatedVolumetricFlow / this.nozzleDiameter / this.layerHeight * 10) / 10
}
}
</script>

<style type="scss" scoped>
:deep(.v-expansion-panel-header) {
padding-left: 0px;
padding-right: 0px;
}
</style>
8 changes: 6 additions & 2 deletions src/components/widgets/toolhead/Toolhead.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@
<extruder-moves v-if="!printerPrinting" />
<z-height-adjust v-if="!printerPrinting" />
</v-col>
<v-col cols="12">
<extruder-stats />
</v-col>
</v-row>

<!-- Speed and Flow Adjustments -->
<speed-and-flow-adjust />
<pressure-advance-adjust v-if="showPressureAdvance" />
</v-card-text>
Expand All @@ -34,6 +36,7 @@ import ToolheadPosition from '@/components/widgets/toolhead/ToolheadPosition.vue
import ZHeightAdjust from '@/components/widgets/toolhead/ZHeightAdjust.vue'
import SpeedAndFlowAdjust from '@/components/widgets/toolhead/SpeedAndFlowAdjust.vue'
import PressureAdvanceAdjust from '@/components/widgets/toolhead/PressureAdvanceAdjust.vue'
import ExtruderStats from '@/components/widgets/toolhead/ExtruderStats.vue'

@Component({
components: {
Expand All @@ -43,7 +46,8 @@ import PressureAdvanceAdjust from '@/components/widgets/toolhead/PressureAdvance
ToolheadPosition,
ZHeightAdjust,
SpeedAndFlowAdjust,
PressureAdvanceAdjust
PressureAdvanceAdjust,
ExtruderStats
}
})
export default class Toolhead extends Mixins(StateMixin) {
Expand Down
19 changes: 19 additions & 0 deletions src/locales/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,25 @@ app:
screws_tilt_calculate: Screws_Tilt_Calculate
bed_screws_adjust: BED_SCREWS_ADJUST
force_move: FORCE_MOVE
label:
stats_active_extruder: >-
<span class="secondary--text">The active extruder configuration is set for</span>
%{filamentDiameter} mm diameter filament
<span class="secondary--text">and</span>
%{nozzleDiameter} mm nozzle
stats_volumetric_flow: >-
Extruding at %{extrudeSpeed} mm/s
<span class="secondary--text">, the extruder should be able to provide an</span>
estimated volumetric flow of %{estimatedVolumetricFlow} mm³/s
stats_extruded_length: >-
Extruding %{extrudeLength} mm of filament at %{extrudeFactor} % flow
<span class="secondary--text">, will provide an</span>
estimated output length of %{estimatedExtrudedLength} mm
stats_max_speed: >-
<span class="secondary--text">Assuming a</span>
%{layerHeight} mm layer height
<span class="secondary--text">, the </span>
estimated maximum print speed is %{estimatedMaxSpeed} mm/s
version:
btn:
check_for_updates: Check for updates
Expand Down