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(gui): fans can have multiple rpm values and add "fan_multi" #2016

Closed
wants to merge 1 commit into from
Closed
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
20 changes: 19 additions & 1 deletion src/components/inputs/MiscellaneousSlider.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,24 @@
<v-icon v-else-if="type.includes('fan')" small :class="fanClasses">{{ mdiFan }}</v-icon>
<span>{{ convertName(name) }}</span>
<v-spacer />
<small v-if="rpm !== null" :class="rpmClasses">{{ Math.round(rpm ?? 0) }} RPM</small>
<small v-if="rpm !== null && !Array.isArray(rpm)" :class="rpmClasses">
{{ Math.round(rpm ?? 0) }} RPM
</small>
<template v-if="Array.isArray(rpm)">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Consider extracting RPM display logic to improve readability

The new logic for displaying multiple RPM values adds complexity to the template. Consider extracting this into a separate component or computed property to improve readability and maintainability.

<template v-if="isRpmArray">

<template v-for="(rpmval, index) in rpm">
<small
v-if="rpm !== null"
:key="index"
:class="{
'mr-3': index !== rpm.length - 1,
'red--text': rpmval === 0 && value > 0,
'mt-2': controllable,
'mr-3 mt-1': !controllable,
}">
{{ Math.round(rpmval ?? 0) }} RPM
</small>
</template>
</template>
<span v-if="!controllable" class="font-weight-bold">
{{ Math.round(parseFloat(value) * 100) }} %
</span>
Expand Down Expand Up @@ -205,6 +222,7 @@ export default class MiscellaneousSlider extends Mixins(BaseMixin) {
let gcode = `SET_PIN PIN=${this.name} VALUE=${newVal.toFixed(2)}`
if (this.type === 'fan') gcode = `M106 S${newVal.toFixed(0)}`
if (this.type === 'fan_generic') gcode = `SET_FAN_SPEED FAN=${this.name} SPEED=${newVal}`
if (this.type === 'fan_multi') gcode = `SET_FAN_SPEED FAN=${this.name} SPEED=${newVal}`
if (this.type === 'led')
gcode = `SET_LED LED=${this.name} ${this.ledChannelName}=${newVal.toFixed(2)} SYNC=0 TRANSMIT=1`

Expand Down
7 changes: 4 additions & 3 deletions src/store/printer/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,10 @@ export const getters: GetterTree<PrinterState, RootState> = {

getFans: (state, getters) => {
const fans: PrinterStateFan[] = []
const supportedFans = ['temperature_fan', 'controller_fan', 'heater_fan', 'fan_generic', 'fan']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: Clarify the distinction between 'fan_multi' and 'fan_generic'

Can you provide more information about the 'fan_multi' type and how it differs from 'fan_generic'? Understanding the distinction would help clarify the purpose of this addition.

const supportedFans = ['temperature_fan', 'controller_fan', 'heater_fan', 'fan_generic', 'fan_multi', 'fan']
const objects = getters.getPrinterObjects(supportedFans)

const controllableFans = ['fan_generic', 'fan']
const controllableFans = ['fan_generic', 'fan_multi', 'fan']

objects.foreach((object: PrinterGetterObject) => {
fans.push({
Expand Down Expand Up @@ -300,13 +300,14 @@ export const getters: GetterTree<PrinterState, RootState> = {
'controller_fan',
'heater_fan',
'fan_generic',
'fan_multi',
'fan',
'output_pin',
'pwm_tool',
'pwm_cycle_time',
]

const controllableFans = ['fan_generic', 'fan']
const controllableFans = ['fan_generic', 'fan_multi', 'fan']

for (const [key, value] of Object.entries(state)) {
const nameSplit = key.split(' ')
Expand Down
Loading