|
@ -170,14 +170,22 @@ class Temperature { |
|
|
#if ENABLED(PREVENT_COLD_EXTRUSION) |
|
|
#if ENABLED(PREVENT_COLD_EXTRUSION) |
|
|
static bool allow_cold_extrude; |
|
|
static bool allow_cold_extrude; |
|
|
static int16_t extrude_min_temp; |
|
|
static int16_t extrude_min_temp; |
|
|
static bool tooColdToExtrude(uint8_t e) { |
|
|
FORCE_INLINE static bool tooCold(const int16_t temp) { return allow_cold_extrude ? false : temp < extrude_min_temp; } |
|
|
|
|
|
FORCE_INLINE static bool tooColdToExtrude(const uint8_t e) { |
|
|
#if HOTENDS == 1 |
|
|
#if HOTENDS == 1 |
|
|
UNUSED(e); |
|
|
UNUSED(e); |
|
|
#endif |
|
|
#endif |
|
|
return allow_cold_extrude ? false : degHotend(HOTEND_INDEX) < extrude_min_temp; |
|
|
return tooCold(degHotend(HOTEND_INDEX)); |
|
|
|
|
|
} |
|
|
|
|
|
FORCE_INLINE static bool targetTooColdToExtrude(const uint8_t e) { |
|
|
|
|
|
#if HOTENDS == 1 |
|
|
|
|
|
UNUSED(e); |
|
|
|
|
|
#endif |
|
|
|
|
|
return tooCold(degTargetHotend(HOTEND_INDEX)); |
|
|
} |
|
|
} |
|
|
#else |
|
|
#else |
|
|
static bool tooColdToExtrude(uint8_t e) { UNUSED(e); return false; } |
|
|
FORCE_INLINE static bool tooColdToExtrude(const uint8_t e) { UNUSED(e); return false; } |
|
|
|
|
|
FORCE_INLINE static bool targetTooColdToExtrude(const uint8_t e) { UNUSED(e); return false; } |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
private: |
|
|
private: |
|
@ -285,8 +293,11 @@ class Temperature { |
|
|
/**
|
|
|
/**
|
|
|
* Static (class) methods |
|
|
* Static (class) methods |
|
|
*/ |
|
|
*/ |
|
|
static float analog2temp(int raw, uint8_t e); |
|
|
static float analog2temp(const int raw, const uint8_t e); |
|
|
static float analog2tempBed(int raw); |
|
|
|
|
|
|
|
|
#if HAS_TEMP_BED |
|
|
|
|
|
static float analog2tempBed(const int raw); |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* Called from the Temperature ISR |
|
|
* Called from the Temperature ISR |
|
@ -302,19 +313,19 @@ class Temperature { |
|
|
* Preheating hotends |
|
|
* Preheating hotends |
|
|
*/ |
|
|
*/ |
|
|
#ifdef MILLISECONDS_PREHEAT_TIME |
|
|
#ifdef MILLISECONDS_PREHEAT_TIME |
|
|
static bool is_preheating(uint8_t e) { |
|
|
static bool is_preheating(const uint8_t e) { |
|
|
#if HOTENDS == 1 |
|
|
#if HOTENDS == 1 |
|
|
UNUSED(e); |
|
|
UNUSED(e); |
|
|
#endif |
|
|
#endif |
|
|
return preheat_end_time[HOTEND_INDEX] && PENDING(millis(), preheat_end_time[HOTEND_INDEX]); |
|
|
return preheat_end_time[HOTEND_INDEX] && PENDING(millis(), preheat_end_time[HOTEND_INDEX]); |
|
|
} |
|
|
} |
|
|
static void start_preheat_time(uint8_t e) { |
|
|
static void start_preheat_time(const uint8_t e) { |
|
|
#if HOTENDS == 1 |
|
|
#if HOTENDS == 1 |
|
|
UNUSED(e); |
|
|
UNUSED(e); |
|
|
#endif |
|
|
#endif |
|
|
preheat_end_time[HOTEND_INDEX] = millis() + MILLISECONDS_PREHEAT_TIME; |
|
|
preheat_end_time[HOTEND_INDEX] = millis() + MILLISECONDS_PREHEAT_TIME; |
|
|
} |
|
|
} |
|
|
static void reset_preheat_time(uint8_t e) { |
|
|
static void reset_preheat_time(const uint8_t e) { |
|
|
#if HOTENDS == 1 |
|
|
#if HOTENDS == 1 |
|
|
UNUSED(e); |
|
|
UNUSED(e); |
|
|
#endif |
|
|
#endif |
|
@ -329,36 +340,37 @@ class Temperature { |
|
|
static int8_t widthFil_to_size_ratio(); // Convert Filament Width (mm) to an extrusion ratio
|
|
|
static int8_t widthFil_to_size_ratio(); // Convert Filament Width (mm) to an extrusion ratio
|
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//high level conversion routines, for use outside of temperature.cpp
|
|
|
//high level conversion routines, for use outside of temperature.cpp
|
|
|
//inline so that there is no performance decrease.
|
|
|
//inline so that there is no performance decrease.
|
|
|
//deg=degreeCelsius
|
|
|
//deg=degreeCelsius
|
|
|
|
|
|
|
|
|
static float degHotend(uint8_t e) { |
|
|
FORCE_INLINE static float degHotend(const uint8_t e) { |
|
|
#if HOTENDS == 1 |
|
|
#if HOTENDS == 1 |
|
|
UNUSED(e); |
|
|
UNUSED(e); |
|
|
#endif |
|
|
#endif |
|
|
return current_temperature[HOTEND_INDEX]; |
|
|
return current_temperature[HOTEND_INDEX]; |
|
|
} |
|
|
} |
|
|
static float degBed() { return current_temperature_bed; } |
|
|
FORCE_INLINE static float degBed() { return current_temperature_bed; } |
|
|
|
|
|
|
|
|
#if ENABLED(SHOW_TEMP_ADC_VALUES) |
|
|
#if ENABLED(SHOW_TEMP_ADC_VALUES) |
|
|
static int16_t rawHotendTemp(uint8_t e) { |
|
|
FORCE_INLINE static int16_t rawHotendTemp(const uint8_t e) { |
|
|
#if HOTENDS == 1 |
|
|
#if HOTENDS == 1 |
|
|
UNUSED(e); |
|
|
UNUSED(e); |
|
|
#endif |
|
|
#endif |
|
|
return current_temperature_raw[HOTEND_INDEX]; |
|
|
return current_temperature_raw[HOTEND_INDEX]; |
|
|
} |
|
|
} |
|
|
static int16_t rawBedTemp() { return current_temperature_bed_raw; } |
|
|
FORCE_INLINE static int16_t rawBedTemp() { return current_temperature_bed_raw; } |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
static int16_t degTargetHotend(uint8_t e) { |
|
|
FORCE_INLINE static int16_t degTargetHotend(const uint8_t e) { |
|
|
#if HOTENDS == 1 |
|
|
#if HOTENDS == 1 |
|
|
UNUSED(e); |
|
|
UNUSED(e); |
|
|
#endif |
|
|
#endif |
|
|
return target_temperature[HOTEND_INDEX]; |
|
|
return target_temperature[HOTEND_INDEX]; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static int16_t degTargetBed() { return target_temperature_bed; } |
|
|
FORCE_INLINE static int16_t degTargetBed() { return target_temperature_bed; } |
|
|
|
|
|
|
|
|
#if WATCH_HOTENDS |
|
|
#if WATCH_HOTENDS |
|
|
static void start_watching_heater(const uint8_t e = 0); |
|
|
static void start_watching_heater(const uint8_t e = 0); |
|
@ -399,21 +411,25 @@ class Temperature { |
|
|
#endif |
|
|
#endif |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static bool isHeatingHotend(uint8_t e) { |
|
|
FORCE_INLINE static bool isHeatingHotend(const uint8_t e) { |
|
|
#if HOTENDS == 1 |
|
|
#if HOTENDS == 1 |
|
|
UNUSED(e); |
|
|
UNUSED(e); |
|
|
#endif |
|
|
#endif |
|
|
return target_temperature[HOTEND_INDEX] > current_temperature[HOTEND_INDEX]; |
|
|
return target_temperature[HOTEND_INDEX] > current_temperature[HOTEND_INDEX]; |
|
|
} |
|
|
} |
|
|
static bool isHeatingBed() { return target_temperature_bed > current_temperature_bed; } |
|
|
FORCE_INLINE static bool isHeatingBed() { return target_temperature_bed > current_temperature_bed; } |
|
|
|
|
|
|
|
|
static bool isCoolingHotend(uint8_t e) { |
|
|
FORCE_INLINE static bool isCoolingHotend(const uint8_t e) { |
|
|
#if HOTENDS == 1 |
|
|
#if HOTENDS == 1 |
|
|
UNUSED(e); |
|
|
UNUSED(e); |
|
|
#endif |
|
|
#endif |
|
|
return target_temperature[HOTEND_INDEX] < current_temperature[HOTEND_INDEX]; |
|
|
return target_temperature[HOTEND_INDEX] < current_temperature[HOTEND_INDEX]; |
|
|
} |
|
|
} |
|
|
static bool isCoolingBed() { return target_temperature_bed < current_temperature_bed; } |
|
|
FORCE_INLINE static bool isCoolingBed() { return target_temperature_bed < current_temperature_bed; } |
|
|
|
|
|
|
|
|
|
|
|
FORCE_INLINE static bool wait_for_heating(const uint8_t e) { |
|
|
|
|
|
return degTargetHotend(e) > TEMP_HYSTERESIS && abs(degHotend(e) - degTargetHotend(e)) > TEMP_HYSTERESIS; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* The software PWM power for a heater |
|
|
* The software PWM power for a heater |
|
@ -480,11 +496,12 @@ class Temperature { |
|
|
|
|
|
|
|
|
#if ENABLED(PROBING_HEATERS_OFF) |
|
|
#if ENABLED(PROBING_HEATERS_OFF) |
|
|
static void pause(const bool p); |
|
|
static void pause(const bool p); |
|
|
static bool is_paused() { return paused; } |
|
|
FORCE_INLINE static bool is_paused() { return paused; } |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
#if HEATER_IDLE_HANDLER |
|
|
#if HEATER_IDLE_HANDLER |
|
|
static void start_heater_idle_timer(uint8_t e, millis_t timeout_ms) { |
|
|
|
|
|
|
|
|
static void start_heater_idle_timer(const uint8_t e, const millis_t timeout_ms) { |
|
|
#if HOTENDS == 1 |
|
|
#if HOTENDS == 1 |
|
|
UNUSED(e); |
|
|
UNUSED(e); |
|
|
#endif |
|
|
#endif |
|
@ -492,7 +509,7 @@ class Temperature { |
|
|
heater_idle_timeout_exceeded[HOTEND_INDEX] = false; |
|
|
heater_idle_timeout_exceeded[HOTEND_INDEX] = false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static void reset_heater_idle_timer(uint8_t e) { |
|
|
static void reset_heater_idle_timer(const uint8_t e) { |
|
|
#if HOTENDS == 1 |
|
|
#if HOTENDS == 1 |
|
|
UNUSED(e); |
|
|
UNUSED(e); |
|
|
#endif |
|
|
#endif |
|
@ -503,7 +520,7 @@ class Temperature { |
|
|
#endif |
|
|
#endif |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static bool is_heater_idle(uint8_t e) { |
|
|
FORCE_INLINE static bool is_heater_idle(const uint8_t e) { |
|
|
#if HOTENDS == 1 |
|
|
#if HOTENDS == 1 |
|
|
UNUSED(e); |
|
|
UNUSED(e); |
|
|
#endif |
|
|
#endif |
|
@ -511,7 +528,7 @@ class Temperature { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
#if HAS_TEMP_BED |
|
|
#if HAS_TEMP_BED |
|
|
static void start_bed_idle_timer(millis_t timeout_ms) { |
|
|
static void start_bed_idle_timer(const millis_t timeout_ms) { |
|
|
bed_idle_timeout_ms = millis() + timeout_ms; |
|
|
bed_idle_timeout_ms = millis() + timeout_ms; |
|
|
bed_idle_timeout_exceeded = false; |
|
|
bed_idle_timeout_exceeded = false; |
|
|
} |
|
|
} |
|
@ -524,12 +541,11 @@ class Temperature { |
|
|
#endif |
|
|
#endif |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static bool is_bed_idle() { |
|
|
FORCE_INLINE static bool is_bed_idle() { return bed_idle_timeout_exceeded; } |
|
|
return bed_idle_timeout_exceeded; |
|
|
|
|
|
} |
|
|
|
|
|
#endif |
|
|
|
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
#endif // HEATER_IDLE_HANDLER
|
|
|
|
|
|
|
|
|
#if HAS_TEMP_HOTEND || HAS_TEMP_BED |
|
|
#if HAS_TEMP_HOTEND || HAS_TEMP_BED |
|
|
static void print_heaterstates(); |
|
|
static void print_heaterstates(); |
|
|
#if ENABLED(AUTO_REPORT_TEMPERATURES) |
|
|
#if ENABLED(AUTO_REPORT_TEMPERATURES) |
|
@ -574,7 +590,7 @@ class Temperature { |
|
|
|
|
|
|
|
|
typedef enum TRState { TRInactive, TRFirstHeating, TRStable, TRRunaway } TRstate; |
|
|
typedef enum TRState { TRInactive, TRFirstHeating, TRStable, TRRunaway } TRstate; |
|
|
|
|
|
|
|
|
static void thermal_runaway_protection(TRState * const state, millis_t * const timer, const float current, const float target, const int8_t heater_id, const uint16_t period_seconds, const uint16_t hysteresis_degc); |
|
|
static void thermal_runaway_protection(TRState * const state, millis_t * const timer, const float ¤t, const float &target, const int8_t heater_id, const uint16_t period_seconds, const uint16_t hysteresis_degc); |
|
|
|
|
|
|
|
|
#if ENABLED(THERMAL_PROTECTION_HOTENDS) |
|
|
#if ENABLED(THERMAL_PROTECTION_HOTENDS) |
|
|
static TRState thermal_runaway_state_machine[HOTENDS]; |
|
|
static TRState thermal_runaway_state_machine[HOTENDS]; |
|
|