Add typedef celsius_t (#21374)

This commit is contained in:
Scott Lahteine
2021-03-24 04:11:43 -05:00
committed by GitHub
parent 07c24e72ac
commit e5ff55a1be
35 changed files with 252 additions and 298 deletions

View File

@ -940,11 +940,11 @@ FORCE_INLINE void segment_idle(millis_t &next_idle_ms) {
DualXMode dual_x_carriage_mode = DEFAULT_DUAL_X_CARRIAGE_MODE;
float inactive_extruder_x = X2_MAX_POS, // Used in mode 0 & 1
duplicate_extruder_x_offset = DEFAULT_DUPLICATION_X_OFFSET; // Used in mode 2
duplicate_extruder_x_offset = DEFAULT_DUPLICATION_X_OFFSET; // Used in mode 2 & 3
xyz_pos_t raised_parked_position; // Used in mode 1
bool active_extruder_parked = false; // Used in mode 1 & 2
bool active_extruder_parked = false; // Used in mode 1, 2 & 3
millis_t delayed_move_time = 0; // Used in mode 1
int16_t duplicate_extruder_temp_offset = 0; // Used in mode 2
celsius_t duplicate_extruder_temp_offset = 0; // Used in mode 2 & 3
bool idex_mirrored_mode = false; // Used in mode 3
float x_home_pos(const uint8_t extruder) {

View File

@ -463,13 +463,13 @@ FORCE_INLINE bool all_axes_trusted() { return xyz_bits ==
};
extern DualXMode dual_x_carriage_mode;
extern float inactive_extruder_x, // Used in mode 0 & 1
duplicate_extruder_x_offset; // Used in mode 2 & 3
extern xyz_pos_t raised_parked_position; // Used in mode 1
extern bool active_extruder_parked; // Used in mode 1, 2 & 3
extern millis_t delayed_move_time; // Used in mode 1
extern int16_t duplicate_extruder_temp_offset; // Used in mode 2 & 3
extern bool idex_mirrored_mode; // Used in mode 3
extern float inactive_extruder_x, // Used in mode 0 & 1
duplicate_extruder_x_offset; // Used in mode 2 & 3
extern xyz_pos_t raised_parked_position; // Used in mode 1
extern bool active_extruder_parked; // Used in mode 1, 2 & 3
extern millis_t delayed_move_time; // Used in mode 1
extern celsius_t duplicate_extruder_temp_offset; // Used in mode 2 & 3
extern bool idex_mirrored_mode; // Used in mode 3
FORCE_INLINE bool idex_is_duplicating() { return dual_x_carriage_mode >= DXC_DUPLICATION_MODE; }

View File

@ -197,9 +197,9 @@ float Planner::steps_to_mm[XYZE_N]; // (mm) Millimeters per step
skew_factor_t Planner::skew_factor; // Initialized by settings.load()
#if ENABLED(AUTOTEMP)
float Planner::autotemp_max = 250,
Planner::autotemp_min = 210,
Planner::autotemp_factor = 0.1f;
celsius_t Planner::autotemp_max = 250,
Planner::autotemp_min = 210;
float Planner::autotemp_factor = 0.1f;
bool Planner::autotemp_enabled = false;
#endif
@ -1376,7 +1376,7 @@ void Planner::check_axes_activity() {
#if ENABLED(AUTOTEMP_PROPORTIONAL)
void Planner::_autotemp_update_from_hotend() {
const int16_t target = thermalManager.degTargetHotend(active_extruder);
const celsius_t target = thermalManager.degTargetHotend(active_extruder);
autotemp_min = target + AUTOTEMP_MIN_P;
autotemp_max = target + AUTOTEMP_MAX_P;
}

View File

@ -896,7 +896,8 @@ class Planner {
#endif
#if ENABLED(AUTOTEMP)
static float autotemp_min, autotemp_max, autotemp_factor;
static celsius_t autotemp_min, autotemp_max;
static float autotemp_factor;
static bool autotemp_enabled;
static void autotemp_update();
static void autotemp_M104_M109();

View File

@ -253,7 +253,7 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY,
#if HAS_HOTEND
hotend_info_t Temperature::temp_hotend[HOTEND_TEMPS]; // = { 0 }
const uint16_t Temperature::hotend_maxtemp[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_MAXTEMP, HEATER_1_MAXTEMP, HEATER_2_MAXTEMP, HEATER_3_MAXTEMP, HEATER_4_MAXTEMP, HEATER_5_MAXTEMP, HEATER_6_MAXTEMP, HEATER_7_MAXTEMP);
const celsius_t Temperature::hotend_maxtemp[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_MAXTEMP, HEATER_1_MAXTEMP, HEATER_2_MAXTEMP, HEATER_3_MAXTEMP, HEATER_4_MAXTEMP, HEATER_5_MAXTEMP, HEATER_6_MAXTEMP, HEATER_7_MAXTEMP);
#endif
#if ENABLED(AUTO_POWER_E_FANS)
@ -368,12 +368,8 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY,
#if HAS_HEATED_BED
bed_info_t Temperature::temp_bed; // = { 0 }
// Init min and max temp with extreme values to prevent false errors during startup
#ifdef BED_MINTEMP
int16_t Temperature::mintemp_raw_BED = TEMP_SENSOR_BED_RAW_LO_TEMP;
#endif
#ifdef BED_MAXTEMP
int16_t Temperature::maxtemp_raw_BED = TEMP_SENSOR_BED_RAW_HI_TEMP;
#endif
int16_t Temperature::mintemp_raw_BED = TEMP_SENSOR_BED_RAW_LO_TEMP,
Temperature::maxtemp_raw_BED = TEMP_SENSOR_BED_RAW_HI_TEMP;
TERN_(WATCH_BED, bed_watch_t Temperature::watch_bed); // = { 0 }
IF_DISABLED(PIDTEMPBED, millis_t Temperature::next_bed_check_ms);
#endif
@ -383,12 +379,8 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY,
#if HAS_HEATED_CHAMBER
millis_t next_cool_check_ms_2 = 0;
float old_temp = 9999;
#ifdef CHAMBER_MINTEMP
int16_t Temperature::mintemp_raw_CHAMBER = TEMP_SENSOR_CHAMBER_RAW_LO_TEMP;
#endif
#ifdef CHAMBER_MAXTEMP
int16_t Temperature::maxtemp_raw_CHAMBER = TEMP_SENSOR_CHAMBER_RAW_HI_TEMP;
#endif
int16_t Temperature::mintemp_raw_CHAMBER = TEMP_SENSOR_CHAMBER_RAW_LO_TEMP,
Temperature::maxtemp_raw_CHAMBER = TEMP_SENSOR_CHAMBER_RAW_HI_TEMP;
TERN_(WATCH_CHAMBER, chamber_watch_t Temperature::watch_chamber{0});
IF_DISABLED(PIDTEMPCHAMBER, millis_t Temperature::next_chamber_check_ms);
#endif
@ -400,12 +392,8 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY,
bool flag_cooler_state;
//bool flag_cooler_excess = false;
float previous_temp = 9999;
#ifdef COOLER_MINTEMP
int16_t Temperature::mintemp_raw_COOLER = TEMP_SENSOR_COOLER_RAW_LO_TEMP;
#endif
#ifdef COOLER_MAXTEMP
int16_t Temperature::maxtemp_raw_COOLER = TEMP_SENSOR_COOLER_RAW_HI_TEMP;
#endif
int16_t Temperature::mintemp_raw_COOLER = TEMP_SENSOR_COOLER_RAW_LO_TEMP,
Temperature::maxtemp_raw_COOLER = TEMP_SENSOR_COOLER_RAW_HI_TEMP;
#if WATCH_COOLER
cooler_watch_t Temperature::watch_cooler{0};
#endif
@ -419,7 +407,7 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY,
#if ENABLED(PREVENT_COLD_EXTRUSION)
bool Temperature::allow_cold_extrude = false;
int16_t Temperature::extrude_min_temp = EXTRUDE_MINTEMP;
celsius_t Temperature::extrude_min_temp = EXTRUDE_MINTEMP;
#endif
// private:
@ -429,7 +417,7 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY,
#endif
#if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
uint16_t Temperature::redundant_temperature_raw = 0;
celsius_t Temperature::redundant_temperature_raw = 0;
float Temperature::redundant_temperature = 0.0;
#endif
@ -474,7 +462,7 @@ volatile bool Temperature::raw_temps_ready = false;
#endif
#if ENABLED(SINGLENOZZLE_STANDBY_TEMP)
uint16_t Temperature::singlenozzle_temp[EXTRUDERS];
celsius_t Temperature::singlenozzle_temp[EXTRUDERS];
#if HAS_FAN
uint8_t Temperature::singlenozzle_fan_speed[EXTRUDERS];
#endif
@ -1566,22 +1554,22 @@ void Temperature::manage_heater() {
* Bisect search for the range of the 'raw' value, then interpolate
* proportionally between the under and over values.
*/
#define SCAN_THERMISTOR_TABLE(TBL,LEN) do{ \
uint8_t l = 0, r = LEN, m; \
for (;;) { \
m = (l + r) >> 1; \
if (!m) return int16_t(pgm_read_word(&TBL[0].celsius)); \
if (m == l || m == r) return int16_t(pgm_read_word(&TBL[LEN-1].celsius)); \
int16_t v00 = pgm_read_word(&TBL[m-1].value), \
v10 = pgm_read_word(&TBL[m-0].value); \
if (raw < v00) r = m; \
else if (raw > v10) l = m; \
else { \
const int16_t v01 = int16_t(pgm_read_word(&TBL[m-1].celsius)), \
v11 = int16_t(pgm_read_word(&TBL[m-0].celsius)); \
return v01 + (raw - v00) * float(v11 - v01) / float(v10 - v00); \
} \
} \
#define SCAN_THERMISTOR_TABLE(TBL,LEN) do{ \
uint8_t l = 0, r = LEN, m; \
for (;;) { \
m = (l + r) >> 1; \
if (!m) return celsius_t(pgm_read_word(&TBL[0].celsius)); \
if (m == l || m == r) return celsius_t(pgm_read_word(&TBL[LEN-1].celsius)); \
int16_t v00 = pgm_read_word(&TBL[m-1].value), \
v10 = pgm_read_word(&TBL[m-0].value); \
if (raw < v00) r = m; \
else if (raw > v10) l = m; \
else { \
const celsius_t v01 = celsius_t(pgm_read_word(&TBL[m-1].celsius)), \
v11 = celsius_t(pgm_read_word(&TBL[m-0].celsius)); \
return v01 + (raw - v00) * float(v11 - v01) / float(v10 - v00); \
} \
} \
}while(0)
#if HAS_USER_THERMISTORS
@ -1663,7 +1651,7 @@ void Temperature::manage_heater() {
SERIAL_EOL();
}
float Temperature::user_thermistor_to_deg_c(const uint8_t t_index, const int raw) {
celsius_t Temperature::user_thermistor_to_deg_c(const uint8_t t_index, const int raw) {
//#if (MOTHERBOARD == BOARD_RAMPS_14_EFB)
// static uint32_t clocks_total = 0;
// static uint32_t calls = 0;
@ -1712,7 +1700,7 @@ void Temperature::manage_heater() {
#if HAS_HOTEND
// Derived from RepRap FiveD extruder::getTemperature()
// For hot end temperature measurement.
float Temperature::analog_to_celsius_hotend(const int raw, const uint8_t e) {
celsius_t Temperature::analog_to_celsius_hotend(const int raw, const uint8_t e) {
if (e > HOTENDS - DISABLED(TEMP_SENSOR_1_AS_REDUNDANT)) {
SERIAL_ERROR_START();
SERIAL_ECHO(e);
@ -1821,7 +1809,7 @@ void Temperature::manage_heater() {
#if HAS_HEATED_BED
// For bed temperature measurement.
float Temperature::analog_to_celsius_bed(const int raw) {
celsius_t Temperature::analog_to_celsius_bed(const int raw) {
#if TEMP_SENSOR_BED_IS_CUSTOM
return user_thermistor_to_deg_c(CTI_BED, raw);
#elif TEMP_SENSOR_BED_IS_THERMISTOR
@ -1839,7 +1827,7 @@ void Temperature::manage_heater() {
#if HAS_TEMP_CHAMBER
// For chamber temperature measurement.
float Temperature::analog_to_celsius_chamber(const int raw) {
celsius_t Temperature::analog_to_celsius_chamber(const int raw) {
#if TEMP_SENSOR_CHAMBER_IS_CUSTOM
return user_thermistor_to_deg_c(CTI_CHAMBER, raw);
#elif TEMP_SENSOR_CHAMBER_IS_THERMISTOR
@ -1857,7 +1845,7 @@ void Temperature::manage_heater() {
#if HAS_TEMP_COOLER
// For cooler temperature measurement.
float Temperature::analog_to_celsius_cooler(const int raw) {
celsius_t Temperature::analog_to_celsius_cooler(const int raw) {
#if TEMP_SENSOR_COOLER_IS_CUSTOM
return user_thermistor_to_deg_c(CTI_COOLER, raw);
#elif TEMP_SENSOR_COOLER_IS_THERMISTOR
@ -1875,7 +1863,7 @@ void Temperature::manage_heater() {
#if HAS_TEMP_PROBE
// For probe temperature measurement.
float Temperature::analog_to_celsius_probe(const int raw) {
celsius_t Temperature::analog_to_celsius_probe(const int raw) {
#if TEMP_SENSOR_PROBE_IS_CUSTOM
return user_thermistor_to_deg_c(CTI_PROBE, raw);
#elif TEMP_SENSOR_PROBE_IS_THERMISTOR
@ -2191,13 +2179,13 @@ void Temperature::init() {
#if HAS_HOTEND
#define _TEMP_MIN_E(NR) do{ \
const int16_t tmin = _MAX(HEATER_##NR##_MINTEMP, TERN(TEMP_SENSOR_##NR##_IS_CUSTOM, 0, (int16_t)pgm_read_word(&TEMPTABLE_##NR [TEMP_SENSOR_##NR##_MINTEMP_IND].celsius))); \
const celsius_t tmin = _MAX(HEATER_##NR##_MINTEMP, TERN(TEMP_SENSOR_##NR##_IS_CUSTOM, 0, pgm_read_word(&TEMPTABLE_##NR [TEMP_SENSOR_##NR##_MINTEMP_IND].celsius))); \
temp_range[NR].mintemp = tmin; \
while (analog_to_celsius_hotend(temp_range[NR].raw_min, NR) < tmin) \
temp_range[NR].raw_min += TEMPDIR(NR) * (OVERSAMPLENR); \
}while(0)
#define _TEMP_MAX_E(NR) do{ \
const int16_t tmax = _MIN(HEATER_##NR##_MAXTEMP, TERN(TEMP_SENSOR_##NR##_IS_CUSTOM, 2000, (int16_t)pgm_read_word(&TEMPTABLE_##NR [TEMP_SENSOR_##NR##_MAXTEMP_IND].celsius) - 1)); \
const celsius_t tmax = _MIN(HEATER_##NR##_MAXTEMP, TERN(TEMP_SENSOR_##NR##_IS_CUSTOM, 2000, pgm_read_word(&TEMPTABLE_##NR [TEMP_SENSOR_##NR##_MAXTEMP_IND].celsius) - 1)); \
temp_range[NR].maxtemp = tmax; \
while (analog_to_celsius_hotend(temp_range[NR].raw_max, NR) > tmax) \
temp_range[NR].raw_max -= TEMPDIR(NR) * (OVERSAMPLENR); \
@ -2257,30 +2245,18 @@ void Temperature::init() {
#endif // HAS_HOTEND
#if HAS_HEATED_BED
#ifdef BED_MINTEMP
while (analog_to_celsius_bed(mintemp_raw_BED) < BED_MINTEMP) mintemp_raw_BED += TEMPDIR(BED) * (OVERSAMPLENR);
#endif
#ifdef BED_MAXTEMP
while (analog_to_celsius_bed(maxtemp_raw_BED) > BED_MAXTEMP) maxtemp_raw_BED -= TEMPDIR(BED) * (OVERSAMPLENR);
#endif
#endif // HAS_HEATED_BED
while (analog_to_celsius_bed(mintemp_raw_BED) < BED_MINTEMP) mintemp_raw_BED += TEMPDIR(BED) * (OVERSAMPLENR);
while (analog_to_celsius_bed(maxtemp_raw_BED) > BED_MAXTEMP) maxtemp_raw_BED -= TEMPDIR(BED) * (OVERSAMPLENR);
#endif
#if HAS_HEATED_CHAMBER
#ifdef CHAMBER_MINTEMP
while (analog_to_celsius_chamber(mintemp_raw_CHAMBER) < CHAMBER_MINTEMP) mintemp_raw_CHAMBER += TEMPDIR(CHAMBER) * (OVERSAMPLENR);
#endif
#ifdef CHAMBER_MAXTEMP
while (analog_to_celsius_chamber(maxtemp_raw_CHAMBER) > CHAMBER_MAXTEMP) maxtemp_raw_CHAMBER -= TEMPDIR(CHAMBER) * (OVERSAMPLENR);
#endif
while (analog_to_celsius_chamber(mintemp_raw_CHAMBER) < CHAMBER_MINTEMP) mintemp_raw_CHAMBER += TEMPDIR(CHAMBER) * (OVERSAMPLENR);
while (analog_to_celsius_chamber(maxtemp_raw_CHAMBER) > CHAMBER_MAXTEMP) maxtemp_raw_CHAMBER -= TEMPDIR(CHAMBER) * (OVERSAMPLENR);
#endif
#if HAS_COOLER
#ifdef COOLER_MINTEMP
while (analog_to_celsius_cooler(mintemp_raw_COOLER) > COOLER_MINTEMP) mintemp_raw_COOLER += TEMPDIR(COOLER) * (OVERSAMPLENR);
#endif
#ifdef COOLER_MAXTEMP
while (analog_to_celsius_cooler(maxtemp_raw_COOLER) < COOLER_MAXTEMP) maxtemp_raw_COOLER -= TEMPDIR(COOLER) * (OVERSAMPLENR);
#endif
while (analog_to_celsius_cooler(mintemp_raw_COOLER) > COOLER_MINTEMP) mintemp_raw_COOLER += TEMPDIR(COOLER) * (OVERSAMPLENR);
while (analog_to_celsius_cooler(maxtemp_raw_COOLER) < COOLER_MAXTEMP) maxtemp_raw_COOLER -= TEMPDIR(COOLER) * (OVERSAMPLENR);
#endif
TERN_(PROBING_HEATERS_OFF, paused = false);
@ -2345,7 +2321,7 @@ void Temperature::init() {
*
* TODO: Embed the last 3 parameters during init, if not less optimal
*/
void Temperature::tr_state_machine_t::run(const float &current, const float &target, const heater_id_t heater_id, const uint16_t period_seconds, const uint16_t hysteresis_degc) {
void Temperature::tr_state_machine_t::run(const float &current, const float &target, const heater_id_t heater_id, const uint16_t period_seconds, const celsius_t hysteresis_degc) {
#if HEATER_IDLE_HANDLER
// Convert the given heater_id_t to an idle array index
@ -2554,7 +2530,7 @@ void Temperature::disable_all_heaters() {
#if HAS_MULTI_MAX_TC
// Needed to return the correct temp when this is called between readings
static uint16_t max_tc_temp_previous[MAX_TC_COUNT] = { 0 };
static celsius_t max_tc_temp_previous[MAX_TC_COUNT] = { 0 };
#define THERMO_TEMP(I) max_tc_temp_previous[I]
#define THERMO_SEL(A,B) (hindex ? (B) : (A))
#define MAX6675_WRITE(V) do{ switch (hindex) { case 1: WRITE(MAX6675_SS2_PIN, V); break; default: WRITE(MAX6675_SS_PIN, V); } }while(0)

View File

@ -179,7 +179,7 @@ enum ADCSensorState : char {
typedef struct TempInfo {
uint16_t acc;
int16_t raw;
float celsius;
celsius_t celsius;
inline void reset() { acc = 0; }
inline void sample(const uint16_t s) { acc += s; }
inline void update() { raw = acc; }
@ -187,7 +187,7 @@ typedef struct TempInfo {
// A PWM heater with temperature sensor
typedef struct HeaterInfo : public TempInfo {
int16_t target;
celsius_t target;
uint8_t soft_pwm_amount;
} heater_info_t;
@ -228,14 +228,14 @@ struct PIDHeaterInfo : public HeaterInfo {
// Heater watch handling
template <int INCREASE, int HYSTERESIS, millis_t PERIOD>
struct HeaterWatch {
uint16_t target;
celsius_t target;
millis_t next_ms;
inline bool elapsed(const millis_t &ms) { return next_ms && ELAPSED(ms, next_ms); }
inline bool elapsed() { return elapsed(millis()); }
inline void restart(const int16_t curr, const int16_t tgt) {
inline void restart(const celsius_t curr, const celsius_t tgt) {
if (tgt) {
const int16_t newtarget = curr + INCREASE;
const celsius_t newtarget = curr + INCREASE;
if (newtarget < tgt - HYSTERESIS - 1) {
target = newtarget;
next_ms = millis() + SEC_TO_MS(PERIOD);
@ -261,8 +261,8 @@ struct HeaterWatch {
// Temperature sensor read value ranges
typedef struct { int16_t raw_min, raw_max; } raw_range_t;
typedef struct { int16_t mintemp, maxtemp; } celsius_range_t;
typedef struct { int16_t raw_min, raw_max, mintemp, maxtemp; } temp_range_t;
typedef struct { celsius_t mintemp, maxtemp; } celsius_range_t;
typedef struct { int16_t raw_min, raw_max; celsius_t mintemp, maxtemp; } temp_range_t;
#define THERMISTOR_ABS_ZERO_C -273.15f // bbbbrrrrr cold !
#define THERMISTOR_RESISTANCE_NOMINAL_C 25.0f // mmmmm comfortable
@ -323,8 +323,8 @@ class Temperature {
#if HAS_HOTEND
#define HOTEND_TEMPS (HOTENDS + ENABLED(TEMP_SENSOR_1_AS_REDUNDANT))
static hotend_info_t temp_hotend[HOTEND_TEMPS];
static const uint16_t hotend_maxtemp[HOTENDS];
FORCE_INLINE static uint16_t hotend_max_target(const uint8_t e) { return hotend_maxtemp[e] - (HOTEND_OVERSHOOT); }
static const celsius_t hotend_maxtemp[HOTENDS];
FORCE_INLINE static celsius_t hotend_max_target(const uint8_t e) { return hotend_maxtemp[e] - (HOTEND_OVERSHOOT); }
#endif
TERN_(HAS_HEATED_BED, static bed_info_t temp_bed);
TERN_(HAS_TEMP_PROBE, static probe_info_t temp_probe);
@ -342,8 +342,8 @@ class Temperature {
#if ENABLED(PREVENT_COLD_EXTRUSION)
static bool allow_cold_extrude;
static int16_t extrude_min_temp;
FORCE_INLINE static bool tooCold(const int16_t temp) { return allow_cold_extrude ? false : temp < extrude_min_temp - (TEMP_WINDOW); }
static celsius_t extrude_min_temp;
FORCE_INLINE static bool tooCold(const celsius_t temp) { return allow_cold_extrude ? false : temp < extrude_min_temp - (TEMP_WINDOW); }
FORCE_INLINE static bool tooColdToExtrude(const uint8_t E_NAME) {
return tooCold(degHotend(HOTEND_INDEX));
}
@ -359,7 +359,7 @@ class Temperature {
FORCE_INLINE static bool targetHotEnoughToExtrude(const uint8_t e) { return !targetTooColdToExtrude(e); }
#if ENABLED(SINGLENOZZLE_STANDBY_FAN)
static uint16_t singlenozzle_temp[EXTRUDERS];
static celsius_t singlenozzle_temp[EXTRUDERS];
#if HAS_FAN
static uint8_t singlenozzle_fan_speed[EXTRUDERS];
#endif
@ -411,7 +411,7 @@ class Temperature {
#if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
static uint16_t redundant_temperature_raw;
static float redundant_temperature;
static celsius_t redundant_temperature;
#endif
#if ENABLED(PID_EXTRUSION_SCALING)
@ -424,34 +424,19 @@ class Temperature {
#if HAS_HEATED_BED
TERN_(WATCH_BED, static bed_watch_t watch_bed);
IF_DISABLED(PIDTEMPBED, static millis_t next_bed_check_ms);
#ifdef BED_MINTEMP
static int16_t mintemp_raw_BED;
#endif
#ifdef BED_MAXTEMP
static int16_t maxtemp_raw_BED;
#endif
static int16_t mintemp_raw_BED, maxtemp_raw_BED;
#endif
#if HAS_HEATED_CHAMBER
TERN_(WATCH_CHAMBER, static chamber_watch_t watch_chamber);
TERN(PIDTEMPCHAMBER,,static millis_t next_chamber_check_ms);
#ifdef CHAMBER_MINTEMP
static int16_t mintemp_raw_CHAMBER;
#endif
#ifdef CHAMBER_MAXTEMP
static int16_t maxtemp_raw_CHAMBER;
#endif
static int16_t mintemp_raw_CHAMBER, maxtemp_raw_CHAMBER;
#endif
#if HAS_COOLER
TERN_(WATCH_COOLER, static cooler_watch_t watch_cooler);
static millis_t next_cooler_check_ms, cooler_fan_flush_ms;
#ifdef COOLER_MINTEMP
static int16_t mintemp_raw_COOLER;
#endif
#ifdef COOLER_MAXTEMP
static int16_t maxtemp_raw_COOLER;
#endif
static int16_t mintemp_raw_COOLER, maxtemp_raw_COOLER;
#endif
#ifdef MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED
@ -488,7 +473,7 @@ class Temperature {
static user_thermistor_t user_thermistor[USER_THERMISTORS];
static void log_user_thermistor(const uint8_t t_index, const bool eprom=false);
static void reset_user_thermistors();
static float user_thermistor_to_deg_c(const uint8_t t_index, const int raw);
static celsius_t user_thermistor_to_deg_c(const uint8_t t_index, const int raw);
static bool set_pull_up_res(int8_t t_index, float value) {
//if (!WITHIN(t_index, 0, USER_THERMISTORS - 1)) return false;
if (!WITHIN(value, 1, 1000000)) return false;
@ -516,19 +501,19 @@ class Temperature {
#endif
#if HAS_HOTEND
static float analog_to_celsius_hotend(const int raw, const uint8_t e);
static celsius_t analog_to_celsius_hotend(const int raw, const uint8_t e);
#endif
#if HAS_HEATED_BED
static float analog_to_celsius_bed(const int raw);
static celsius_t analog_to_celsius_bed(const int raw);
#endif
#if HAS_TEMP_PROBE
static float analog_to_celsius_probe(const int raw);
static celsius_t analog_to_celsius_probe(const int raw);
#endif
#if HAS_TEMP_CHAMBER
static float analog_to_celsius_chamber(const int raw);
static celsius_t analog_to_celsius_chamber(const int raw);
#endif
#if HAS_TEMP_COOLER
static float analog_to_celsius_cooler(const int raw);
static celsius_t analog_to_celsius_cooler(const int raw);
#endif
#if HAS_FAN
@ -620,7 +605,7 @@ class Temperature {
}
#endif
FORCE_INLINE static int16_t degTargetHotend(const uint8_t E_NAME) {
FORCE_INLINE static celsius_t degTargetHotend(const uint8_t E_NAME) {
return TERN0(HAS_HOTEND, temp_hotend[HOTEND_INDEX].target);
}
@ -632,7 +617,7 @@ class Temperature {
#if HAS_HOTEND
static void setTargetHotend(const int16_t celsius, const uint8_t E_NAME) {
static void setTargetHotend(const celsius_t celsius, const uint8_t E_NAME) {
const uint8_t ee = HOTEND_INDEX;
#ifdef MILLISECONDS_PREHEAT_TIME
if (celsius == 0)
@ -678,12 +663,12 @@ class Temperature {
#if HAS_HEATED_BED
#if ENABLED(SHOW_TEMP_ADC_VALUES)
FORCE_INLINE static int16_t rawBedTemp() { return temp_bed.raw; }
FORCE_INLINE static int16_t rawBedTemp() { return temp_bed.raw; }
#endif
FORCE_INLINE static float degBed() { return temp_bed.celsius; }
FORCE_INLINE static int16_t degTargetBed() { return temp_bed.target; }
FORCE_INLINE static bool isHeatingBed() { return temp_bed.target > temp_bed.celsius; }
FORCE_INLINE static bool isCoolingBed() { return temp_bed.target < temp_bed.celsius; }
FORCE_INLINE static celsius_t degBed() { return temp_bed.celsius; }
FORCE_INLINE static celsius_t degTargetBed() { return temp_bed.target; }
FORCE_INLINE static bool isHeatingBed() { return temp_bed.target > temp_bed.celsius; }
FORCE_INLINE static bool isCoolingBed() { return temp_bed.target < temp_bed.celsius; }
#if WATCH_BED
static void start_watching_bed();
@ -691,15 +676,9 @@ class Temperature {
static inline void start_watching_bed() {}
#endif
static void setTargetBed(const int16_t celsius) {
static void setTargetBed(const celsius_t celsius) {
TERN_(AUTO_POWER_CONTROL, if (celsius) powerManager.power_on());
temp_bed.target =
#ifdef BED_MAX_TARGET
_MIN(celsius, BED_MAX_TARGET)
#else
celsius
#endif
;
temp_bed.target = _MIN(celsius, BED_MAX_TARGET);
start_watching_bed();
}
@ -735,14 +714,13 @@ class Temperature {
#if HAS_TEMP_CHAMBER
#if ENABLED(SHOW_TEMP_ADC_VALUES)
FORCE_INLINE static int16_t rawChamberTemp() { return temp_chamber.raw; }
FORCE_INLINE static int16_t rawChamberTemp() { return temp_chamber.raw; }
#endif
FORCE_INLINE static float degChamber() { return temp_chamber.celsius; }
FORCE_INLINE static float degChamber() { return temp_chamber.celsius; }
#if HAS_HEATED_CHAMBER
FORCE_INLINE static int16_t degTargetChamber() { return temp_chamber.target; }
FORCE_INLINE static bool isHeatingChamber() { return temp_chamber.target > temp_chamber.celsius; }
FORCE_INLINE static bool isCoolingChamber() { return temp_chamber.target < temp_chamber.celsius; }
FORCE_INLINE static celsius_t degTargetChamber() { return temp_chamber.target; }
FORCE_INLINE static bool isHeatingChamber() { return temp_chamber.target > temp_chamber.celsius; }
FORCE_INLINE static bool isCoolingChamber() { return temp_chamber.target < temp_chamber.celsius; }
static bool wait_for_chamber(const bool no_wait_for_cooling=true);
#endif
#endif
@ -754,27 +732,21 @@ class Temperature {
#endif
#if HAS_HEATED_CHAMBER
static void setTargetChamber(const int16_t celsius) {
temp_chamber.target =
#ifdef CHAMBER_MAXTEMP
_MIN(celsius, CHAMBER_MAXTEMP - 10)
#else
celsius
#endif
;
static void setTargetChamber(const celsius_t celsius) {
temp_chamber.target = _MIN(celsius, CHAMBER_MAX_TARGET);
start_watching_chamber();
}
#endif
#if HAS_TEMP_COOLER
#if ENABLED(SHOW_TEMP_ADC_VALUES)
FORCE_INLINE static int16_t rawCoolerTemp() { return temp_cooler.raw; }
FORCE_INLINE static int16_t rawCoolerTemp() { return temp_cooler.raw; }
#endif
FORCE_INLINE static float degCooler() { return temp_cooler.celsius; }
FORCE_INLINE static float degCooler() { return temp_cooler.celsius; }
#if HAS_COOLER
FORCE_INLINE static int16_t degTargetCooler() { return temp_cooler.target; }
FORCE_INLINE static bool isLaserHeating() { return temp_cooler.target > temp_cooler.celsius; }
FORCE_INLINE static bool isLaserCooling() { return temp_cooler.target < temp_cooler.celsius; }
FORCE_INLINE static celsius_t degTargetCooler() { return temp_cooler.target; }
FORCE_INLINE static bool isLaserHeating() { return temp_cooler.target > temp_cooler.celsius; }
FORCE_INLINE static bool isLaserCooling() { return temp_cooler.target < temp_cooler.celsius; }
static bool wait_for_cooler(const bool no_wait_for_cooling=true);
#endif
#endif
@ -786,7 +758,7 @@ class Temperature {
#endif
#if HAS_COOLER
static void setTargetCooler(const int16_t celsius) {
static void setTargetCooler(const celsius_t celsius) {
temp_cooler.target = constrain(celsius, COOLER_MIN_TARGET, COOLER_MAX_TARGET);
start_watching_cooler();
}
@ -945,7 +917,7 @@ class Temperature {
millis_t timer = 0;
TRState state = TRInactive;
float running_temp;
void run(const float &current, const float &target, const heater_id_t heater_id, const uint16_t period_seconds, const uint16_t hysteresis_degc);
void run(const float &current, const float &target, const heater_id_t heater_id, const uint16_t period_seconds, const celsius_t hysteresis_degc);
} tr_state_machine_t;
static tr_state_machine_t tr_state_machine[NR_HEATER_RUNAWAY];

View File

@ -44,7 +44,7 @@
#define ANY_THERMISTOR_IS(n) (TEMP_SENSOR_0_THERMISTOR_ID == n || TEMP_SENSOR_1_THERMISTOR_ID == n || TEMP_SENSOR_2_THERMISTOR_ID == n || TEMP_SENSOR_3_THERMISTOR_ID == n || TEMP_SENSOR_4_THERMISTOR_ID == n || TEMP_SENSOR_5_THERMISTOR_ID == n || TEMP_SENSOR_6_THERMISTOR_ID == n || TEMP_SENSOR_7_THERMISTOR_ID == n || TEMP_SENSOR_BED_THERMISTOR_ID == n || TEMP_SENSOR_CHAMBER_THERMISTOR_ID == n || TEMP_SENSOR_COOLER_THERMISTOR_ID == n || TEMP_SENSOR_PROBE_THERMISTOR_ID == n)
typedef struct { int16_t value, celsius; } temp_entry_t;
typedef struct { int16_t value; celsius_t celsius; } temp_entry_t;
// Pt1000 and Pt100 handling
//