Add whole-degree accessors, simplify some temperature-related features (#21685)

This commit is contained in:
Scott Lahteine
2021-04-23 20:19:23 -05:00
committed by GitHub
parent 384e09aa7c
commit c4620bb528
28 changed files with 144 additions and 139 deletions

View File

@@ -34,9 +34,9 @@ enum TempSensorID : uint8_t {
typedef struct {
uint8_t measurements; // Max. number of measurements to be stored (35 - 80°C)
float temp_res, // Resolution in °C between measurements
start_temp, // Base measurement; z-offset == 0
end_temp;
celsius_t temp_res, // Resolution in °C between measurements
start_temp, // Base measurement; z-offset == 0
end_temp;
} temp_calib_t;
/**
@@ -50,25 +50,25 @@ typedef struct {
#define PTC_SAMPLE_COUNT 10U
#endif
#ifndef PTC_SAMPLE_RES
#define PTC_SAMPLE_RES 5.0f
#define PTC_SAMPLE_RES 5
#endif
#ifndef PTC_SAMPLE_START
#define PTC_SAMPLE_START 30.0f
#define PTC_SAMPLE_START 30
#endif
#define PTC_SAMPLE_END ((PTC_SAMPLE_START) + (PTC_SAMPLE_COUNT) * (PTC_SAMPLE_RES))
// Bed temperature calibration constants
#ifndef BTC_PROBE_TEMP
#define BTC_PROBE_TEMP 30.0f
#define BTC_PROBE_TEMP 30
#endif
#ifndef BTC_SAMPLE_COUNT
#define BTC_SAMPLE_COUNT 10U
#endif
#ifndef BTC_SAMPLE_STEP
#define BTC_SAMPLE_RES 5.0f
#define BTC_SAMPLE_RES 5
#endif
#ifndef BTC_SAMPLE_START
#define BTC_SAMPLE_START 60.0f
#define BTC_SAMPLE_START 60
#endif
#define BTC_SAMPLE_END ((BTC_SAMPLE_START) + (BTC_SAMPLE_COUNT) * (BTC_SAMPLE_RES))
@@ -77,7 +77,7 @@ typedef struct {
#endif
#ifndef PTC_PROBE_RAISE
#define PTC_PROBE_RAISE 10.0f
#define PTC_PROBE_RAISE 10
#endif
static constexpr temp_calib_t cali_info_init[TSI_COUNT] = {
@@ -124,7 +124,7 @@ class ProbeTempComp {
static void prepare_new_calibration(const_float_t init_meas_z);
static void push_back_new_measurement(const TempSensorID tsi, const_float_t meas_z);
static bool finish_calibration(const TempSensorID tsi);
static void compensate_measurement(const TempSensorID tsi, const_float_t temp, float &meas_z);
static void compensate_measurement(const TempSensorID tsi, const celsius_t temp, float &meas_z);
private:
static uint8_t calib_idx;
@@ -135,7 +135,7 @@ class ProbeTempComp {
*/
static float init_measurement;
static float get_offset_for_temperature(const TempSensorID tsi, const_float_t temp);
static float get_offset_for_temperature(const TempSensorID tsi, const celsius_t temp);
/**
* Fit a linear function in measured temperature offsets