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

fix: fix gcode command for generic_heater in presets #1569

Merged
merged 1 commit into from
Oct 1, 2023
Merged
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
18 changes: 14 additions & 4 deletions src/components/panels/Temperature/TemperaturePanelPresets.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,23 @@ export default class TemperaturePanelPresets extends Mixins(BaseMixin) {
preheat(preset: GuiPresetsStatePreset): void {
for (const [name, attributes] of Object.entries(preset.values)) {
if (attributes.bool) {
let gcode = `SET_HEATER_TEMPERATURE HEATER=${name} TARGET=${attributes.value}`
const splits = name.split(' ')
const printerObject = splits[0]
let printerObjectName = splits[1] ?? splits[0]

if (attributes.type === 'temperature_fan') {
const fanName = name.replace('temperature_fan ', '')
gcode = `SET_TEMPERATURE_FAN_TARGET temperature_fan=${fanName} TARGET=${attributes.value}`
// set default heater command
let command = 'SET_HEATER_TEMPERATURE'
let commandAttribute = 'HEATER'

// override command for temperature_fan
if (printerObject === 'temperature_fan') {
command = 'SET_TEMPERATURE_FAN_TARGET'
commandAttribute = 'TEMPERATURE_FAN'
}

// build gcode
const gcode = `${command} ${commandAttribute}=${printerObjectName} TARGET=${attributes.value}`

this.$store.dispatch('server/addEvent', { message: gcode, type: 'command' })
this.$socket.emit('printer.gcode.script', { script: gcode })
}
Expand Down
Loading