mirror of
https://github.com/MarlinFirmware/Marlin.git
synced 2024-11-26 21:36:21 +00:00
✨ PREHEAT_TIME_BED_MS (#25146)
This commit is contained in:
parent
250fd60920
commit
64167dfe79
@ -493,7 +493,8 @@
|
||||
* the minimum temperature your thermistor can read. The lower the better/safer.
|
||||
* This shouldn't need to be more than 30 seconds (30000)
|
||||
*/
|
||||
//#define MILLISECONDS_PREHEAT_TIME 0
|
||||
//#define PREHEAT_TIME_HOTEND_MS 0
|
||||
//#define PREHEAT_TIME_BED_MS 0
|
||||
|
||||
// @section extruder
|
||||
|
||||
|
@ -664,6 +664,8 @@
|
||||
#error "SCARA_PRINTABLE_RADIUS is now PRINTABLE_RADIUS."
|
||||
#elif defined(SCARA_FEEDRATE_SCALING)
|
||||
#error "SCARA_FEEDRATE_SCALING is now FEEDRATE_SCALING."
|
||||
#elif defined(MILLISECONDS_PREHEAT_TIME)
|
||||
#error "MILLISECONDS_PREHEAT_TIME is now PREHEAT_TIME_HOTEND_MS."
|
||||
#endif
|
||||
|
||||
// L64xx stepper drivers have been removed
|
||||
@ -2400,12 +2402,16 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
|
||||
#endif
|
||||
#if MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED < 5
|
||||
#error "Thermistor 66 requires MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED ≥ 5."
|
||||
#elif MILLISECONDS_PREHEAT_TIME < 15000
|
||||
#error "Thermistor 66 requires MILLISECONDS_PREHEAT_TIME ≥ 15000, but 30000 or higher is recommended."
|
||||
#elif PREHEAT_TIME_HOTEND_MS < 15000
|
||||
#error "Thermistor 66 requires PREHEAT_TIME_HOTEND_MS ≥ 15000, but 30000 or higher is recommended."
|
||||
#endif
|
||||
#undef _BAD_MINTEMP
|
||||
#endif
|
||||
|
||||
#if TEMP_SENSOR_BED == 66 && PREHEAT_TIME_BED_MS < 15000
|
||||
#error "Thermistor 66 requires PREHEAT_TIME_BED_MS ≥ 15000, but 30000 or higher is recommended."
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Required MAX31865 settings
|
||||
*/
|
||||
|
@ -561,8 +561,11 @@ volatile bool Temperature::raw_temps_ready = false;
|
||||
uint8_t Temperature::consecutive_low_temperature_error[HOTENDS] = { 0 };
|
||||
#endif
|
||||
|
||||
#if MILLISECONDS_PREHEAT_TIME > 0
|
||||
millis_t Temperature::preheat_end_time[HOTENDS] = { 0 };
|
||||
#if PREHEAT_TIME_HOTEND_MS > 0
|
||||
millis_t Temperature::preheat_end_ms_hotend[HOTENDS] { 0 };
|
||||
#endif
|
||||
#if HAS_HEATED_BED && PREHEAT_TIME_BED_MS > 0
|
||||
millis_t Temperature::preheat_end_ms_bed = 0;
|
||||
#endif
|
||||
|
||||
#if HAS_FAN_LOGIC
|
||||
@ -1535,7 +1538,7 @@ void Temperature::mintemp_error(const heater_id_t heater_id) {
|
||||
tr_state_machine[e].run(temp_hotend[e].celsius, temp_hotend[e].target, (heater_id_t)e, THERMAL_PROTECTION_PERIOD, THERMAL_PROTECTION_HYSTERESIS);
|
||||
#endif
|
||||
|
||||
temp_hotend[e].soft_pwm_amount = (temp_hotend[e].celsius > temp_range[e].mintemp || is_preheating(e)) && temp_hotend[e].celsius < temp_range[e].maxtemp ? (int)get_pid_output_hotend(e) >> 1 : 0;
|
||||
temp_hotend[e].soft_pwm_amount = (temp_hotend[e].celsius > temp_range[e].mintemp || is_hotend_preheating(e)) && temp_hotend[e].celsius < temp_range[e].maxtemp ? (int)get_pid_output_hotend(e) >> 1 : 0;
|
||||
|
||||
#if WATCH_HOTENDS
|
||||
// Make sure temperature is increasing
|
||||
@ -1609,6 +1612,10 @@ void Temperature::mintemp_error(const heater_id_t heater_id) {
|
||||
#endif
|
||||
|
||||
if (!bed_timed_out) {
|
||||
if (is_bed_preheating()) {
|
||||
temp_bed.soft_pwm_amount = MAX_BED_POWER >> 1;
|
||||
}
|
||||
else {
|
||||
#if ENABLED(PIDTEMPBED)
|
||||
temp_bed.soft_pwm_amount = WITHIN(temp_bed.celsius, BED_MINTEMP, BED_MAXTEMP) ? (int)get_pid_output_bed() >> 1 : 0;
|
||||
#else
|
||||
@ -1629,6 +1636,7 @@ void Temperature::mintemp_error(const heater_id_t heater_id) {
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
} while (false);
|
||||
}
|
||||
@ -2394,7 +2402,7 @@ void Temperature::updateTemperaturesFromRawValues() {
|
||||
//*/
|
||||
|
||||
const bool heater_on = temp_hotend[e].target > 0;
|
||||
if (heater_on && !is_preheating(e) && ((neg && r > temp_range[e].raw_min) || (pos && r < temp_range[e].raw_min))) {
|
||||
if (heater_on && !is_hotend_preheating(e) && ((neg && r > temp_range[e].raw_min) || (pos && r < temp_range[e].raw_min))) {
|
||||
if (TERN1(MULTI_MAX_CONSECUTIVE_LOW_TEMP_ERR, ++consecutive_low_temperature_error[e] >= MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED))
|
||||
mintemp_error((heater_id_t)e);
|
||||
}
|
||||
@ -2408,7 +2416,7 @@ void Temperature::updateTemperaturesFromRawValues() {
|
||||
#define TP_CMP(S,A,B) (TEMPDIR(S) < 0 ? ((A)<(B)) : ((A)>(B)))
|
||||
#if ENABLED(THERMAL_PROTECTION_BED)
|
||||
if (TP_CMP(BED, temp_bed.getraw(), maxtemp_raw_BED)) maxtemp_error(H_BED);
|
||||
if (temp_bed.target > 0 && TP_CMP(BED, mintemp_raw_BED, temp_bed.getraw())) mintemp_error(H_BED);
|
||||
if (temp_bed.target > 0 && !is_bed_preheating() && TP_CMP(BED, mintemp_raw_BED, temp_bed.getraw())) mintemp_error(H_BED);
|
||||
#endif
|
||||
|
||||
#if BOTH(HAS_HEATED_CHAMBER, THERMAL_PROTECTION_CHAMBER)
|
||||
|
@ -748,10 +748,6 @@ class Temperature {
|
||||
static uint8_t consecutive_low_temperature_error[HOTENDS];
|
||||
#endif
|
||||
|
||||
#if MILLISECONDS_PREHEAT_TIME > 0
|
||||
static millis_t preheat_end_time[HOTENDS];
|
||||
#endif
|
||||
|
||||
#if HAS_FAN_LOGIC
|
||||
static millis_t fan_update_ms;
|
||||
|
||||
@ -907,20 +903,38 @@ class Temperature {
|
||||
static void task();
|
||||
|
||||
/**
|
||||
* Preheating hotends
|
||||
* Preheating hotends & bed
|
||||
*/
|
||||
#if MILLISECONDS_PREHEAT_TIME > 0
|
||||
static bool is_preheating(const uint8_t E_NAME) {
|
||||
return preheat_end_time[HOTEND_INDEX] && PENDING(millis(), preheat_end_time[HOTEND_INDEX]);
|
||||
#if PREHEAT_TIME_HOTEND_MS > 0
|
||||
static millis_t preheat_end_ms_hotend[HOTENDS];
|
||||
static bool is_hotend_preheating(const uint8_t E_NAME) {
|
||||
return preheat_end_ms_hotend[HOTEND_INDEX] && PENDING(millis(), preheat_end_ms_hotend[HOTEND_INDEX]);
|
||||
}
|
||||
static void start_preheat_time(const uint8_t E_NAME) {
|
||||
preheat_end_time[HOTEND_INDEX] = millis() + MILLISECONDS_PREHEAT_TIME;
|
||||
static void start_hotend_preheat_time(const uint8_t E_NAME) {
|
||||
preheat_end_ms_hotend[HOTEND_INDEX] = millis() + PREHEAT_TIME_HOTEND_MS;
|
||||
}
|
||||
static void reset_preheat_time(const uint8_t E_NAME) {
|
||||
preheat_end_time[HOTEND_INDEX] = 0;
|
||||
static void reset_hotend_preheat_time(const uint8_t E_NAME) {
|
||||
preheat_end_ms_hotend[HOTEND_INDEX] = 0;
|
||||
}
|
||||
#else
|
||||
#define is_preheating(n) (false)
|
||||
static bool is_hotend_preheating(const uint8_t) { return false; }
|
||||
#endif
|
||||
|
||||
#if HAS_HEATED_BED
|
||||
#if PREHEAT_TIME_BED_MS > 0
|
||||
static millis_t preheat_end_ms_bed;
|
||||
static bool is_bed_preheating() {
|
||||
return preheat_end_ms_bed && PENDING(millis(), preheat_end_ms_bed);
|
||||
}
|
||||
static void start_bed_preheat_time() {
|
||||
preheat_end_ms_bed = millis() + PREHEAT_TIME_BED_MS;
|
||||
}
|
||||
static void reset_bed_preheat_time() {
|
||||
preheat_end_ms_bed = 0;
|
||||
}
|
||||
#else
|
||||
static bool is_bed_preheating() { return false; }
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//high level conversion routines, for use outside of temperature.cpp
|
||||
@ -949,11 +963,11 @@ class Temperature {
|
||||
|
||||
static void setTargetHotend(const celsius_t celsius, const uint8_t E_NAME) {
|
||||
const uint8_t ee = HOTEND_INDEX;
|
||||
#if MILLISECONDS_PREHEAT_TIME > 0
|
||||
#if PREHEAT_TIME_HOTEND_MS > 0
|
||||
if (celsius == 0)
|
||||
reset_preheat_time(ee);
|
||||
reset_hotend_preheat_time(ee);
|
||||
else if (temp_hotend[ee].target == 0)
|
||||
start_preheat_time(ee);
|
||||
start_hotend_preheat_time(ee);
|
||||
#endif
|
||||
TERN_(AUTO_POWER_CONTROL, if (celsius) powerManager.power_on());
|
||||
temp_hotend[ee].target = _MIN(celsius, hotend_max_target(ee));
|
||||
@ -1016,6 +1030,12 @@ class Temperature {
|
||||
static void start_watching_bed() { TERN_(WATCH_BED, watch_bed.restart(degBed(), degTargetBed())); }
|
||||
|
||||
static void setTargetBed(const celsius_t celsius) {
|
||||
#if PREHEAT_TIME_BED_MS > 0
|
||||
if (celsius == 0)
|
||||
reset_bed_preheat_time();
|
||||
else if (temp_bed.target == 0)
|
||||
start_bed_preheat_time();
|
||||
#endif
|
||||
TERN_(AUTO_POWER_CONTROL, if (celsius) powerManager.power_on());
|
||||
temp_bed.target = _MIN(celsius, BED_MAX_TARGET);
|
||||
start_watching_bed();
|
||||
|
Loading…
Reference in New Issue
Block a user