mirror of
https://github.com/MarlinFirmware/Marlin.git
synced 2024-11-30 15:26:18 +00:00
🎨 Misc. temperature cleanup
This commit is contained in:
parent
9cf1a8891f
commit
03bb28c277
@ -38,6 +38,10 @@ uint8_t ControllerFan::speed;
|
||||
const controllerFan_settings_t &ControllerFan::settings = controllerFan_defaults;
|
||||
#endif
|
||||
|
||||
#if ENABLED(FAN_SOFT_PWM)
|
||||
uint8_t ControllerFan::soft_pwm_speed;
|
||||
#endif
|
||||
|
||||
void ControllerFan::setup() {
|
||||
SET_OUTPUT(CONTROLLER_FAN_PIN);
|
||||
#ifdef CONTROLLER_FAN2_PIN
|
||||
@ -98,7 +102,7 @@ void ControllerFan::update() {
|
||||
#endif
|
||||
|
||||
#if ENABLED(FAN_SOFT_PWM)
|
||||
thermalManager.soft_pwm_controller_speed = speed;
|
||||
soft_pwm_speed = speed;
|
||||
#else
|
||||
if (PWM_PIN(CONTROLLER_FAN_PIN))
|
||||
hal.set_pwm_duty(pin_t(CONTROLLER_FAN_PIN), speed);
|
||||
|
@ -60,6 +60,9 @@ class ControllerFan {
|
||||
#else
|
||||
static const controllerFan_settings_t &settings;
|
||||
#endif
|
||||
#if ENABLED(FAN_SOFT_PWM)
|
||||
static uint8_t soft_pwm_speed;
|
||||
#endif
|
||||
static bool state() { return speed > 0; }
|
||||
static void init() { reset(); }
|
||||
static void reset() { TERN_(CONTROLLER_FAN_EDITABLE, settings = controllerFan_defaults); }
|
||||
|
@ -87,30 +87,8 @@ void GcodeSuite::M42() {
|
||||
|
||||
#if HAS_FAN
|
||||
switch (pin) {
|
||||
#if HAS_FAN0
|
||||
case FAN0_PIN: thermalManager.fan_speed[0] = pin_status; return;
|
||||
#endif
|
||||
#if HAS_FAN1
|
||||
case FAN1_PIN: thermalManager.fan_speed[1] = pin_status; return;
|
||||
#endif
|
||||
#if HAS_FAN2
|
||||
case FAN2_PIN: thermalManager.fan_speed[2] = pin_status; return;
|
||||
#endif
|
||||
#if HAS_FAN3
|
||||
case FAN3_PIN: thermalManager.fan_speed[3] = pin_status; return;
|
||||
#endif
|
||||
#if HAS_FAN4
|
||||
case FAN4_PIN: thermalManager.fan_speed[4] = pin_status; return;
|
||||
#endif
|
||||
#if HAS_FAN5
|
||||
case FAN5_PIN: thermalManager.fan_speed[5] = pin_status; return;
|
||||
#endif
|
||||
#if HAS_FAN6
|
||||
case FAN6_PIN: thermalManager.fan_speed[6] = pin_status; return;
|
||||
#endif
|
||||
#if HAS_FAN7
|
||||
case FAN7_PIN: thermalManager.fan_speed[7] = pin_status; return;
|
||||
#endif
|
||||
#define _CASE(N) case FAN##N##_PIN: thermalManager.fan_speed[N] = pin_status; return;
|
||||
REPEAT(FAN_COUNT, _CASE)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -85,7 +85,7 @@ void GcodeSuite::M106() {
|
||||
if (!got_preset && parser.seenval('S'))
|
||||
speed = parser.value_ushort();
|
||||
|
||||
TERN_(FOAMCUTTER_XYUV, speed *= 2.55); // Get command in % of max heat
|
||||
TERN_(FOAMCUTTER_XYUV, speed *= 2.55f); // Get command in % of max heat
|
||||
|
||||
// Set speed, with constraint
|
||||
thermalManager.set_fan_speed(pfan, speed);
|
||||
|
@ -524,7 +524,7 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED);
|
||||
#if HAS_TEMP_CHAMBER
|
||||
chamber_info_t Temperature::temp_chamber; // = { 0 }
|
||||
#if HAS_HEATED_CHAMBER
|
||||
millis_t next_cool_check_ms_2 = 0;
|
||||
millis_t next_cool_check_ms = 0;
|
||||
celsius_float_t old_temp = 9999;
|
||||
raw_adc_t Temperature::mintemp_raw_CHAMBER = TEMP_SENSOR_CHAMBER_RAW_LO_TEMP,
|
||||
Temperature::maxtemp_raw_CHAMBER = TEMP_SENSOR_CHAMBER_RAW_HI_TEMP;
|
||||
@ -546,7 +546,7 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED);
|
||||
raw_adc_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};
|
||||
cooler_watch_t Temperature::watch_cooler; // = { 0 }
|
||||
#endif
|
||||
millis_t Temperature::next_cooler_check_ms, Temperature::cooler_fan_flush_ms;
|
||||
#endif
|
||||
@ -617,11 +617,11 @@ volatile bool Temperature::raw_temps_ready = false;
|
||||
|
||||
#if MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED > 1
|
||||
#define MULTI_MAX_CONSECUTIVE_LOW_TEMP_ERR 1
|
||||
uint8_t Temperature::consecutive_low_temperature_error[HOTENDS] = { 0 };
|
||||
uint8_t Temperature::consecutive_low_temperature_error[HOTENDS]; // = { 0 }
|
||||
#endif
|
||||
|
||||
#if PREHEAT_TIME_HOTEND_MS > 0
|
||||
millis_t Temperature::preheat_end_ms_hotend[HOTENDS] { 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;
|
||||
@ -1781,15 +1781,15 @@ void Temperature::mintemp_error(const heater_id_t heater_id) {
|
||||
if (!flag_chamber_excess_heat && temp_chamber.is_above_target((HIGH_EXCESS_HEAT_LIMIT) - 1)) {
|
||||
// Open vent after MIN_COOLING_SLOPE_TIME_CHAMBER_VENT seconds if the
|
||||
// temperature didn't drop at least MIN_COOLING_SLOPE_DEG_CHAMBER_VENT
|
||||
if (next_cool_check_ms_2 == 0 || ELAPSED(ms, next_cool_check_ms_2)) {
|
||||
if (next_cool_check_ms == 0 || ELAPSED(ms, next_cool_check_ms)) {
|
||||
if (temp_chamber.celsius - old_temp > MIN_COOLING_SLOPE_DEG_CHAMBER_VENT)
|
||||
flag_chamber_excess_heat = true; // the bed is heating the chamber too much
|
||||
next_cool_check_ms_2 = ms + SEC_TO_MS(MIN_COOLING_SLOPE_TIME_CHAMBER_VENT);
|
||||
next_cool_check_ms = ms + SEC_TO_MS(MIN_COOLING_SLOPE_TIME_CHAMBER_VENT);
|
||||
old_temp = temp_chamber.celsius;
|
||||
}
|
||||
}
|
||||
else {
|
||||
next_cool_check_ms_2 = 0;
|
||||
next_cool_check_ms = 0;
|
||||
old_temp = 9999;
|
||||
}
|
||||
if (flag_chamber_excess_heat && temp_chamber.is_above_target((LOW_EXCESS_HEAT_LIMIT) - 1))
|
||||
@ -2492,7 +2492,7 @@ void Temperature::updateTemperaturesFromRawValues() {
|
||||
/**
|
||||
// DEBUG PREHEATING TIME
|
||||
SERIAL_ECHOLNPGM("\nExtruder = ", e, " Preheat On/Off = ", is_preheating(e));
|
||||
const float test_is_preheating = (preheat_end_time[HOTEND_INDEX] - millis()) * 0.001f;
|
||||
const float test_is_preheating = (preheat_end_ms_hotend[HOTEND_INDEX] - millis()) * 0.001f;
|
||||
if (test_is_preheating < 31) SERIAL_ECHOLNPGM("Extruder = ", e, " Preheat remaining time = ", test_is_preheating, "s", "\n");
|
||||
//*/
|
||||
|
||||
@ -3551,7 +3551,7 @@ void Temperature::isr() {
|
||||
#if ENABLED(FAN_SOFT_PWM)
|
||||
|
||||
#if ENABLED(USE_CONTROLLER_FAN)
|
||||
WRITE(CONTROLLER_FAN_PIN, soft_pwm_controller.add(pwm_mask, soft_pwm_controller_speed));
|
||||
WRITE(CONTROLLER_FAN_PIN, soft_pwm_controller.add(pwm_mask, controllerFan.soft_pwm_speed));
|
||||
#endif
|
||||
|
||||
#define _FAN_PWM(N) do{ \
|
||||
@ -4183,7 +4183,7 @@ void Temperature::isr() {
|
||||
|
||||
bool wants_to_cool = false;
|
||||
celsius_float_t target_temp = -1.0, old_temp = 9999.0;
|
||||
millis_t now, next_temp_ms = 0, next_cool_check_ms = 0;
|
||||
millis_t now, next_temp_ms = 0, cool_check_ms = 0;
|
||||
wait_for_heatup = true;
|
||||
do {
|
||||
// Target temperature might be changed during the loop
|
||||
@ -4241,9 +4241,9 @@ void Temperature::isr() {
|
||||
if (wants_to_cool) {
|
||||
// Break after MIN_COOLING_SLOPE_TIME seconds
|
||||
// if the temperature did not drop at least MIN_COOLING_SLOPE_DEG
|
||||
if (!next_cool_check_ms || ELAPSED(now, next_cool_check_ms)) {
|
||||
if (!cool_check_ms || ELAPSED(now, cool_check_ms)) {
|
||||
if (old_temp - temp < float(MIN_COOLING_SLOPE_DEG)) break;
|
||||
next_cool_check_ms = now + SEC_TO_MS(MIN_COOLING_SLOPE_TIME);
|
||||
cool_check_ms = now + SEC_TO_MS(MIN_COOLING_SLOPE_TIME);
|
||||
old_temp = temp;
|
||||
}
|
||||
}
|
||||
@ -4320,7 +4320,7 @@ void Temperature::isr() {
|
||||
|
||||
bool wants_to_cool = false;
|
||||
celsius_float_t target_temp = -1, old_temp = 9999;
|
||||
millis_t now, next_temp_ms = 0, next_cool_check_ms = 0;
|
||||
millis_t now, next_temp_ms = 0, cool_check_ms = 0;
|
||||
wait_for_heatup = true;
|
||||
do {
|
||||
// Target temperature might be changed during the loop
|
||||
@ -4376,9 +4376,9 @@ void Temperature::isr() {
|
||||
if (wants_to_cool) {
|
||||
// Break after MIN_COOLING_SLOPE_TIME_BED seconds
|
||||
// if the temperature did not drop at least MIN_COOLING_SLOPE_DEG_BED
|
||||
if (!next_cool_check_ms || ELAPSED(now, next_cool_check_ms)) {
|
||||
if (!cool_check_ms || ELAPSED(now, cool_check_ms)) {
|
||||
if (old_temp - temp < float(MIN_COOLING_SLOPE_DEG_BED)) break;
|
||||
next_cool_check_ms = now + SEC_TO_MS(MIN_COOLING_SLOPE_TIME_BED);
|
||||
cool_check_ms = now + SEC_TO_MS(MIN_COOLING_SLOPE_TIME_BED);
|
||||
old_temp = temp;
|
||||
}
|
||||
}
|
||||
@ -4515,7 +4515,7 @@ void Temperature::isr() {
|
||||
|
||||
bool wants_to_cool = false;
|
||||
float target_temp = -1, old_temp = 9999;
|
||||
millis_t now, next_temp_ms = 0, next_cool_check_ms = 0;
|
||||
millis_t now, next_temp_ms = 0, cool_check_ms = 0;
|
||||
wait_for_heatup = true;
|
||||
do {
|
||||
// Target temperature might be changed during the loop
|
||||
@ -4567,9 +4567,9 @@ void Temperature::isr() {
|
||||
if (wants_to_cool) {
|
||||
// Break after MIN_COOLING_SLOPE_TIME_CHAMBER seconds
|
||||
// if the temperature did not drop at least MIN_COOLING_SLOPE_DEG_CHAMBER
|
||||
if (!next_cool_check_ms || ELAPSED(now, next_cool_check_ms)) {
|
||||
if (!cool_check_ms || ELAPSED(now, cool_check_ms)) {
|
||||
if (old_temp - temp < float(MIN_COOLING_SLOPE_DEG_CHAMBER)) break;
|
||||
next_cool_check_ms = now + SEC_TO_MS(MIN_COOLING_SLOPE_TIME_CHAMBER);
|
||||
cool_check_ms = now + SEC_TO_MS(MIN_COOLING_SLOPE_TIME_CHAMBER);
|
||||
old_temp = temp;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user