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

chore: some toolhead panel tweaks #781

Merged
merged 5 commits into from
May 8, 2022
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 8 additions & 31 deletions src/components/panels/ToolheadControls/MoveToControl.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,11 @@
<template #default="{ el }">
<v-container class="py-0">
<v-row>
<v-col>
<v-btn-toggle v-model="positionString" dense mandatory style="flex-wrap: nowrap; width: 100%">
<v-btn
value="absolute"
:disabled="['printing'].includes(printer_state)"
dense
class="btnMinWidthAuto flex-grow-1 px-0"
style="height: 28px">
<span class="body-2">{{ $t('Panels.ToolheadControlPanel.Absolute') }}</span>
</v-btn>
<v-btn
value="relative"
:disabled="['printing'].includes(printer_state)"
dense
class="btnMinWidthAuto flex-grow-1 px-0"
style="height: 28px">
<span class="body-2">{{ $t('Panels.ToolheadControlPanel.Relative') }}</span>
</v-btn>
</v-btn-toggle>
<v-col class="v-subheader text--secondary pr-0">
<v-icon small class="mr-2">
{{ mdiCrosshairsGps }}
</v-icon>
<span>{{ $t('Panels.ToolheadControlPanel.Position') }}: {{ displayPositionAbsolute }}</span>
</v-col>
</v-row>
<v-form class="pt-3" @keyup.native.enter="sendCmd">
Expand Down Expand Up @@ -78,11 +64,14 @@ import BaseMixin from '@/components/mixins/base'
import ControlMixin from '@/components/mixins/control'
import MoveToInput from '@/components/inputs/MoveToInput.vue'
import Responsive from '@/components/ui/Responsive.vue'
import { mdiCrosshairsGps } from '@mdi/js'

