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(miscellaneous): add support for pwm_tool and pwm_cycle_time #1804

Merged
merged 1 commit into from
Mar 7, 2024
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
7 changes: 3 additions & 4 deletions src/components/inputs/MiscellaneousSlider.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
<v-icon v-else-if="type === 'led'" class="mr-2" small :retain-focus-on-click="true" @click="ledOn">
{{ mdiLightbulbOutline }}
</v-icon>
<v-icon v-else-if="type !== 'output_pin'" small :class="fanClasses">{{ mdiFan }}</v-icon>
<v-icon v-else-if="type.includes('fan')" small :class="fanClasses">{{ mdiFan }}</v-icon>
<span>{{ convertName(name) }}</span>
<v-spacer></v-spacer>
<v-spacer />
<small v-if="rpm !== null" :class="rpmClasses">{{ Math.round(rpm ?? 0) }} RPM</small>
<span v-if="!controllable" class="font-weight-bold">
{{ Math.round(parseFloat(value) * 100) }} %
Expand Down Expand Up @@ -199,12 +199,11 @@ export default class MiscellaneousSlider extends Mixins(BaseMixin) {
sendCmd(newVal: number): void {
if (this.value === newVal) return

let gcode = ''
let gcode = `SET_PIN PIN=${this.name} VALUE=${newVal.toFixed(2)}`
if (newVal < this.min) newVal = 0
newVal = newVal * this.multi
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 === 'output_pin') gcode = `SET_PIN PIN=${this.name} VALUE=${newVal.toFixed(2)}`
if (this.type === 'led')
gcode = `SET_LED LED=${this.name} ${this.ledChannelName}=${newVal.toFixed(2)} SYNC=0 TRANSMIT=1`

Expand Down
13 changes: 11 additions & 2 deletions src/store/printer/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,15 @@ export const getters: GetterTree<PrinterState, RootState> = {

getMiscellaneous: (state) => {
const output: PrinterStateMiscellaneous[] = []
const supportedObjects = ['controller_fan', 'heater_fan', 'fan_generic', 'fan', 'output_pin']
const supportedObjects = [
'controller_fan',
'heater_fan',
'fan_generic',
'fan',
'output_pin',
'pwm_tool',
'pwm_cycle_time',
]

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

Expand All @@ -308,10 +316,11 @@ export const getters: GetterTree<PrinterState, RootState> = {

if (nameSplit[0].toLowerCase() === 'fan') scale = 255

if (nameSplit[0].toLowerCase() === 'output_pin') {
if (['output_pin', 'pwm_tool', 'pwm_cycle_time'].includes(nameSplit[0])) {
controllable = true
pwm = false
if ('pwm' in settings) pwm = settings?.pwm ?? false
if (['pwm_tool', 'pwm_cycle_time'].includes(nameSplit[0])) pwm = true
if ('scale' in settings) scale = settings?.scale ?? 1
}

Expand Down
Loading