Skip to content

Commit

Permalink
⛙ Merge w/Marlin
Browse files Browse the repository at this point in the history
  • Loading branch information
classicrocker883 committed Dec 12, 2024
2 parents ee5a0d5 + 23bc810 commit da6a577
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 5 deletions.
1 change: 1 addition & 0 deletions Marlin/src/gcode/bedlevel/abl/G29.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ G29_TYPE GcodeSuite::G29() {
#if ABL_USES_GRID

xy_probe_feedrate_mm_s = MMM_TO_MMS(parser.linearval('S', XY_PROBE_FEEDRATE));
if (xy_probe_feedrate_mm_s == 0) xy_probe_feedrate_mm_s = XY_PROBE_FEEDRATE; // Don't let "UBL Save Slot #0" break G29

const float x_min = probe.min_x(), x_max = probe.max_x(),
y_min = probe.min_y(), y_max = probe.max_y();
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/extui/ui_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1003,7 +1003,7 @@ namespace ExtUI {
feedrate_mm_s = MMM_TO_MMS(Z_PROBE_FEEDRATE_FAST);
destination.set(current_position.x, current_position.y, Z_CLEARANCE_BETWEEN_PROBES);
prepare_line_to_destination();
feedrate_mm_s = XY_PROBE_FEEDRATE_MM_S;
if (XY_PROBE_FEEDRATE_MM_S) feedrate_mm_s = XY_PROBE_FEEDRATE_MM_S;
destination.set(x_target, y_target);
prepare_line_to_destination();
}
Expand Down
86 changes: 82 additions & 4 deletions Marlin/src/module/temperature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1521,6 +1521,13 @@ int16_t Temperature::getHeaterPower(const heater_id_t heater_id) {
// Temperature Error Handlers
//

/**
* Loud Kill
* @brief Produce a loud alarm, park the head, "kill" the machine
* in response to a temperature error, e.g., a thermal runaway.
* @param lcd_msg: The message to display on the LCD
* @param heater_id: The heater that caused the error
*/
inline void loud_kill(FSTR_P const lcd_msg, const heater_id_t heater_id) {
marlin_state = MarlinState::MF_KILLED;
thermalManager.disable_all_heaters();
Expand Down Expand Up @@ -1551,13 +1558,24 @@ inline void loud_kill(FSTR_P const lcd_msg, const heater_id_t heater_id) {
kill(lcd_msg, HEATER_FSTR(heater_id));
}

/**
* Temperature Error
* @brief Handle a temperature error, e.g., a thermal runaway.
* @param heater_id: The heater that caused the error
* @param serial_msg: The message to display on the serial console
* @param lcd_msg: The message to display on the LCD
* @param deg: The detected temperature (if ERR_INCLUDE_TEMP)
*/
void Temperature::_temp_error(
const heater_id_t heater_id, FSTR_P const serial_msg, FSTR_P const lcd_msg
OPTARG(ERR_INCLUDE_TEMP, const celsius_float_t deg)
) {
#if BOGUS_TEMPERATURE_GRACE_PERIOD
#define HAS_BOGUS_TEMPERATURE_GRACE_PERIOD 1
#endif
static uint8_t killed = 0;

if (IsRunning() && TERN1(BOGUS_TEMPERATURE_GRACE_PERIOD, killed == 2)) {
if (IsRunning() && killed == TERN(HAS_BOGUS_TEMPERATURE_GRACE_PERIOD, 2, 0)) {
SERIAL_ERROR_START();
SERIAL_ECHO(serial_msg);
SERIAL_ECHOPGM(STR_STOPPED_HEATER);
Expand Down Expand Up @@ -1591,7 +1609,13 @@ void Temperature::_temp_error(
disable_all_heaters(); // always disable (even for bogus temp)
hal.watchdog_refresh();

#if BOGUS_TEMPERATURE_GRACE_PERIOD
#if HAS_BOGUS_TEMPERATURE_GRACE_PERIOD

// During boot the temperature may be unreliable, so when killed ==
// 0: Set the expire time
// 1: Check the expiration time has elapsed
// 2: Kill the machine
// >2: Do nothing
const millis_t ms = millis();
static millis_t expire_ms;
switch (killed) {
Expand All @@ -1607,13 +1631,21 @@ void Temperature::_temp_error(
++killed;
break;
}
#elif defined(BOGUS_TEMPERATURE_GRACE_PERIOD)
UNUSED(killed);

#else

if (!killed) { killed = 1; loud_kill(lcd_msg, heater_id); }

#endif
}

/**
* Max Temp Error
* @brief - The temperature reading is out of range, e.g., too high.
* May be caused by a disconnected thermistor which has infinite resistance.
* @param heater_id: The heater that caused the error
* @param deg: The detected temperature (if ERR_INCLUDE_TEMP)
*/
void Temperature::maxtemp_error(const heater_id_t heater_id OPTARG(ERR_INCLUDE_TEMP, const celsius_float_t deg)) {
#if HAS_HOTEND || HAS_HEATED_BED
TERN_(SOVOL_SV06_RTS, rts.gotoPageBeep(ID_KillBadTemp_L, ID_KillBadTemp_D));
Expand All @@ -1623,6 +1655,13 @@ void Temperature::maxtemp_error(const heater_id_t heater_id OPTARG(ERR_INCLUDE_T
_TEMP_ERROR(heater_id, F(STR_T_MAXTEMP), MSG_ERR_MAXTEMP, deg);
}

/**
* Min Temp Error
* @brief - The temperature reading is out of range, e.g., too high.
* May be caused by a shorted thermistor which has near zero resistance.
* @param heater_id: The heater that caused the error
* @param deg: The detected temperature (if ERR_INCLUDE_TEMP)
*/
void Temperature::mintemp_error(const heater_id_t heater_id OPTARG(ERR_INCLUDE_TEMP, const celsius_float_t deg)) {
#if HAS_HOTEND || HAS_HEATED_BED
TERN_(SOVOL_SV06_RTS, rts.gotoPageBeep(ID_KillBadTemp_L, ID_KillBadTemp_D));
Expand Down Expand Up @@ -1690,6 +1729,13 @@ void Temperature::mintemp_error(const heater_id_t heater_id OPTARG(ERR_INCLUDE_T

#if HAS_HOTEND

/**
* PID Output Hotend
* @brief Calculate the power output for the hotend (using PID or MPC)
* that is required to get closer to the target temperature.
* @param E_NAME: The extruder index
* @return The power output for the hotend
*/
float Temperature::get_pid_output_hotend(const uint8_t E_NAME) {
const uint8_t ee = HOTEND_INDEX;

Expand Down Expand Up @@ -1804,6 +1850,12 @@ void Temperature::mintemp_error(const heater_id_t heater_id OPTARG(ERR_INCLUDE_T

#if ENABLED(PIDTEMPBED)

/**
* PID Output Bed
* @brief Calculate the bed power output using PID that is required
* to get closer to the target temperature.
* @return The power output for the bed
*/
float Temperature::get_pid_output_bed() {
static PIDRunner<bed_info_t> bed_pid(temp_bed);
const float pid_output = bed_pid.get_pid_output();
Expand All @@ -1815,6 +1867,12 @@ void Temperature::mintemp_error(const heater_id_t heater_id OPTARG(ERR_INCLUDE_T

#if ENABLED(PIDTEMPCHAMBER)

/**
* PID Output Chamber
* @brief Calculate the chamber power output using PID that is required
* to get closer to the target temperature.
* @return The power output for the chamber
*/
float Temperature::get_pid_output_chamber() {
static PIDRunner<chamber_info_t> chamber_pid(temp_chamber);
const float pid_output = chamber_pid.get_pid_output();
Expand All @@ -1826,6 +1884,11 @@ void Temperature::mintemp_error(const heater_id_t heater_id OPTARG(ERR_INCLUDE_T

#if HAS_HOTEND

/**
* Manage Hotend Temperatures
* @brief Task for managing hotends, called from Temperature::task()
* @param ms Current Time
*/
void Temperature::manage_hotends(const millis_t &ms) {
HOTEND_LOOP() {
#if ENABLED(THERMAL_PROTECTION_HOTENDS)
Expand Down Expand Up @@ -1870,6 +1933,11 @@ void Temperature::mintemp_error(const heater_id_t heater_id OPTARG(ERR_INCLUDE_T

#if HAS_HEATED_BED

/**
* Manage Heated Bed Temperature
* @brief Task for managing the heated bed, called from Temperature::task()
* @param ms Current Time
*/
void Temperature::manage_heated_bed(const millis_t &ms) {

#if ENABLED(THERMAL_PROTECTION_BED)
Expand Down Expand Up @@ -1998,6 +2066,11 @@ void Temperature::mintemp_error(const heater_id_t heater_id OPTARG(ERR_INCLUDE_T

#if HAS_HEATED_CHAMBER

/**
* Manage Heated Chamber Temperature
* @brief Task for managing the heated chamber, called from Temperature::task()
* @param ms Current Time
*/
void Temperature::manage_heated_chamber(const millis_t &ms) {

#ifndef CHAMBER_CHECK_INTERVAL
Expand Down Expand Up @@ -2130,6 +2203,11 @@ void Temperature::mintemp_error(const heater_id_t heater_id OPTARG(ERR_INCLUDE_T

#if HAS_COOLER

/**
* Manage Heated Cooler Temperature
* @brief Task for managing the cooler, called from Temperature::task()
* @param ms Current Time
*/
void Temperature::manage_cooler(const millis_t &ms) {

#ifndef COOLER_CHECK_INTERVAL
Expand Down

0 comments on commit da6a577

Please sign in to comment.