Update temperature types

This commit is contained in:
Scott Lahteine
2021-04-23 19:14:49 -05:00
parent 51a61c5431
commit 72e3d2492f
16 changed files with 88 additions and 76 deletions

View File

@ -352,7 +352,7 @@ FORCE_INLINE void probe_specific_action(const bool deploy) {
* - If a preheat input is higher than the current target, raise the target temperature.
* - If a preheat input is higher than the current temperature, wait for stabilization.
*/
void Probe::preheat_for_probing(const int16_t hotend_temp, const int16_t bed_temp) {
void Probe::preheat_for_probing(const celsius_t hotend_temp, const celsius_t bed_temp) {
#if HAS_HOTEND && (PROBING_NOZZLE_TEMP || LEVELING_NOZZLE_TEMP)
#define WAIT_FOR_NOZZLE_HEAT
#endif
@ -363,17 +363,17 @@ FORCE_INLINE void probe_specific_action(const bool deploy) {
DEBUG_ECHOPGM("Preheating ");
#if ENABLED(WAIT_FOR_NOZZLE_HEAT)
const int16_t hotendPreheat = hotend_temp > thermalManager.degTargetHotend(0) ? hotend_temp : 0;
const celsius_t hotendPreheat = hotend_temp > thermalManager.degTargetHotend(0) ? hotend_temp : 0;
if (hotendPreheat) {
DEBUG_ECHOPAIR("hotend (", hotendPreheat, ")");
thermalManager.setTargetHotend(hotendPreheat, 0);
}
#elif ENABLED(WAIT_FOR_BED_HEAT)
constexpr int16_t hotendPreheat = 0;
constexpr celsius_t hotendPreheat = 0;
#endif
#if ENABLED(WAIT_FOR_BED_HEAT)
const int16_t bedPreheat = bed_temp > thermalManager.degTargetBed() ? bed_temp : 0;
const celsius_t bedPreheat = bed_temp > thermalManager.degTargetBed() ? bed_temp : 0;
if (bedPreheat) {
if (hotendPreheat) DEBUG_ECHOPGM(" and ");
DEBUG_ECHOPAIR("bed (", bedPreheat, ")");

View File

@ -61,7 +61,7 @@ public:
static xyz_pos_t offset;
#if EITHER(PREHEAT_BEFORE_PROBING, PREHEAT_BEFORE_LEVELING)
static void preheat_for_probing(const int16_t hotend_temp, const int16_t bed_temp);
static void preheat_for_probing(const celsius_t hotend_temp, const celsius_t bed_temp);
#endif
static bool set_deployed(const bool deploy);

View File

@ -382,7 +382,7 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY,
chamber_info_t Temperature::temp_chamber; // = { 0 }
#if HAS_HEATED_CHAMBER
millis_t next_cool_check_ms_2 = 0;
float old_temp = 9999;
celsius_float_t old_temp = 9999;
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});
@ -395,7 +395,7 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY,
#if HAS_COOLER
bool flag_cooler_state;
//bool flag_cooler_excess = false;
float previous_temp = 9999;
celsius_float_t previous_temp = 9999;
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
@ -421,8 +421,8 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY,
#endif
#if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
celsius_t Temperature::redundant_temperature_raw = 0;
float Temperature::redundant_temperature = 0.0;
int16_t Temperature::redundant_temperature_raw = 0;
celsius_float_t Temperature::redundant_temperature = 0.0;
#endif
volatile bool Temperature::raw_temps_ready = false;
@ -508,7 +508,7 @@ volatile bool Temperature::raw_temps_ready = false;
long t_high = 0, t_low = 0;
PID_t tune_pid = { 0, 0, 0 };
float maxT = 0, minT = 10000;
celsius_float_t maxT = 0, minT = 10000;
const bool isbed = (heater_id == H_BED);
const bool ischamber = (heater_id == H_CHAMBER);
@ -544,9 +544,9 @@ volatile bool Temperature::raw_temps_ready = false;
#define GTV(C,B,H) C_GTV(ischamber, C, B_GTV(isbed, B, H))
const uint16_t watch_temp_period = GTV(WATCH_CHAMBER_TEMP_PERIOD, WATCH_BED_TEMP_PERIOD, WATCH_TEMP_PERIOD);
const uint8_t watch_temp_increase = GTV(WATCH_CHAMBER_TEMP_INCREASE, WATCH_BED_TEMP_INCREASE, WATCH_TEMP_INCREASE);
const float watch_temp_target = target - float(watch_temp_increase + GTV(TEMP_CHAMBER_HYSTERESIS, TEMP_BED_HYSTERESIS, TEMP_HYSTERESIS) + 1);
const celsius_float_t watch_temp_target = celsius_float_t(target - watch_temp_increase + GTV(TEMP_CHAMBER_HYSTERESIS, TEMP_BED_HYSTERESIS, TEMP_HYSTERESIS) + 1);
millis_t temp_change_ms = next_temp_ms + SEC_TO_MS(watch_temp_period);
float next_watch_temp = 0.0;
celsius_float_t next_watch_temp = 0.0;
bool heated = false;
#endif
@ -567,7 +567,7 @@ volatile bool Temperature::raw_temps_ready = false;
SHV(bias);
#if ENABLED(PRINTER_EVENT_LEDS)
const float start_temp = GHV(temp_chamber.celsius, temp_bed.celsius, temp_hotend[heater_id].celsius);
const celsius_float_t start_temp = GHV(temp_chamber.celsius, temp_bed.celsius, temp_hotend[heater_id].celsius);
LEDColor color = ONHEATINGSTART();
#endif
@ -2338,7 +2338,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_t current, const_float_t target, const heater_id_t heater_id, const uint16_t period_seconds, const celsius_t hysteresis_degc) {
void Temperature::tr_state_machine_t::run(const_celsius_float_t current, const_celsius_float_t 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
@ -3373,7 +3373,16 @@ void Temperature::isr() {
#include "../gcode/gcode.h"
static void print_heater_state(const_float_t c, const_float_t t
/**
* Print a single heater state in the form:
* Bed: " B:nnn.nn /nnn.nn"
* Chamber: " C:nnn.nn /nnn.nn"
* Probe: " P:nnn.nn /nnn.nn"
* Cooler: " L:nnn.nn /nnn.nn"
* Extruder: " T0:nnn.nn /nnn.nn"
* With ADC: " T0:nnn.nn /nnn.nn (nnn.nn)"
*/
static void print_heater_state(const_celsius_float_t c, const_celsius_float_t t
#if ENABLED(SHOW_TEMP_ADC_VALUES)
, const float r
#endif
@ -3557,12 +3566,12 @@ void Temperature::isr() {
#endif
#if ENABLED(PRINTER_EVENT_LEDS)
const float start_temp = degHotend(target_extruder);
const celsius_float_t start_temp = degHotend(target_extruder);
printerEventLEDs.onHotendHeatingStart();
#endif
bool wants_to_cool = false;
float target_temp = -1.0, old_temp = 9999.0;
celsius_float_t target_temp = -1.0, old_temp = 9999.0;
millis_t now, next_temp_ms = 0, next_cool_check_ms = 0;
wait_for_heatup = true;
do {
@ -3592,7 +3601,7 @@ void Temperature::isr() {
idle();
gcode.reset_stepper_timeout(); // Keep steppers powered
const float temp = degHotend(target_extruder);
const celsius_float_t temp = degHotend(target_extruder);
#if ENABLED(PRINTER_EVENT_LEDS)
// Gradually change LED strip from violet to red as nozzle heats up
@ -3601,7 +3610,7 @@ void Temperature::isr() {
#if TEMP_RESIDENCY_TIME > 0
const float temp_diff = ABS(target_temp - temp);
const celsius_float_t temp_diff = ABS(target_temp - temp);
if (!residency_start_ms) {
// Start the TEMP_RESIDENCY_TIME timer when we reach target temp for the first time.
@ -3695,12 +3704,12 @@ void Temperature::isr() {
#endif
#if ENABLED(PRINTER_EVENT_LEDS)
const float start_temp = degBed();
const celsius_float_t start_temp = degBed();
printerEventLEDs.onBedHeatingStart();
#endif
bool wants_to_cool = false;
float target_temp = -1, old_temp = 9999;
celsius_float_t target_temp = -1, old_temp = 9999;
millis_t now, next_temp_ms = 0, next_cool_check_ms = 0;
wait_for_heatup = true;
do {
@ -3730,7 +3739,7 @@ void Temperature::isr() {
idle();
gcode.reset_stepper_timeout(); // Keep steppers powered
const float temp = degBed();
const celsius_float_t temp = degBed();
#if ENABLED(PRINTER_EVENT_LEDS)
// Gradually change LED strip from blue to violet as bed heats up
@ -3739,7 +3748,7 @@ void Temperature::isr() {
#if TEMP_BED_RESIDENCY_TIME > 0
const float temp_diff = ABS(target_temp - temp);
const celsius_float_t temp_diff = ABS(target_temp - temp);
if (!residency_start_ms) {
// Start the TEMP_BED_RESIDENCY_TIME timer when we reach target temp for the first time.
@ -4021,11 +4030,11 @@ void Temperature::isr() {
idle();
gcode.reset_stepper_timeout(); // Keep steppers powered
const float current_temp = degCooler();
const celsius_float_t current_temp = degCooler();
#if TEMP_COOLER_RESIDENCY_TIME > 0
const float temp_diff = ABS(target_temp - temp);
const celsius_float_t temp_diff = ABS(target_temp - temp);
if (!residency_start_ms) {
// Start the TEMP_COOLER_RESIDENCY_TIME timer when we reach target temp for the first time.

View File

@ -961,7 +961,7 @@ class Temperature {
millis_t timer = 0;
TRState state = TRInactive;
float running_temp;
void run(const_float_t current, const_float_t target, const heater_id_t heater_id, const uint16_t period_seconds, const celsius_t hysteresis_degc);
void run(const_celsius_float_t current, const_celsius_float_t 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];