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: live printing bed mesh changes #1056

Merged
merged 4 commits into from Mar 5, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/components/layout/AppSaveConfigAndRestartBtn.vue
Expand Up @@ -6,7 +6,10 @@
:loading="loading"
@click="$emit('click')"
>
<v-icon class="mr-1">
<v-icon
class="mr-1"
color="warning"
>
$save
</v-icon>
<span>{{ $t('app.general.btn.save_config_and_restart') }}</span>
Expand All @@ -22,7 +25,7 @@
fab
small
text
color=""
color="warning"
:elevation="0"
:disabled="disabled"
:loading="loading"
Expand Down
107 changes: 58 additions & 49 deletions src/components/widgets/bedmesh/BedMeshControls.vue
Expand Up @@ -18,10 +18,8 @@
</app-btn-collapse-group>
</template>

<v-simple-table
v-if="meshes.length > 0"
class="no-hover"
>
<template v-if="bedMeshProfiles.length > 0">
<v-simple-table class="no-hover">
<thead>
<tr>
<th>{{ $t('app.general.label.name') }}</th>
Expand All @@ -32,11 +30,11 @@
</thead>
<tbody>
<tr
v-for="item in meshes"
:key="item.profile_name"
v-for="item in bedMeshProfiles"
:key="item.name"
>
<td class="">
{{ item.profile_name }}
{{ item.name }}
</td>
<td>
<v-chip
Expand All @@ -48,8 +46,8 @@
</v-chip>
</td>
<td class="focus--text">
<span v-if="item.active && mesh.variance">
{{ mesh.variance.toFixed(4) }}
<span>
{{ item.variance.toFixed(4) }}
<!-- / {{ mesh.min }} / {{ mesh.mid }} / {{ mesh.max }} -->
</span>
</td>
Expand All @@ -58,18 +56,17 @@
nowrap
>
<v-tooltip
v-if="!item.active && !printerPrinting && !printerBusy"
v-if="!item.active"
bottom
>
<template #activator="{ on, attrs }">
<app-btn
v-if="!item.active && !printerPrinting && !printerBusy"
v-bind="attrs"
x-small
color=""
fab
text
@click="loadProfile(item.profile_name)"
@click="loadProfile(item.name)"
v-on="on"
>
<v-icon>$open</v-icon>
Expand All @@ -81,14 +78,13 @@
<v-tooltip bottom>
<template #activator="{ on, attrs }">
<app-btn
:disabled="printerPrinting || printerBusy"
v-bind="attrs"
color=""
class="ml-2"
fab
text
x-small
@click="removeProfile(item.profile_name)"
@click="removeProfile(item.name)"
v-on="on"
>
<v-icon color="">
Expand All @@ -104,18 +100,19 @@
</v-simple-table>

<v-divider />
</template>

<v-card-text>
<div
v-if="meshes.length === 0"
v-if="bedMeshProfiles.length === 0"
class="mb-4"
>
{{ $t('app.bedmesh.msg.not_found') }}
</div>
<v-row>
<v-col cols="6">
<app-btn
:disabled="!meshLoaded || printerPrinting || printerBusy"
:disabled="!meshLoaded"
small
block
class="mb-2"
Expand All @@ -132,7 +129,7 @@
block
class="mb-2"
:loading="hasWait($waits.onMeshCalibrate)"
:disabled="printerPrinting || printerBusy"
:disabled="printerBusy"
v-on="on"
@click="calibrate()"
>
Expand All @@ -149,7 +146,7 @@
block
small
color="primary"
:disabled="!meshLoaded || printerPrinting || printerBusy"
:disabled="!meshLoaded"
v-on="on"
@click="handleOpenSaveDialog()"
>
Expand All @@ -165,7 +162,7 @@
small
class="mb-2"
:loading="hasWait($waits.onHomeAll)"
:disabled="printerPrinting || printerBusy"
:disabled="printerBusy"
:color="(!allHomed) ? 'primary' : undefined"
@click="sendGcode('G28', $waits.onHomeAll)"
>
Expand All @@ -180,7 +177,7 @@
<app-btn
v-if="!printerPrinting && printerSupportsQgl"
:loading="hasWait($waits.onQGL)"
:disabled="printerPrinting || printerBusy"
:disabled="printerBusy"
block
class="mb-2"
small
Expand All @@ -205,12 +202,10 @@
>
<v-radio
:label="$t('app.bedmesh.label.probed_matrix')"
color="primary"
value="probed_matrix"
/>
<v-radio
:label="$t('app.bedmesh.label.mesh_matrix')"
color="primary"
value="mesh_matrix"
/>
</v-radio-group>
Expand Down Expand Up @@ -285,7 +280,7 @@ import { Component, Mixins, Watch } from 'vue-property-decorator'
import SaveMeshDialog from './SaveMeshDialog.vue'
import StateMixin from '@/mixins/state'
import ToolheadMixin from '@/mixins/toolhead'
import { KlipperMesh, ProcessedMesh } from '@/store/mesh/types'
import { MeshState, BedMeshProfile, KlipperBedMesh, MatrixType } from '@/store/mesh/types'

