Skip to content

Commit

Permalink
Report 40°C on virtual TMC heater channels for any associated driver …
Browse files Browse the repository at this point in the history
…being active
  • Loading branch information
wilriker committed Feb 1, 2019
1 parent de25af1 commit 32cd699
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/Platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3001,6 +3001,23 @@ void Platform::DisableAllDrives()
}
}

#if HAS_SMART_DRIVERS
// Check if at least one driver is NOT in state disabled
bool Platform::IsAnyDriverActive(unsigned int board) const
{
const size_t firstDriver = board * 5;
const size_t lastDriver = min<size_t>(firstDriver + 5, MaxSmartDrivers);
for (size_t driver = firstDriver; driver < lastDriver; ++driver)
{
if (driverState[driver] != DriverStatus::disabled)
{
return true;
}
}
return false;
}
#endif

// Set drives to idle hold if they are enabled. If a drive is disabled, leave it alone.
// Must not be called from an ISR, or with interrupts disabled.
void Platform::SetDriversIdle()
Expand Down Expand Up @@ -4426,7 +4443,8 @@ float Platform::GetTmcDriversTemperature(unsigned int board) const
const uint16_t mask = ((1u << 5) - 1) << (5 * board); // there are 5 drivers on each board
return ((temperatureShutdownDrivers & mask) != 0) ? 150.0
: ((temperatureWarningDrivers & mask) != 0) ? 100.0
: 0.0;
: IsAnyDriverActive(board) ? 40.0
: 0.0;
}

#endif
Expand Down
1 change: 1 addition & 0 deletions src/Platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,7 @@ class Platform
#endif

#if HAS_SMART_DRIVERS
bool IsAnyDriverActive(unsigned int board) const;
float GetTmcDriversTemperature(unsigned int board) const;
void DriverCoolingFansOnOff(uint32_t driverChannelsMonitored, bool on);
unsigned int GetNumSmartDrivers() const { return numSmartDrivers; }
Expand Down

0 comments on commit 32cd699

Please sign in to comment.