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: show warning for Trinamic OTPW flag #1448

Merged
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
29 changes: 29 additions & 0 deletions src/store/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,35 @@
import type { Commit, Dispatch } from 'vuex'
import type { RootState } from './types'
import { SocketActions } from '@/api/socketActions'
import type { AppPushNotification } from './notifications/types'

export const handleTrinamicDriversChange = (payload: any, state: RootState, dispatch: Dispatch) => {
for (const item in payload) {
const [type, nameFromSplit] = item.split(' ', 2)

if (
/^tmc\d{4}$/.exec(type) &&
payload[item]?.drv_status?.otpw != null &&
state.printer.printer?.[item]?.drv_status?.otpw == null
) {
const name = nameFromSplit ?? item

const notification: AppPushNotification = {
id: `${item}-otpw`,
title: `Stepper driver '${name}' is over-heating`,
description: 'This may lead to a failed print',
to: 'https://www.klipper3d.org/TMC_Drivers.html#tmc-reports-error-ot1overtemperror',
type: 'error',
snackbar: true,
merge: true,
clear: true,
noCount: true
}

dispatch('notifications/pushNotification', notification, { root: true })
}
}
}

export const handleExcludeObjectChange = (payload: any, state: RootState, dispatch: Dispatch) => {
// For every notify - if print_stats.state changes from standby -> printing,
Expand Down
3 changes: 2 additions & 1 deletion src/store/printer/actions.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { ActionTree } from 'vuex'
import type { PrinterState } from './types'
import type { RootState } from '../types'
import { handlePrintStateChange, handleCurrentFileChange, handleExcludeObjectChange } from '../helpers'
import { handlePrintStateChange, handleCurrentFileChange, handleExcludeObjectChange, handleTrinamicDriversChange } from '../helpers'
import { handleAddChartEntry, handleSystemStatsChange, handleMcuStatsChange } from '../chart_helpers'
import { SocketActions } from '@/api/socketActions'
import { Globals } from '@/globals'
Expand Down Expand Up @@ -150,6 +150,7 @@ export const actions: ActionTree<PrinterState, RootState> = {
handleExcludeObjectChange(payload, rootState, dispatch)
handleSystemStatsChange(payload, rootState, commit)
handleMcuStatsChange(payload, rootState, commit)
handleTrinamicDriversChange(payload, rootState, dispatch)

for (const key in payload) {
const val = payload[key]
Expand Down