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

Report 40°C on virtual TMC heater channel for any driver being active #180

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
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