From 8d86fc821d73b057a14af9db24d90e99b7b0e31b Mon Sep 17 00:00:00 2001 From: vintagepc <53943260+vintagepc@users.noreply.github.com> Date: Tue, 18 Jan 2022 08:38:37 -0500 Subject: [PATCH] Fix heater freeze on power loss/reset (#353) --- parts/boards/EinsyRambo.cpp | 2 ++ parts/components/Heater.cpp | 4 ++++ parts/components/Heater.h | 3 +++ 3 files changed, 9 insertions(+) diff --git a/parts/boards/EinsyRambo.cpp b/parts/boards/EinsyRambo.cpp index dd74faaa..de26b1d9 100644 --- a/parts/boards/EinsyRambo.cpp +++ b/parts/boards/EinsyRambo.cpp @@ -284,6 +284,8 @@ namespace Boards SetPin(Y_TMC2130_CS,1); SetPin(Z_TMC2130_CS,1); SetPin(E0_TMC2130_CS,1); + + hExtruder.Reset(); } }; // namespace Boards diff --git a/parts/components/Heater.cpp b/parts/components/Heater.cpp index afb41c29..7b8893c3 100644 --- a/parts/components/Heater.cpp +++ b/parts/components/Heater.cpp @@ -69,6 +69,10 @@ avr_cycle_count_t Heater::OnTempTick(avr_t * pAVR, avr_cycle_count_t) return 0; } +void Heater::Reset() +{ + RegisterTimerUsec(m_fcnTempTick, 100000, this); +} void Heater::OnPWMChanged(struct avr_irq_t *,uint32_t value) { diff --git a/parts/components/Heater.h b/parts/components/Heater.h index ec3baa97..441009c3 100644 --- a/parts/components/Heater.h +++ b/parts/components/Heater.h @@ -60,6 +60,9 @@ class Heater : public BasePeripheral, public Scriptable, public GLIndicator // Change SoftPWM mode after creation inline void SetSoftPWM(bool bVal) { m_bIsBed = bVal; } + // Reset heater + void Reset(); + protected: Scriptable::LineStatus ProcessAction (unsigned int iAct, const std::vector &vArgs) override;