Skip to content

Commit

Permalink
feat(notification): add TMC overheating warnings (#1919)
Browse files Browse the repository at this point in the history
  • Loading branch information
meteyou authored Jul 6, 2024
1 parent 6fd3251 commit 81ea9cd
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@
"OneHourShort": "1H",
"OneWeekShort": "1W",
"Remind": "Remind:",
"ShowDetails": "show details"
"ShowDetails": "show details",
"TmcOtFlag": "Stepper driver error: OT flag set",
"TmcOtFlagText": "The stepper driver '{name}' has triggered the OT flag and stopped working. This can be caused by a too high current. Please check the stepper driver settings and cooling.",
"TmcOtpwFlag": "Stepper driver warning: OTPW flag set",
"TmcOtpwFlagText": "The stepper driver '{name}' has triggered the OTPW flag and may stop working if it gets any hotter. This is an indication of an over temperature condition. This can be caused by a too high current. Please check the stepper driver settings and cooling."
},
"NumberInput": {
"GreaterOrEqualError": "Must be greater or equal than {min}!",
Expand Down
41 changes: 41 additions & 0 deletions src/store/gui/notifications/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ export const getters: GetterTree<GuiNotificationState, any> = {
// browser warnings
notifications = notifications.concat(getters['getNotificationsBrowserWarnings'])

// TMC overheat warnings
notifications = notifications.concat(getters['getNotificationsOverheatDrivers'])

const mapType = {
normal: 2,
high: 1,
Expand Down Expand Up @@ -398,6 +401,44 @@ export const getters: GetterTree<GuiNotificationState, any> = {
return notifications
},

getNotificationsOverheatDrivers: (state, getters, rootState) => {
const notifications: GuiNotificationStateEntry[] = []
const date = rootState.server.system_boot_at ?? new Date()

Object.keys(rootState.printer)
.filter((key) => key.startsWith('tmc'))
.forEach((key) => {
const printerObject = rootState.printer[key]
const name = key.split(' ')[1]

if ((printerObject.drv_status?.ot ?? null) === 1) {
notifications.push({
id: `tmcwarning/${key}-ot`,
priority: 'critical',
title: i18n.t('App.Notifications.TmcOtFlag').toString(),
description: i18n.t('App.Notifications.TmcOtFlagText', { name }).toString(),
date,
dismissed: false,
url: 'https://www.klipper3d.org/TMC_Drivers.html#tmc-reports-error-ot1overtemperror',
})
}

if ((printerObject.drv_status?.otpw ?? null) === 1) {
notifications.push({
id: `tmcwarning/${key}-otpw`,
priority: 'high',
title: i18n.t('App.Notifications.TmcOtpwFlag').toString(),
description: i18n.t('App.Notifications.TmcOtpwFlagText', { name }).toString(),
date,
dismissed: false,
url: 'https://www.klipper3d.org/TMC_Drivers.html#tmc-reports-error-ot1overtemperror',
})
}
})

return notifications
},

getDismiss: (state, getters, rootState) => {
const currentTime = new Date()
const systemBootAt = rootState.server.system_boot_at ?? new Date()
Expand Down

0 comments on commit 81ea9cd

Please sign in to comment.