@Component({
components: {
Expand All @@ -304,70 +299,64 @@ export default class BedMesh extends Mixins(StateMixin, ToolheadMixin) {
}

get matrix () {
return this.$store.state.mesh.matrix
return this.mesh.matrix
}

set matrix (val: string) {
set matrix (val: MatrixType) {
this.$store.dispatch('mesh/onMatrix', val)
}

get mapScale () {
return this.$store.state.mesh.scale
return this.mesh.scale
}

set mapScale (val: string) {
set mapScale (val: number) {
this.$store.dispatch('mesh/onScale', val)
}

get boxScale () {
return this.$store.state.mesh.boxScale
return this.mesh.boxScale
}

set boxScale (val: string) {
set boxScale (val: number) {
this.$store.dispatch('mesh/onBoxScale', val)
}

get wireframe () {
return this.$store.state.mesh.wireframe
return this.mesh.wireframe
}

set wireframe (val: string) {
set wireframe (val: boolean) {
this.$store.dispatch('mesh/onWireframe', val)
}

get flatSurface () {
return this.$store.state.mesh.flatSurface
return this.mesh.flatSurface
}

set flatSurface (val: boolean) {
this.$store.dispatch('mesh/onFlatSurface', val)
}

// The available meshes.
get meshes (): KlipperMesh[] {
return this.$store.getters['mesh/getBedMeshes']
get mesh () {
return this.$store.state.mesh as MeshState
}

// The current processed mesh data, if any.
get mesh (): ProcessedMesh {
return this.$store.getters['mesh/getCurrentMeshData'][this.matrix]
// The available meshes.
get bedMeshProfiles () {
return this.$store.getters['mesh/getBedMeshProfiles'] as BedMeshProfile[]
}

// The current mesh, unprocessed.
get currentMesh (): KlipperMesh {
return this.$store.state.printer.printer.bed_mesh
get currentMesh () {
return this.$store.state.printer.printer.bed_mesh as KlipperBedMesh
}

// If we have a mesh loaded.
get meshLoaded (): boolean {
return ('profile_name' in this.currentMesh && this.currentMesh.profile_name.length > 0)
}

// If we have a default profile.
get hasDefault (): boolean {
return (this.meshes.findIndex(mesh => mesh.profile_name === 'default') > -1)
}

// If the printer supports QGL
get printerSupportsQgl (): boolean {
const printerSettings = this.$store.getters['printer/getPrinterSettings']()
Expand All @@ -378,17 +367,38 @@ export default class BedMesh extends Mixins(StateMixin, ToolheadMixin) {
this.sendGcode('BED_MESH_CALIBRATE', this.$waits.onMeshCalibrate)
}

clearMesh () {
async clearMesh () {
if (this.printerPrinting) {
const result = await this.$confirm(
this.$tc('app.general.simple_form.msg.confirm'),
{ title: this.$tc('app.general.label.confirm'), color: 'card-heading', icon: '$error' }
)

if (!result) {
return
}
}

this.sendGcode('BED_MESH_CLEAR')
}

loadProfile (name: string) {
async loadProfile (name: string) {
if (this.printerPrinting) {
const result = await this.$confirm(
this.$tc('app.general.simple_form.msg.confirm'),
{ title: this.$tc('app.general.label.confirm'), color: 'card-heading', icon: '$error' }
)

if (!result) {
return
}
}

this.sendGcode(`BED_MESH_PROFILE LOAD="${name}"`)
}

removeProfile (name: string) {
this.sendGcode(`BED_MESH_PROFILE REMOVE="${name}"`)
this.sendGcode('SAVE_CONFIG', this.$waits.onSaveConfig)
}

handleMeshSave (config: {name: string; removeDefault: boolean}) {
Expand All @@ -398,7 +408,6 @@ export default class BedMesh extends Mixins(StateMixin, ToolheadMixin) {
if (config.removeDefault) {
this.sendGcode(`BED_MESH_PROFILE REMOVE="${this.currentMesh.profile_name}"`)
}
this.sendGcode('SAVE_CONFIG', this.$waits.onSaveConfig)
}

handleOpenSaveDialog () {
Expand Down
6 changes: 2 additions & 4 deletions src/locales/ar.yaml
Expand Up @@ -17,11 +17,9 @@ app:
not_loaded: لم يتم تحميل شبكة
tooltip:
calibrate: Begins a new calibration, saving as profile 'default'
delete: Delete Profile. This WILL restart your printer
delete: Delete Profile
load: Load Profile
save: >-
Commits calibrated profile to printer.cfg. This WILL restart your
printer
save: Commits calibrated profile to printer.cfg
chart:
label:
current: درجة الحرارة
Expand Down
4 changes: 2 additions & 2 deletions src/locales/cs.yaml
Expand Up @@ -17,9 +17,9 @@ app:
not_loaded: Síť bodů nenačtena.
tooltip:
calibrate: Zahájí novou kalibraci, uloží se jako profil 'default'
delete: Smazat profil. Toto RESTARTUJE vaši tiskárnu!
delete: Smazat profil
load: Načíst profil
save: Vloží profil do printer.cfg. Vaše tiskárna se RESTARTUJE!
save: Vloží profil do printer.cfg
chart:
label:
current: Teplota
Expand Down
6 changes: 2 additions & 4 deletions src/locales/de.yaml
Expand Up @@ -18,11 +18,9 @@ app:
not_loaded: Kein Mesh geladen
tooltip:
calibrate: Neue Kalibrierung beginnen und Profil als 'default' speichern
delete: Profil löschen. Achtung, der Drucker wird neu gestartet
delete: Profil löschen
load: Profil laden
save: >-
Fügt das Mesh Profil der printer.cfg hinzu. Achtung, der Drucker wird
neu gestartet
save: Fügt das Mesh Profil der printer.cfg hinzu
chart:
label:
current: Aktuell
Expand Down
6 changes: 2 additions & 4 deletions src/locales/en.yaml
Expand Up @@ -18,11 +18,9 @@ app:
not_loaded: No mesh loaded
tooltip:
calibrate: Begins a new calibration, saving as profile 'default'
delete: Delete Profile. This WILL restart your printer
delete: Delete Profile
load: Load Profile
save: >-
Commits calibrated profile to printer.cfg. This WILL restart your
printer
save: Commits calibrated profile to printer.cfg
chart:
label:
current: Actual
Expand Down
6 changes: 2 additions & 4 deletions src/locales/es.yaml
Expand Up @@ -17,11 +17,9 @@ app:
not_loaded: No está cargada ninguna malla.
tooltip:
calibrate: 'Comienza una nueva calibración, se guardará con el nombre ''default'''
delete: Elimina el perfil. Esto REINICIARÁ su impresora
delete: Elimina el perfil
load: Cargar el perfil
save: >-
Guarda el perfil de calibracion en el archivo printer.cfg. Esto
REINICIARÁ su impresora
save: Guarda el perfil de calibracion en el archivo printer.cfg
chart:
label:
current: Tª
Expand Down
6 changes: 2 additions & 4 deletions src/locales/fr.yaml
Expand Up @@ -19,11 +19,9 @@ app:
calibrate: >-
Démarrer une nouvelle calibration, le profil sera sauvegardé sous le nom
'default'
delete: Supprime le profil, ceci va REDÉMARRER votre imprimante .
delete: Supprime le profil
load: Charger le profil
save: >-
Enregistrer le profil calibré dans 'printer.cfg' . Ceci va REDÉMARRER
votre imprimante .
save: Enregistrer le profil calibré dans 'printer.cfg'
chart:
label:
current: Courant
Expand Down