Skip to content

Commit

Permalink
feat: print progress estimation improvements (#1414)
Browse files Browse the repository at this point in the history
Signed-off-by: Pedro Lamas <pedrolamas@gmail.com>
  • Loading branch information
pedrolamas committed Apr 13, 2024
1 parent 6930a24 commit 8ad71bc
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 12 deletions.
10 changes: 9 additions & 1 deletion src/components/settings/GeneralSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -464,11 +464,19 @@ export default class GeneralSettings extends Mixins(StateMixin) {
return [
{
value: 'file',
text: this.$t('app.setting.timer_options.file')
text: this.$t('app.setting.timer_options.relative_file_position')
},
{
value: 'fileAbsolute',
text: this.$t('app.setting.timer_options.absolute_file_position')
},
{
value: 'slicer',
text: this.$t('app.setting.timer_options.slicer_m73')
},
{
value: 'filament',
text: this.$t('app.setting.timer_options.filament')
}
]
}
Expand Down
4 changes: 2 additions & 2 deletions src/locales/de.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -662,8 +662,8 @@ app:
print_progress_calculation: Druckfortschritt-Berechnung
timer_options:
duration: Nur Dauer
filament: Filament-Schätzung
file: Datei-Schätzung
filament: Filament
file: Datei
slicer: Slicer
slicer_m73: Slicer (M73)
title:
Expand Down
6 changes: 4 additions & 2 deletions src/locales/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -634,9 +634,11 @@ app:
show_bed_screws_adjust_dialog_automatically: Show Bed Screws Adjust dialog automatically
show_screws_tilt_adjust_dialog_automatically: Show Screws Tilt Adjust dialog automatically
timer_options:
absolute_file_position: Absolute file position
duration: Duration only
filament: Filament Estimation
file: File Estimation
filament: Filament
file: File
relative_file_position: Relative file position
slicer: Slicer
slicer_m73: Slicer (M73)
title:
Expand Down
4 changes: 2 additions & 2 deletions src/locales/tr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -668,8 +668,8 @@ app:
otomatik olarak göster
timer_options:
duration: Süre sadece
filament: Filament Tahmini
file: Dosya Tahmini
filament: Filament
file: Dosya
slicer: Dilimleyici
slicer_m73: Dilimleyici (M73)
title:
Expand Down
2 changes: 1 addition & 1 deletion src/store/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export type PrintInProgressLayout = 'default' | 'compact'

export type ColorPickerValueRange = 'absolute' | 'percentage'

export type PrintProgressCalculation = 'file' | 'slicer'
export type PrintProgressCalculation = 'file' | 'fileAbsolute' | 'slicer' | 'filament'

export type PrintEtaCalculation = 'file' | 'slicer'

Expand Down
31 changes: 27 additions & 4 deletions src/store/printer/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ export const getters: GetterTree<PrinterState, RootState> = {
}
},

getFilePrintProgress: (state): number => {
getFileRelativePrintProgress: (state): number => {
const { gcode_start_byte, gcode_end_byte, path, filename } = state.printer.current_file ?? {}
const { file_position } = state.printer.virtual_sdcard ?? {}
const { file_position, progress } = state.printer.virtual_sdcard ?? {}

const fullFilename = path ? `${path}/${filename}` : filename

Expand All @@ -111,25 +111,48 @@ export const getters: GetterTree<PrinterState, RootState> = {
if (currentPosition > 0 && endPosition > 0) return currentPosition / endPosition
}

return state.printer.display_status.progress || 0
return progress || 0
},

getFileAbsolutePrintProgress: (state): number => {
return state.printer.virtual_sdcard?.progress || 0
},

getSlicerPrintProgress: (state): number => {
return state.printer.display_status.progress || 0
},

getFilamentPrintProgress: (state) => {
const { filament_used, filename: statsFilename } = state.printer.print_stats ?? {}
const { filament_total, path, filename } = state.printer.current_file ?? {}

const fullFilename = path ? `${path}/${filename}` : filename

if (filament_used != null && filament_total && fullFilename === statsFilename) {
return filament_used / filament_total
}

return state.printer.virtual_sdcard?.progress || 0
},

getPrintProgress: (state, getters, rootState): number => {
const printProgressCalculation = rootState.config.uiSettings.general.printProgressCalculation

const printProgressCalculationResults = printProgressCalculation
.map(type => {
switch (type) {
case 'file':
return getters.getFilePrintProgress
return getters.getFileRelativePrintProgress

case 'fileAbsolute':
return getters.getFileAbsolutePrintProgress

case 'slicer':
return getters.getSlicerPrintProgress

case 'filament':
return getters.getFilamentPrintProgress

default:
return 0
}
Expand Down

0 comments on commit 8ad71bc

Please sign in to comment.