Skip to content

Commit

Permalink
Tidied up M307 processing
Browse files Browse the repository at this point in the history
  • Loading branch information
dc42 committed Nov 11, 2024
1 parent ae18f35 commit 72d8511
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/Heating/Heater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,22 +151,18 @@ GCodeResult Heater::SetOrReportModel(unsigned int heater, GCodeBuffer& gb, const

if (gb.Seen('K'))
{
// New style model parameters
// New style cooling rate parameters
seen = true;
float coolingRates[2];
size_t numValues = 2;
gb.GetFloatArray(coolingRates, numValues, false);
basicCoolingRate = coolingRates[0];
fanCoolingRate = (numValues == 2) ? coolingRates[1] : 0.0;
if (gb.Seen('R'))
{
heatingRate = gb.GetPositiveFValue();
}
gb.TryGetFValue('E', coolingRateExponent, seen);
}
else if (gb.Seen('C'))
{
// Old style model parameters
// Old style cooling time constant parameters
seen = true;
float timeConstants[2];
size_t numValues = 2;
Expand All @@ -176,17 +172,17 @@ GCodeResult Heater::SetOrReportModel(unsigned int heater, GCodeBuffer& gb, const
coolingRateExponent = 1.0;
}

if (gb.TryGetFValue('R', heatingRate, seen))
if (gb.Seen('R'))
{
// We have the heating rate
seen = true;
heatingRate = gb.GetPositiveFValue();
}
else
{
float gain;
if (gb.TryGetFValue('A', gain, seen))
{
// Old style heating model. A = gain, C = cooling time constant
seen = true;
heatingRate = gain * basicCoolingRate * 0.01;
}
}
Expand Down

0 comments on commit 72d8511

Please sign in to comment.