From 81ea9cdaaf2275ef23127dc688813cf548c51546 Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Sat, 6 Jul 2024 21:46:04 +0200 Subject: [PATCH] feat(notification): add TMC overheating warnings (#1919) --- src/locales/en.json | 6 +++- src/store/gui/notifications/getters.ts | 41 ++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/src/locales/en.json b/src/locales/en.json index 69b336d68..5c403574b 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -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}!", diff --git a/src/store/gui/notifications/getters.ts b/src/store/gui/notifications/getters.ts index 7364dd0a5..6bd197bed 100644 --- a/src/store/gui/notifications/getters.ts +++ b/src/store/gui/notifications/getters.ts @@ -41,6 +41,9 @@ export const getters: GetterTree = { // browser warnings notifications = notifications.concat(getters['getNotificationsBrowserWarnings']) + // TMC overheat warnings + notifications = notifications.concat(getters['getNotificationsOverheatDrivers']) + const mapType = { normal: 2, high: 1, @@ -398,6 +401,44 @@ export const getters: GetterTree = { 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()