@Component({
components: { MoveToInput, Responsive },
})
export default class MoveToControl extends Mixins(BaseMixin, ControlMixin) {
mdiCrosshairsGps = mdiCrosshairsGps

input: { [index: string]: any } = {
x: { pos: '', valid: true },
y: { pos: '', valid: true },
Expand Down Expand Up @@ -163,18 +152,6 @@ export default class MoveToControl extends Mixins(BaseMixin, ControlMixin) {
return this.$store.state.printer.gcode_move?.absolute_coordinates ?? true
}

get positionString() {
return this.positionAbsolute ? 'absolute' : 'relative'
}

set positionString(newVal) {
let gcode = 'G90'
if (newVal === 'relative') gcode = 'G91'

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

get livePositions() {
const pos = this.$store.state.printer.motion_report?.live_position ?? [0, 0, 0]
return {
Expand Down
17 changes: 9 additions & 8 deletions src/components/panels/ToolheadControls/ZoffsetControl.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
<responsive
:breakpoints="{
xsmall: (el) => el.width <= 285,
medium: (el) => el.width <= 510,
}">
<template #default="{ el }">
<v-container class="pa-0">
Expand Down Expand Up @@ -115,7 +116,7 @@
</v-col>
</v-row>
<v-row dense>
<v-col>
<v-col :class="!el.is.medium ? 'order-1 col-6' : 'col-12'">
<div class="d-flex align-center">
<v-item-group class="_btn-group">
<v-btn
Expand All @@ -125,14 +126,14 @@
class="_btn-qs flex-grow-1 px-1"
@click="sendBabyStepUp(offset)">
<v-icon v-if="index === 0 && !el.is.xsmall" left small class="mr-1 ml-1">
{{ mdiArrowSplitHorizontal }}
{{ mdiArrowExpandUp }}
</v-icon>
<span>&plus;{{ offset }}</span>
</v-btn>
</v-item-group>
</div>
</v-col>
<v-col>
<v-col :class="!el.is.medium ? 'order-0 col-6' : 'col-12'">
<v-item-group class="_btn-group">
<v-btn
v-for="(offset, index) in offsetsZ"
Expand All @@ -141,7 +142,7 @@
class="_btn-qs flex-grow-1 px-1"
@click="sendBabyStepDown(offset)">
<v-icon v-if="index === 0 && !el.is.xsmall" left small class="mr-1 ml-1">
{{ mdiArrowCollapseVertical }}
{{ mdiArrowCollapseDown }}
</v-icon>
<span>&minus;{{ offset }}</span>
</v-btn>
Expand Down Expand Up @@ -191,10 +192,10 @@ import {
mdiElectricSwitch,
mdiElevator,
mdiContentSave,
mdiArrowCollapseVertical,
mdiArrowCollapseDown,
mdiInformation,
mdiMenuDown,
mdiArrowSplitHorizontal,
mdiArrowExpandUp,
mdiLayersOutline,
} from '@mdi/js'
@Component({
Expand All @@ -205,10 +206,10 @@ export default class ZoffsetControl extends Mixins(BaseMixin) {
mdiElectricSwitch = mdiElectricSwitch
mdiElevator = mdiElevator
mdiContentSave = mdiContentSave
mdiArrowCollapseVertical = mdiArrowCollapseVertical
mdiArrowCollapseDown = mdiArrowCollapseDown
mdiInformation = mdiInformation
mdiMenuDown = mdiMenuDown
mdiArrowSplitHorizontal = mdiArrowSplitHorizontal
mdiArrowExpandUp = mdiArrowExpandUp
mdiLayersOutline = mdiLayersOutline

private saveOffsetDialog = false
Expand Down
19 changes: 15 additions & 4 deletions src/store/printer/getters.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { additionalSensors, checkKlipperConfigModules } from '@/store/variables'
import {
additionalSensors,
checkKlipperConfigModules,
opacityHeaterActive,
opacityHeaterInactive,
} from '@/store/variables'
import { GetterTree } from 'vuex'
import {
PrinterState,
Expand Down Expand Up @@ -202,7 +207,10 @@ export const getters: GetterTree<PrinterState, RootState> = {
name: heater.name,
type: heater.type,
icon: heater.icon,
iconColor: heater.target > 0 ? `${heater.chartColor}aa` : `${heater.chartColor}22`,
iconColor:
heater.target > 0
? `${heater.chartColor}${opacityHeaterActive}`
: `${heater.chartColor}${opacityHeaterInactive}`,
iconClass: '',
state: heater.target > 0 ? heater.power + '%' : 'off',
avgState: heater.avgPower + '%',
Expand Down Expand Up @@ -231,7 +239,10 @@ export const getters: GetterTree<PrinterState, RootState> = {
name: fan.name,
type: 'temperature_fan',
icon: fan.icon,
iconColor: fan.target > 0 ? `${fan.chartColor}aa` : `${fan.chartColor}22`,
iconColor:
fan.target > 0
? `${fan.chartColor}${opacityHeaterActive}`
: `${fan.chartColor}${opacityHeaterInactive}`,
iconClass: fan.speed ? ' icon-rotate' : '',
state: fan.target > 0 && fan.speed > 0 ? fan.speed + '%' : fan.target > 0 ? 'standby' : 'off',
avgState: fan.avgSpeed + '%',
Expand Down Expand Up @@ -260,7 +271,7 @@ export const getters: GetterTree<PrinterState, RootState> = {
name: sensor.name,
type: 'temperature_sensor',
icon: sensor.icon,
iconColor: `${sensor.chartColor}aa`,
iconColor: `${sensor.chartColor}${opacityHeaterActive}`,
iconClass: '',
state: null,
avgState: '',
Expand Down
4 changes: 2 additions & 2 deletions src/store/variables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ export const colorArray = ['#F44336', '#8e379d', '#03DAC5', '#3F51B5', '#ffde03'

export const colorHeaterBed = '#2196F3'
export const colorChamber = '#4CAF50'
export const opacityHeaterActive = '99'
export const opacityHeaterInactive = '44'
export const themeDir = '.theme'
export const datasetInterval = 1000
export const datasetTypes = ['temperature', 'target', 'power', 'speed']

export const datasetTypesInPercents = ['power', 'speed']

export const additionalSensors = ['bme280', 'htu21d']

/*
Expand Down