Keep the curve and thermistor comments timeless
Both headers described the port transformation ("legacy cubic becomes",
"no hand-rolled series needed") rather than what the code is. State the
cubic and the __builtin_log rationale directly.
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -5,9 +5,9 @@
|
|||||||
|
|
||||||
#include <libavr/flash.hpp>
|
#include <libavr/flash.hpp>
|
||||||
|
|
||||||
// The auto-mode fan curve, tabulated at compile time: the legacy cubic
|
// The auto-mode fan curve, tabulated at compile time: a cubic in °C
|
||||||
// (0.002246·x³ − 0.09·x² + 0.91·x, zero below 20 °C) becomes a libavr
|
// (0.002246·x³ − 0.09·x² + 0.91·x, zero below 20 °C) as a flash_table of
|
||||||
// flash_table of duty percent per °C.
|
// duty percent per °C.
|
||||||
namespace app::curve {
|
namespace app::curve {
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ namespace detail {
|
|||||||
consteval double temperature_of(double adc)
|
consteval double temperature_of(double adc)
|
||||||
{
|
{
|
||||||
double resistance = series_resistor * adc / (1023.0 - adc);
|
double resistance = series_resistor * adc / (1023.0 - adc);
|
||||||
// __builtin_log constant-folds on the AVR backend, so no runtime libm
|
// __builtin_log constant-folds on the AVR backend, so the table is
|
||||||
// and no hand-rolled series is needed for the compile-time table.
|
// built at compile time with no runtime libm.
|
||||||
double steinhart = __builtin_log(resistance / nominal_resistance) / beta + 1.0 / (nominal_temperature + 273.15);
|
double steinhart = __builtin_log(resistance / nominal_resistance) / beta + 1.0 / (nominal_temperature + 273.15);
|
||||||
return 1.0 / steinhart - 273.15;
|
return 1.0 / steinhart - 273.15;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user