Skip to content

Commit

Permalink
feat: allow custom gcode to run with thermal presets
Browse files Browse the repository at this point in the history
Signed-off-by: Craig Bassett <[email protected]>
  • Loading branch information
cadriel committed Jun 25, 2021
1 parent 35e5eec commit 782cfd4
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,17 @@
<v-divider :key="i + 'fand'"></v-divider>
</template>

<app-setting :title="$t('app.setting.label.thermal_preset_gcode')">
<v-textarea
v-model="preset.gcode"
rows="2"
hide-details="auto"
class="mb-2"
outlined
>
</v-textarea>
</app-setting>

<v-card-actions>
<v-spacer></v-spacer>
<app-btn color="warning" text @click="$emit('input', false)" type="button">{{ $t('app.general.btn.cancel') }}</app-btn>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,29 +49,28 @@
<v-divider :key="preset.id" v-if="i < presets.length - 1 && presets.length > 0"></v-divider>
</template>

<temperature-preset-dialog
<preset-dialog
v-if="dialogState.preset"
v-model="dialogState.active"
:preset="dialogState.preset"
@save="handleSavePreset"
></temperature-preset-dialog>
></preset-dialog>

</v-card>
</div>
</template>

<script lang="ts">
import { Component, Mixins } from 'vue-property-decorator'
import PresetDialog from './PresetDialog.vue'
import { TemperaturePreset } from '@/store/config/types'
import { Fan, Heater } from '@/store/printer/types'
import StateMixin from '@/mixins/state'
import { VForm } from '@/types/vuetify'
import TemperaturePresetDialog from './TempPresetDialog.vue'
@Component({
components: {
TemperaturePresetDialog
PresetDialog
}
})
export default class TemperaturePresetSettings extends Mixins(StateMixin) {
Expand Down
22 changes: 14 additions & 8 deletions src/components/widgets/thermals/TemperatureCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,22 @@ export default class TemperatureCard extends Mixins(StateMixin) {
}
handleApplyPreset (preset: TemperaturePreset) {
if (preset && preset.values) {
for (const key in preset.values) {
const item = preset.values[key]
if (item.type === 'heater' && item.active && item.value > -1) {
this.sendGcode(`SET_HEATER_TEMPERATURE HEATER=${key} TARGET=${item.value}`)
}
if (item.type === 'fan' && item.active && item.value > -1) {
this.sendGcode(`SET_TEMPERATURE_FAN_TARGET TEMPERATURE_FAN=${key} TARGET=${item.value}`)
if (preset) {
if (preset.values) {
for (const key in preset.values) {
const item = preset.values[key]
if (item.type === 'heater' && item.active && item.value > -1) {
this.sendGcode(`SET_HEATER_TEMPERATURE HEATER=${key} TARGET=${item.value}`)
}
if (item.type === 'fan' && item.active && item.value > -1) {
this.sendGcode(`SET_TEMPERATURE_FAN_TARGET TEMPERATURE_FAN=${key} TARGET=${item.value}`)
}
}
}
if (preset.gcode) {
this.sendGcode(preset.gcode)
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/locales/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ app:
retraction_icon_size: Retraction Icon Size
show_animations: Show animations
theme_preset: Community preset
thermal_preset_gcode: GCode
thermal_preset_name: Preset Name
time_estimates: Time estimates
toggle: Toggle
Expand Down
1 change: 1 addition & 0 deletions src/store/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ export interface TemperaturePreset {
id: number;
name: string;
values: TemperaturePresetValues;
gcode?: string;
}

export interface TemperaturePresetValues {
Expand Down
6 changes: 3 additions & 3 deletions src/views/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<macro-categories></macro-categories>
<cameras></cameras>
<toolhead-settings></toolhead-settings>
<temperature-preset-settings></temperature-preset-settings>
<preset-settings></preset-settings>
<gcode-preview-settings></gcode-preview-settings>
<version-settings v-if="supportsVersions"></version-settings>
</div>
Expand All @@ -23,7 +23,7 @@ import StateMixin from '@/mixins/state'
import MacroCategories from '@/components/settings/macros/MacroCategories.vue'
import GeneralSettings from '@/components/settings/GeneralSettings.vue'
import TemperaturePresetSettings from '@/components/settings/TemperaturePresetSettings.vue'
import PresetSettings from '@/components/settings/presets/PresetSettings.vue'
import Cameras from '@/components/settings/cameras/Cameras.vue'
import ToolheadSettings from '@/components/settings/ToolheadSettings.vue'
import ThemeSettings from '@/components/settings/ThemeSettings.vue'
Expand All @@ -35,7 +35,7 @@ import AuthSettings from '@/components/settings/auth/AuthSettings.vue'
components: {
MacroCategories,
GeneralSettings,
TemperaturePresetSettings,
PresetSettings,
Cameras,
ToolheadSettings,
ThemeSettings,
Expand Down

0 comments on commit 782cfd4

Please sign in to comment.