Skip to content

Commit

Permalink
feat: show warning for Trinamic OTPW flag
Browse files Browse the repository at this point in the history
Signed-off-by: Pedro Lamas <[email protected]>
  • Loading branch information
pedrolamas committed Jun 11, 2024
1 parent 0f72501 commit 064206e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
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: `TMC '${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

0 comments on commit 064206e

Please sign in to comment.