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(notification): add TMC overheating warnings #1919

Merged
merged 4 commits into from
Jul 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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. This is an indication of a over temperature condition. This can be caused by a too high current. Please check the stepper driver settings and cooling.",
meteyou marked this conversation as resolved.
Show resolved Hide resolved
"TmcOtpwFlag": "Stepper driver warning: OTPW flag set",
"TmcOtpwFlagText": "The stepper driver '{name}' has triggered the OTPW flag. This is an indication of a over temperature condition. This can be caused by a too high current. Please check the stepper driver settings and cooling."
meteyou marked this conversation as resolved.
Show resolved Hide resolved
},
"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
Loading