console: the thermistor table's geometry is named rather than spelled
Steps, counts per step, the rail clearance, the sensor window, the Kelvin offset and the quarter-degree scale were literals the reader had to re-derive (4, 256, 1019, 273.15, the shift by 2). Each is now a constant the table, the interpolation and the battery share. The table is byte-identical. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
78c9071f0c
commit
e44b45dd1e
2 files changed
+45
-28
No files matched your search
+7
-5
@@ -43,7 +43,7 @@ static_assert(duty_entry(99) == 100);
|
||||
// Monotone across the whole table: a warmer reading never asks for less air.
|
||||
consteval bool curve_rises()
|
||||
{
|
||||
for (std::int32_t t = 1; t < 100; ++t) {
|
||||
for (std::int32_t t = 1; t < static_cast<std::int32_t>(app::curve::detail::table.size()); ++t) {
|
||||
if (duty_entry(t) < duty_entry(t - 1)) {
|
||||
return false;
|
||||
}
|
||||
@@ -57,23 +57,25 @@ static_assert(curve_rises());
|
||||
// thermistor's nominal resistance at
|
||||
// adc = full_scale * nominal / (series + nominal), and the equation's own
|
||||
// definition puts that count at the nominal temperature.
|
||||
using app::thermistor::detail::counts_per_step;
|
||||
using app::thermistor::detail::quarters_entry;
|
||||
using app::thermistor::detail::steps;
|
||||
|
||||
inline constexpr std::int32_t nominal_count =
|
||||
static_cast<std::int32_t>(app::thermistor::adc_full_scale * app::thermistor::nominal_resistance /
|
||||
(app::thermistor::series_resistor + app::thermistor::nominal_resistance));
|
||||
static_assert(quarters_entry(nominal_count / 4) >= 100); // 25.00 C, in quarters
|
||||
static_assert(quarters_entry(nominal_count / 4 + 1) < 100); // and the step below it
|
||||
static_assert(quarters_entry(nominal_count / counts_per_step) >= 100); // 25.00 C, in quarters
|
||||
static_assert(quarters_entry(nominal_count / counts_per_step + 1) < 100); // and the step below it
|
||||
|
||||
// Both clamps, at the ends the divider cannot leave.
|
||||
static_assert(quarters_entry(0) == 125 * 4);
|
||||
static_assert(quarters_entry(255) == -40 * 4);
|
||||
static_assert(quarters_entry(steps - 1) == -40 * 4);
|
||||
|
||||
// An NTC on this divider falls with the count: more counts is more resistance
|
||||
// is a colder sensor, over every step of the table.
|
||||
consteval bool thermistor_falls()
|
||||
{
|
||||
for (std::int32_t i = 1; i < 256; ++i) {
|
||||
for (std::int32_t i = 1; i < steps; ++i) {
|
||||
if (quarters_entry(i) > quarters_entry(i - 1)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user