⚡️ Apply PTC on all probing (#23764)
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
This commit is contained in:
committed by
Scott Lahteine
parent
56cec9690a
commit
7ec2167a73
@ -28,6 +28,7 @@
|
||||
|
||||
#include "probe_temp_comp.h"
|
||||
#include <math.h>
|
||||
#include "../module/temperature.h"
|
||||
|
||||
ProbeTempComp ptc;
|
||||
|
||||
@ -62,6 +63,7 @@ constexpr temp_calib_t ProbeTempComp::cali_info[TSI_COUNT];
|
||||
|
||||
uint8_t ProbeTempComp::calib_idx; // = 0
|
||||
float ProbeTempComp::init_measurement; // = 0.0
|
||||
bool ProbeTempComp::enabled = true;
|
||||
|
||||
void ProbeTempComp::reset() {
|
||||
TERN_(PTC_PROBE, LOOP_L_N(i, PTC_PROBE_COUNT) z_offsets_probe[i] = z_offsets_probe_default[i]);
|
||||
@ -169,6 +171,13 @@ bool ProbeTempComp::finish_calibration(const TempSensorID tsi) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void ProbeTempComp::apply_compensation(float &meas_z) {
|
||||
if (!enabled) return;
|
||||
TERN_(PTC_BED, compensate_measurement(TSI_BED, thermalManager.degBed(), meas_z));
|
||||
TERN_(PTC_PROBE, compensate_measurement(TSI_PROBE, thermalManager.degProbe(), meas_z));
|
||||
TERN_(PTC_HOTEND, compensate_measurement(TSI_EXT, thermalManager.degHotend(0), meas_z));
|
||||
}
|
||||
|
||||
void ProbeTempComp::compensate_measurement(const TempSensorID tsi, const celsius_t temp, float &meas_z) {
|
||||
const uint8_t measurements = cali_info[tsi].measurements;
|
||||
const celsius_t start_temp = cali_info[tsi].start_temp,
|
||||
|
@ -77,7 +77,6 @@ class ProbeTempComp {
|
||||
static void reset_index() { calib_idx = 0; };
|
||||
static uint8_t get_index() { return calib_idx; }
|
||||
static void reset();
|
||||
static void clear_offsets(const TempSensorID tsi);
|
||||
static void clear_all_offsets() {
|
||||
TERN_(PTC_PROBE, clear_offsets(TSI_PROBE));
|
||||
TERN_(PTC_BED, clear_offsets(TSI_BED));
|
||||
@ -88,10 +87,16 @@ 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 celsius_t temp, float &meas_z);
|
||||
static void set_enabled(const bool ena) { enabled = ena; }
|
||||
|
||||
// Apply all temperature compensation adjustments
|
||||
static void apply_compensation(float &meas_z);
|
||||
|
||||
private:
|
||||
static uint8_t calib_idx;
|
||||
static bool enabled;
|
||||
|
||||
static void clear_offsets(const TempSensorID tsi);
|
||||
|
||||
/**
|
||||
* Base value. Temperature compensation values will be deltas
|
||||
@ -104,6 +109,8 @@ class ProbeTempComp {
|
||||
* to allow generating values of higher temperatures.
|
||||
*/
|
||||
static bool linear_regression(const TempSensorID tsi, float &k, float &d);
|
||||
|
||||
static void compensate_measurement(const TempSensorID tsi, const celsius_t temp, float &meas_z);
|
||||
};
|
||||
|
||||
extern ProbeTempComp ptc;
|
||||
|
Reference in New Issue
Block a user