Skip to content

Commit

Permalink
feat: adds initial pwm_cycle_time support
Browse files Browse the repository at this point in the history
Signed-off-by: Pedro Lamas <[email protected]>
  • Loading branch information
pedrolamas committed Jan 24, 2024
1 parent 29067f6 commit 138b0ba
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
9 changes: 8 additions & 1 deletion src/components/widgets/outputs/OutputItem.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div>
<output-pin
v-if="item.type === 'output_pin'"
v-if="pinTypes.includes(item.type)"
:key="item.key"
:pin="item"
/>
Expand Down Expand Up @@ -38,6 +38,13 @@ export default class Outputs extends Vue {
@Prop({ type: Object, required: true })
readonly item!: Fan | Led | IOutputPin
get pinTypes () {
return [
'output_pin',
'pwm_cycle_time'
]
}
get fanTypes () {
return [
'temperature_fan',
Expand Down
15 changes: 11 additions & 4 deletions src/components/widgets/outputs/OutputPin.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div>
<!-- Output Pins -->
<app-named-slider
v-if="pin && pin.pwm"
v-if="pwm"
:label="pin.prettyName"
:min="0"
:max="pin.scale"
Expand All @@ -16,10 +16,10 @@
/>

<app-named-switch
v-if="pin && !pin.pwm"
v-else
:disabled="!klippyReady"
:label="pin.prettyName"
:value="(pin.value > 0)"
:value="pin.value > 0"
:loading="hasWait(`${$waits.onSetOutputPin}${pin.name}`)"
@input="setValue"
/>
Expand All @@ -37,8 +37,15 @@ export default class OutputPin extends Mixins(StateMixin, BrowserMixin) {
@Prop({ type: Object, required: true })
readonly pin!: IOutputPin
get pwm () {
return (
this.pin.pwm ||
this.pin.type === 'pwm_cycle_time'
)
}
setValue (target: number) {
if (!this.pin.pwm) {
if (!this.pwm) {
target = (target) ? this.pin.scale : 0
}
this.sendGcode(`SET_PIN PIN=${this.pin.name} VALUE=${target}`, `${this.$waits.onSetOutputPin}${this.pin.name}`)
Expand Down
8 changes: 6 additions & 2 deletions src/store/printer/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,8 @@ export const getters: GetterTree<PrinterState, RootState> = {
*/
getPins: (_, getters) => {
const outputs = getters.getOutputs([
'output_pin'
'output_pin',
'pwm_cycle_time'
])
return outputs.sort((output: OutputPin) => output.pwm ? 1 : -1)
},
Expand All @@ -508,7 +509,8 @@ export const getters: GetterTree<PrinterState, RootState> = {

// Generic pins...
const outputPins = [
'output_pin'
'output_pin',
'pwm_cycle_time'
]

// LEDs...
Expand All @@ -523,6 +525,7 @@ export const getters: GetterTree<PrinterState, RootState> = {
'fan',
'fan_generic',
'output_pin',
'pwm_cycle_time',
'led',
'neopixel',
'dotstar'
Expand All @@ -536,6 +539,7 @@ export const getters: GetterTree<PrinterState, RootState> = {
// Should we filter visiblity based on the _ prefix?
const filterByPrefix = [
'output_pin',
'pwm_cycle_time',
'temperature_fan',
'controller_fan',
'heater_fan',
Expand Down

0 comments on commit 138b0ba

Please sign in to comment.