Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeanon committed Feb 8, 2024
1 parent 8a1de37 commit 0e14735
Show file tree
Hide file tree
Showing 11 changed files with 210 additions and 6 deletions.
8 changes: 8 additions & 0 deletions src/components/mixins/zoffset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ export default class ZoffsetMixin extends Vue {
return !this.isEndstopProbe && this.existZOffsetApplyEndstop
}

get showSaveZOffset(): boolean {
return this.$store.state.gui.view.toolhead.showSaveZOffset ?? true
}

get showClearZOffset(): boolean {
return this.$store.state.gui.view.toolhead.showClearZOffset ?? true
}

get autoSaveZOffsetOption() {
if (this.isEndstopProbe && this.existZOffsetApplyProbe) return 'Z_OFFSET_APPLY_PROBE'

Expand Down
16 changes: 14 additions & 2 deletions src/components/panels/Temperature/TemperaturePanelList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
<tr>
<th class="icon">&nbsp;</th>
<th class="name">{{ $t('Panels.TemperaturePanel.Name') }}</th>
<th v-if="!el.is.mobile && !hidePIDProfiles" class="pid-profile">
{{ $t('Panels.TemperaturePanel.PIDProfile') }}
</th>
<th v-if="!el.is.mobile" class="state">
{{ $t('Panels.TemperaturePanel.State') }}
</th>
Expand Down Expand Up @@ -103,6 +106,10 @@ export default class TemperaturePanelList extends Mixins(BaseMixin) {
return this.$store.state.gui.view.tempchart.hideMonitors ?? false
}
get hidePIDProfiles(): boolean {
return this.$store.state.gui.view.tempchart.hidePIDProfiles ?? false
}
get temperature_sensors() {
return this.available_sensors
.filter((fullName: string) => {
Expand Down Expand Up @@ -176,17 +183,22 @@ export default class TemperaturePanelList extends Mixins(BaseMixin) {
text-align: center;
}
.temperature-panel-table ::v-deep .pid-profile {
text-align: right !important;
}
.temperature-panel-table ::v-deep .state {
width: 100px;
width: 75px;
text-align: right !important;
}
.temperature-panel-table ::v-deep .current {
width: 100px;
width: 75px;
text-align: right !important;
}
.temperature-panel-table ::v-deep .target {
width: 140px;
text-align: center !important;
}
</style>
108 changes: 106 additions & 2 deletions src/components/panels/Temperature/TemperaturePanelListItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,21 @@
<td class="name">
<span class="cursor-pointer" @click="showEditDialog = true">{{ formatName }}</span>
</td>
<td v-if="!isResponsiveMobile && !hidePIDProfiles" class="pid-profile">
<form @submit.prevent="setPIDProfile">
<v-text-field
v-if="loaded_pid_profile !== null"
class="_pid-profile-input pr-1"
:rules="[rules.pid_profile]"
v-model="pid_profile"
dense
outlined
hide-details
hide-spin-buttons
@blur="pidProfile = loaded_pid_profile"
@focus="$event.target.select()"></v-text-field>
</form>
</td>
<td v-if="!isResponsiveMobile" class="state">
<v-tooltip v-if="state !== null" top>
<template #activator="{ on, attrs }">
Expand Down Expand Up @@ -62,7 +77,7 @@

<script lang="ts">
import Component from 'vue-class-component'
import { Mixins, Prop } from 'vue-property-decorator'
import {Mixins, Prop, Watch} from 'vue-property-decorator'
import BaseMixin from '@/components/mixins/base'
import { convertName } from '@/plugins/helpers'
import {
Expand All @@ -83,6 +98,21 @@ export default class TemperaturePanelListItem extends Mixins(BaseMixin) {
@Prop({ type: Boolean, required: true }) readonly isResponsiveMobile!: boolean
showEditDialog = false
pidProfile = this.printerObject.pid_profile ?? null
private rules = {
pid_profile: (value: string) => this.pidProfileAllowed(value) || this.$t('Panels.TemperaturePanel.PIDProfileNotAllowed')
}
pidProfileAllowed(name: string) {
const pidProfiles = this.pidProfiles
for (let i = 0; i < pidProfiles.length; i++) {
if (name == pidProfiles[i]) {
return true
}
}
return false
}
get printerObject() {
if (!(this.objectName in this.$store.state.printer)) return {}
Expand Down Expand Up @@ -173,6 +203,57 @@ export default class TemperaturePanelListItem extends Mixins(BaseMixin) {
return this.printerObject.power ?? this.printerObject.speed ?? null
}
set pid_profile(newval: string) {
this.pidProfile = newval
}
get pid_profile(): string {
return this.pidProfile
}
get loaded_pid_profile(): string | null {
return this.printerObject.pid_profile ?? null
}
get pidProfiles(): string[] {
return this.$store.getters['printer/getPIDProfiles']?.get(this.objectName) ?? {}
}
updatePIDProfile() {
if (!this.pidProfileAllowed(this.pidProfile)) {
this.$toast.error(
this.$t('Panels.TemperaturePanel.UnknownPIDProfile', { profile: this.pidProfile, heater: this.objectName }) + ''
)
return
}
const gcode = 'PID_PROFILE HEATER=' + this.objectName + ' LOAD=' + this.pidProfile
this.$store.dispatch('server/addEvent', {
message: gcode,
type: 'command',
})
this.$socket.emit('printer.gcode.script', { script: gcode }, { loading: 'macro_' + gcode })
}
setPIDProfile():void {
if (!this.pidProfileAllowed(this.pidProfile)) {
this.$toast.error(
this.$t('Panels.TemperaturePanel.UnknownPIDProfile', { profile: this.pidProfile, heater: this.objectName }) + ''
)
} else {
const gcode = 'PID_PROFILE HEATER=' + this.objectName + ' LOAD=' + this.pidProfile
this.$store.dispatch('server/addEvent', {
message: gcode,
type: 'command',
})
this.$socket.emit('printer.gcode.script', {script: gcode}, {loading: 'macro_' + gcode})
}
}
@Watch('loaded_pid_profile')
pidProfileChanged(newVal: any): void {
this.pidProfile = this.printerObject.pid_profile
}
get formatState() {
if (this.state === null) return null
if (this.target === 0 && this.state === 0) return 'off'
Expand Down Expand Up @@ -208,7 +289,7 @@ export default class TemperaturePanelListItem extends Mixins(BaseMixin) {
}
get max_temp() {
return parseInt(this.printerObjectSettings.max_temp ?? 0)
return parseInt(this.printerObjectSettings.max_set_temp ?? 0)
}
get measured_min_temp() {
Expand Down Expand Up @@ -272,6 +353,10 @@ export default class TemperaturePanelListItem extends Mixins(BaseMixin) {
return ''
}
get hidePIDProfiles(): boolean {
return this.$store.state.gui.view.tempchart.hidePIDProfiles ?? false
}
}
</script>

Expand All @@ -283,4 +368,23 @@ export default class TemperaturePanelListItem extends Mixins(BaseMixin) {
::v-deep .cursor-pointer {
cursor: pointer;
}
._pid-profile-input {
min-width: 4.2rem;
max-width: 8rem;
padding-right: 0 !important;
}
._pid-profile-input >>> .v-input__slot {
min-height: 1rem !important;
padding-left: 8px !important;
padding-right: 8px !important;
}
._pid-profile-input >>> .v-text-field__slot input {
text-align: center !important;
padding-top: 4px;
padding-bottom: 4px;
min-width: 4rem;
}
</style>
15 changes: 15 additions & 0 deletions src/components/panels/Temperature/TemperaturePanelSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@
hide-details
:label="$t('Panels.TemperaturePanel.HideMonitors')" />
</v-list-item>
<v-list-item class="minHeight36">
<v-checkbox
v-model="hidePIDProfiles"
class="mt-0"
hide-details
:label="$t('Panels.TemperaturePanel.HidePIDProfiles')" />
</v-list-item>
<v-list-item class="minHeight36">
<v-checkbox
v-model="autoscaleTempchart"
Expand Down Expand Up @@ -79,5 +86,13 @@ export default class TemperaturePanelSettings extends Mixins(BaseMixin) {
set hideMonitors(newVal: boolean) {
this.$store.dispatch('gui/saveSetting', { name: 'view.tempchart.hideMonitors', value: newVal })
}
get hidePIDProfiles(): boolean {
return this.$store.state.gui.view.tempchart.hidePIDProfiles ?? false
}
set hidePIDProfiles(newVal: boolean) {
this.$store.dispatch('gui/saveSetting', { name: 'view.tempchart.hidePIDProfiles', value: newVal })
}
}
</script>
30 changes: 30 additions & 0 deletions src/components/panels/ToolheadControls/ToolheadPanelSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,20 @@
hide-details
:label="$t('Panels.ToolheadControlPanel.ZOffset')" />
</v-list-item>
<v-list-item class="minHeight36">
<v-checkbox
v-model="showSaveZOffset"
class="mt-0"
hide-details
:label="$t('Panels.ToolheadControlPanel.SaveZOffset')" />
</v-list-item>
<v-list-item class="minHeight36">
<v-checkbox
v-model="showClearZOffset"
class="mt-0"
hide-details
:label="$t('Panels.ToolheadControlPanel.ClearZOffset')" />
</v-list-item>
<v-list-item class="minHeight36">
<v-checkbox
v-model="showSpeedFactor"
Expand Down Expand Up @@ -87,6 +101,22 @@ export default class ToolheadPanelSettings extends Mixins(BaseMixin) {
this.$store.dispatch('gui/saveSetting', { name: 'view.toolhead.showZOffset', value: newVal })
}
get showSaveZOffset(): boolean {
return this.$store.state.gui.view.toolhead.showSaveZOffset ?? true
}
set showSaveZOffset(newVal: boolean) {
this.$store.dispatch('gui/saveSetting', { name: 'view.toolhead.showSaveZOffset', value: newVal })
}
get showClearZOffset(): boolean {
return this.$store.state.gui.view.toolhead.showClearZOffset ?? true
}
set showClearZOffset(newVal: boolean) {
this.$store.dispatch('gui/saveSetting', { name: 'view.toolhead.showClearZOffset', value: newVal })
}
get showSpeedFactor(): boolean {
return this.$store.state.gui.view.toolhead.showSpeedFactor ?? true
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/panels/ToolheadControls/ZoffsetControl.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<v-col class="v-subheader justify-end pl-0">
<div class="d-flex align-center">
<v-btn
v-if="z_gcode_offset !== 0"
v-if="z_gcode_offset !== 0 && showClearZOffset"
:loading="loadings.includes('babySteppingClear')"
text
small
Expand All @@ -27,7 +27,7 @@
<span v-if="!el.is.xsmall" class="ml-1">{{ $t('Panels.ZoffsetPanel.Clear') }}</span>
</v-btn>
<v-btn
v-if="showSaveButton"
v-if="showSaveButton && showSaveZOffset"
color="primary"
text
small
Expand Down
6 changes: 6 additions & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,7 @@
"Headline": "Temperatures",
"HideMcuHostSensors": "Hide Host/MCU Sensors",
"HideMonitors": "Hide Monitors",
"HidePIDProfiles": "Hide PID-Profiles",
"Max": "max",
"Min": "min",
"Name": "Name",
Expand All @@ -768,6 +769,9 @@
"ShowChart": "Show Chart",
"ShowNameInChart": "Show {name} in chart",
"ShowNameInList": "Show {name} in list",
"PIDProfile": "PID-Profile",
"UnknownPIDProfile": "Unknown PID-Profile [{profile}] for Heater [{heater}]",
"PIDProfileNotAllowed": "PID-Profile does not exist",
"State": "State",
"Target": "Target",
"TemperaturesInChart": "Temperature [°C]",
Expand All @@ -788,6 +792,8 @@
"SettingsInterfaceControl": "Settings > Interface > Control",
"SpeedFactor": "Speed factor",
"ZOffset": "Z-Offset",
"SaveZOffset": "Save Z-Offset",
"ClearZOffset": "Clear Z-Offset",
"ZTilt": "Z-Tilt"
},
"WebcamPanel": {
Expand Down
3 changes: 3 additions & 0 deletions src/store/gui/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ export const getDefaultState = (): GuiState => {
hiddenDataset: [],
hideMcuHostSensors: false,
hideMonitors: false,
hidePIDProfiles: false,
autoscale: false,
datasetSettings: {},
},
Expand All @@ -279,6 +280,8 @@ export const getDefaultState = (): GuiState => {
showCoordinates: true,
showControl: true,
showZOffset: true,
showSaveZOffset: true,
showClearZOffset: true,
showSpeedFactor: true,
},
webcam: {
Expand Down
3 changes: 3 additions & 0 deletions src/store/gui/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ export interface GuiState {
hiddenDataset: string[]
hideMcuHostSensors: boolean
hideMonitors: boolean
hidePIDProfiles: boolean
autoscale: boolean
datasetSettings: any
}
Expand All @@ -203,6 +204,8 @@ export interface GuiState {
showCoordinates: boolean
showControl: boolean
showZOffset: boolean
showSaveZOffset: boolean
showClearZOffset: boolean
showSpeedFactor: boolean
}
webcam: {
Expand Down
21 changes: 21 additions & 0 deletions src/store/printer/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,27 @@ export const getters: GetterTree<PrinterState, RootState> = {
return caseInsensitiveSort(array, 'name')
},

getPIDProfiles: (state, getters) => {
const profiles: Map<String, string[]> = new Map()
const config = state.configfile?.config ?? {}
const availableHeaters = state.heaters?.available_heaters ?? []
for (let i = 0; i < availableHeaters.length; i++) {
profiles.set(availableHeaters[i], ["default"])
}
Object.keys(config)
.filter((prop) => prop.startsWith('pid_profile'))
.forEach((prop) => {
const profile = prop.replace('pid_profile ', '').split(' ')
if (profiles.has(profile[0])) {
profiles.get(profile[0])?.push(
profile[1]
)
}
})

return profiles
},

getLights: (state, getters) => {
const lights: PrinterStateLight[] = []
const supportedObjects = ['dotstar', 'led', 'neopixel', 'pca9533', 'pca9632']
Expand Down
Loading

0 comments on commit 0e14735

Please sign in to comment.