Add HAS_HEATED_BED conditional (#10495)
This commit is contained in:
@ -70,7 +70,7 @@ enum ADCSensorState : char {
|
||||
PrepareTemp_4,
|
||||
MeasureTemp_4,
|
||||
#endif
|
||||
#if HAS_TEMP_BED
|
||||
#if HAS_HEATED_BED
|
||||
PrepareTemp_BED,
|
||||
MeasureTemp_BED,
|
||||
#endif
|
||||
@ -108,35 +108,21 @@ enum ADCSensorState : char {
|
||||
#define unscalePID_d(d) ( (d) * PID_dT )
|
||||
#endif
|
||||
|
||||
#if !HAS_HEATER_BED
|
||||
constexpr int16_t target_temperature_bed = 0;
|
||||
#endif
|
||||
|
||||
class Temperature {
|
||||
|
||||
public:
|
||||
|
||||
static float current_temperature[HOTENDS],
|
||||
current_temperature_chamber,
|
||||
current_temperature_bed;
|
||||
static volatile bool in_temp_isr;
|
||||
|
||||
static float current_temperature[HOTENDS];
|
||||
static int16_t current_temperature_raw[HOTENDS],
|
||||
target_temperature[HOTENDS],
|
||||
current_temperature_chamber_raw,
|
||||
current_temperature_bed_raw;
|
||||
target_temperature[HOTENDS];
|
||||
static uint8_t soft_pwm_amount[HOTENDS];
|
||||
|
||||
#if ENABLED(AUTO_POWER_E_FANS)
|
||||
static int16_t autofan_speed[HOTENDS];
|
||||
#endif
|
||||
|
||||
#if HAS_HEATER_BED
|
||||
static int16_t target_temperature_bed;
|
||||
#endif
|
||||
|
||||
static volatile bool in_temp_isr;
|
||||
|
||||
static uint8_t soft_pwm_amount[HOTENDS],
|
||||
soft_pwm_amount_bed;
|
||||
|
||||
#if ENABLED(FAN_SOFT_PWM)
|
||||
static uint8_t soft_pwm_amount_fan[FAN_COUNT],
|
||||
soft_pwm_count_fan[FAN_COUNT];
|
||||
@ -164,24 +150,24 @@ class Temperature {
|
||||
|
||||
#endif
|
||||
|
||||
#if ENABLED(PIDTEMPBED)
|
||||
static float bedKp, bedKi, bedKd;
|
||||
#if HAS_HEATED_BED
|
||||
static float current_temperature_bed;
|
||||
static int16_t current_temperature_bed_raw, target_temperature_bed;
|
||||
static uint8_t soft_pwm_amount_bed;
|
||||
#if ENABLED(PIDTEMPBED)
|
||||
static float bedKp, bedKi, bedKd;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if HAS_TEMP_CHAMBER
|
||||
static float current_temperature_chamber;
|
||||
static int16_t current_temperature_chamber_raw;
|
||||
#endif
|
||||
|
||||
#if ENABLED(BABYSTEPPING)
|
||||
static volatile int babystepsTodo[3];
|
||||
#endif
|
||||
|
||||
#if WATCH_HOTENDS
|
||||
static uint16_t watch_target_temp[HOTENDS];
|
||||
static millis_t watch_heater_next_ms[HOTENDS];
|
||||
#endif
|
||||
|
||||
#if WATCH_THE_BED
|
||||
static uint16_t watch_target_bed_temp;
|
||||
static millis_t watch_bed_next_ms;
|
||||
#endif
|
||||
|
||||
#if ENABLED(PREVENT_COLD_EXTRUSION)
|
||||
static bool allow_cold_extrude;
|
||||
static int16_t extrude_min_temp;
|
||||
@ -209,8 +195,15 @@ class Temperature {
|
||||
private:
|
||||
|
||||
#if EARLY_WATCHDOG
|
||||
// If temperature controller is running
|
||||
static bool inited;
|
||||
static bool inited; // If temperature controller is running
|
||||
#endif
|
||||
|
||||
static volatile bool temp_meas_ready;
|
||||
static uint16_t raw_temp_value[MAX_EXTRUDERS];
|
||||
|
||||
#if WATCH_HOTENDS
|
||||
static uint16_t watch_target_temp[HOTENDS];
|
||||
static millis_t watch_heater_next_ms[HOTENDS];
|
||||
#endif
|
||||
|
||||
#if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
|
||||
@ -218,8 +211,6 @@ class Temperature {
|
||||
static float redundant_temperature;
|
||||
#endif
|
||||
|
||||
static volatile bool temp_meas_ready;
|
||||
|
||||
#if ENABLED(PIDTEMP)
|
||||
static float temp_iState[HOTENDS],
|
||||
temp_dState[HOTENDS],
|
||||
@ -238,27 +229,45 @@ class Temperature {
|
||||
static bool pid_reset[HOTENDS];
|
||||
#endif
|
||||
|
||||
#if ENABLED(PIDTEMPBED)
|
||||
static float temp_iState_bed,
|
||||
temp_dState_bed,
|
||||
pTerm_bed,
|
||||
iTerm_bed,
|
||||
dTerm_bed,
|
||||
pid_error_bed;
|
||||
#else
|
||||
static millis_t next_bed_check_ms;
|
||||
#endif
|
||||
|
||||
static uint16_t raw_temp_value[MAX_EXTRUDERS],
|
||||
raw_temp_chamber_value,
|
||||
raw_temp_bed_value;
|
||||
|
||||
// Init min and max temp with extreme values to prevent false errors during startup
|
||||
static int16_t minttemp_raw[HOTENDS],
|
||||
maxttemp_raw[HOTENDS],
|
||||
minttemp[HOTENDS],
|
||||
maxttemp[HOTENDS];
|
||||
|
||||
#if HAS_HEATED_BED
|
||||
static uint16_t raw_temp_bed_value;
|
||||
#if WATCH_THE_BED
|
||||
static uint16_t watch_target_bed_temp;
|
||||
static millis_t watch_bed_next_ms;
|
||||
#endif
|
||||
#if ENABLED(PIDTEMPBED)
|
||||
static float temp_iState_bed,
|
||||
temp_dState_bed,
|
||||
pTerm_bed,
|
||||
iTerm_bed,
|
||||
dTerm_bed,
|
||||
pid_error_bed;
|
||||
#else
|
||||
static millis_t next_bed_check_ms;
|
||||
#endif
|
||||
#if HEATER_IDLE_HANDLER
|
||||
static millis_t bed_idle_timeout_ms;
|
||||
static bool bed_idle_timeout_exceeded;
|
||||
#endif
|
||||
#ifdef BED_MINTEMP
|
||||
static int16_t bed_minttemp_raw;
|
||||
#endif
|
||||
#ifdef BED_MAXTEMP
|
||||
static int16_t bed_maxttemp_raw;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if HAS_TEMP_CHAMBER
|
||||
static uint16_t raw_temp_chamber_value;
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED
|
||||
static uint8_t consecutive_low_temperature_error[HOTENDS];
|
||||
#endif
|
||||
@ -267,14 +276,6 @@ class Temperature {
|
||||
static millis_t preheat_end_time[HOTENDS];
|
||||
#endif
|
||||
|
||||
#ifdef BED_MINTEMP
|
||||
static int16_t bed_minttemp_raw;
|
||||
#endif
|
||||
|
||||
#ifdef BED_MAXTEMP
|
||||
static int16_t bed_maxttemp_raw;
|
||||
#endif
|
||||
|
||||
#if ENABLED(FILAMENT_WIDTH_SENSOR)
|
||||
static int8_t meas_shift_index; // Index of a delayed sample in buffer
|
||||
#endif
|
||||
@ -294,10 +295,6 @@ class Temperature {
|
||||
#if HEATER_IDLE_HANDLER
|
||||
static millis_t heater_idle_timeout_ms[HOTENDS];
|
||||
static bool heater_idle_timeout_exceeded[HOTENDS];
|
||||
#if HAS_TEMP_BED
|
||||
static millis_t bed_idle_timeout_ms;
|
||||
static bool bed_idle_timeout_exceeded;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
public:
|
||||
@ -319,7 +316,7 @@ class Temperature {
|
||||
*/
|
||||
static float analog2temp(const int raw, const uint8_t e);
|
||||
|
||||
#if HAS_TEMP_BED
|
||||
#if HAS_HEATED_BED
|
||||
static float analog2tempBed(const int raw);
|
||||
#endif
|
||||
#if HAS_TEMP_CHAMBER
|
||||
@ -378,8 +375,6 @@ class Temperature {
|
||||
#endif
|
||||
return current_temperature[HOTEND_INDEX];
|
||||
}
|
||||
FORCE_INLINE static float degBed() { return current_temperature_bed; }
|
||||
FORCE_INLINE static float degChamber() { return current_temperature_chamber; }
|
||||
|
||||
#if ENABLED(SHOW_TEMP_ADC_VALUES)
|
||||
FORCE_INLINE static int16_t rawHotendTemp(const uint8_t e) {
|
||||
@ -388,8 +383,6 @@ class Temperature {
|
||||
#endif
|
||||
return current_temperature_raw[HOTEND_INDEX];
|
||||
}
|
||||
FORCE_INLINE static int16_t rawBedTemp() { return current_temperature_bed_raw; }
|
||||
FORCE_INLINE static int16_t rawChamberTemp() { return current_temperature_chamber_raw; }
|
||||
#endif
|
||||
|
||||
FORCE_INLINE static int16_t degTargetHotend(const uint8_t e) {
|
||||
@ -399,16 +392,10 @@ class Temperature {
|
||||
return target_temperature[HOTEND_INDEX];
|
||||
}
|
||||
|
||||
FORCE_INLINE static int16_t degTargetBed() { return target_temperature_bed; }
|
||||
|
||||
#if WATCH_HOTENDS
|
||||
static void start_watching_heater(const uint8_t e = 0);
|
||||
#endif
|
||||
|
||||
#if WATCH_THE_BED
|
||||
static void start_watching_bed();
|
||||
#endif
|
||||
|
||||
static void setTargetHotend(const int16_t celsius, const uint8_t e) {
|
||||
#if HOTENDS == 1
|
||||
UNUSED(e);
|
||||
@ -428,8 +415,30 @@ class Temperature {
|
||||
#endif
|
||||
}
|
||||
|
||||
static void setTargetBed(const int16_t celsius) {
|
||||
#if HAS_HEATER_BED
|
||||
FORCE_INLINE static bool isHeatingHotend(const uint8_t e) {
|
||||
#if HOTENDS == 1
|
||||
UNUSED(e);
|
||||
#endif
|
||||
return target_temperature[HOTEND_INDEX] > current_temperature[HOTEND_INDEX];
|
||||
}
|
||||
|
||||
FORCE_INLINE static bool isCoolingHotend(const uint8_t e) {
|
||||
#if HOTENDS == 1
|
||||
UNUSED(e);
|
||||
#endif
|
||||
return target_temperature[HOTEND_INDEX] < current_temperature[HOTEND_INDEX];
|
||||
}
|
||||
|
||||
#if HAS_HEATED_BED
|
||||
#if ENABLED(SHOW_TEMP_ADC_VALUES)
|
||||
FORCE_INLINE static int16_t rawBedTemp() { return current_temperature_bed_raw; }
|
||||
#endif
|
||||
FORCE_INLINE static float degBed() { return current_temperature_bed; }
|
||||
FORCE_INLINE static int16_t degTargetBed() { return target_temperature_bed; }
|
||||
FORCE_INLINE static bool isHeatingBed() { return target_temperature_bed > current_temperature_bed; }
|
||||
FORCE_INLINE static bool isCoolingBed() { return target_temperature_bed < current_temperature_bed; }
|
||||
|
||||
static void setTargetBed(const int16_t celsius) {
|
||||
#if ENABLED(AUTO_POWER_CONTROL)
|
||||
powerManager.power_on();
|
||||
#endif
|
||||
@ -443,24 +452,19 @@ class Temperature {
|
||||
#if WATCH_THE_BED
|
||||
start_watching_bed();
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
FORCE_INLINE static bool isHeatingHotend(const uint8_t e) {
|
||||
#if HOTENDS == 1
|
||||
UNUSED(e);
|
||||
#if WATCH_THE_BED
|
||||
static void start_watching_bed();
|
||||
#endif
|
||||
return target_temperature[HOTEND_INDEX] > current_temperature[HOTEND_INDEX];
|
||||
}
|
||||
FORCE_INLINE static bool isHeatingBed() { return target_temperature_bed > current_temperature_bed; }
|
||||
#endif
|
||||
|
||||
FORCE_INLINE static bool isCoolingHotend(const uint8_t e) {
|
||||
#if HOTENDS == 1
|
||||
UNUSED(e);
|
||||
#if HAS_TEMP_CHAMBER
|
||||
#if ENABLED(SHOW_TEMP_ADC_VALUES)
|
||||
FORCE_INLINE static int16_t rawChamberTemp() { return current_temperature_chamber_raw; }
|
||||
#endif
|
||||
return target_temperature[HOTEND_INDEX] < current_temperature[HOTEND_INDEX];
|
||||
}
|
||||
FORCE_INLINE static bool isCoolingBed() { return target_temperature_bed < current_temperature_bed; }
|
||||
FORCE_INLINE static float degChamber() { return current_temperature_chamber; }
|
||||
#endif
|
||||
|
||||
FORCE_INLINE static bool wait_for_heating(const uint8_t e) {
|
||||
return degTargetHotend(e) > TEMP_HYSTERESIS && abs(degHotend(e) - degTargetHotend(e)) > TEMP_HYSTERESIS;
|
||||
@ -469,7 +473,7 @@ class Temperature {
|
||||
/**
|
||||
* The software PWM power for a heater
|
||||
*/
|
||||
static int getHeaterPower(int heater);
|
||||
static int getHeaterPower(const int heater);
|
||||
|
||||
/**
|
||||
* Switch off all heaters, set all target temperatures to 0
|
||||
@ -562,7 +566,7 @@ class Temperature {
|
||||
return heater_idle_timeout_exceeded[HOTEND_INDEX];
|
||||
}
|
||||
|
||||
#if HAS_TEMP_BED
|
||||
#if HAS_HEATED_BED
|
||||
static void start_bed_idle_timer(const millis_t timeout_ms) {
|
||||
bed_idle_timeout_ms = millis() + timeout_ms;
|
||||
bed_idle_timeout_exceeded = false;
|
||||
@ -627,7 +631,7 @@ class Temperature {
|
||||
|
||||
#if ENABLED(THERMAL_PROTECTION_HOTENDS) || HAS_THERMALLY_PROTECTED_BED
|
||||
|
||||
typedef enum TRState : char { TRInactive, TRFirstHeating, TRStable, TRRunaway } TRstate;
|
||||
enum TRState : char { TRInactive, TRFirstHeating, TRStable, TRRunaway };
|
||||
|
||||
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);
|
||||
|
||||
|
Reference in New Issue
Block a user