heater_ind_t => heater_id_t

This commit is contained in:
Scott Lahteine 2020-09-13 18:06:14 -05:00
parent d93471fdad
commit 49ca16c3fb
6 changed files with 64 additions and 64 deletions

View File

@ -62,7 +62,7 @@ void GcodeSuite::M303() {
#define SI TERN(PIDTEMPBED, H_BED, H_E0) #define SI TERN(PIDTEMPBED, H_BED, H_E0)
#define EI TERN(PIDTEMP, HOTENDS - 1, H_BED) #define EI TERN(PIDTEMP, HOTENDS - 1, H_BED)
const heater_ind_t e = (heater_ind_t)parser.intval('E'); const heater_id_t e = (heater_id_t)parser.intval('E');
if (!WITHIN(e, SI, EI)) { if (!WITHIN(e, SI, EI)) {
SERIAL_ECHOLNPGM(STR_PID_BAD_EXTRUDER_NUM); SERIAL_ECHOLNPGM(STR_PID_BAD_EXTRUDER_NUM);
TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_BAD_EXTRUDER_NUM)); TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_BAD_EXTRUDER_NUM));

View File

@ -519,13 +519,13 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const
} }
} }
FORCE_INLINE void _draw_heater_status(const heater_ind_t heater, const char prefix, const bool blink) { FORCE_INLINE void _draw_heater_status(const heater_id_t heater_id, const char prefix, const bool blink) {
#if HAS_HEATED_BED #if HAS_HEATED_BED
const bool isBed = heater < 0; const bool isBed = heater_id < 0;
const float t1 = (isBed ? thermalManager.degBed() : thermalManager.degHotend(heater)), const float t1 = (isBed ? thermalManager.degBed() : thermalManager.degHotend(heater_id)),
t2 = (isBed ? thermalManager.degTargetBed() : thermalManager.degTargetHotend(heater)); t2 = (isBed ? thermalManager.degTargetBed() : thermalManager.degTargetHotend(heater_id));
#else #else
const float t1 = thermalManager.degHotend(heater), t2 = thermalManager.degTargetHotend(heater); const float t1 = thermalManager.degHotend(heater_id), t2 = thermalManager.degTargetHotend(heater_id);
#endif #endif
if (prefix >= 0) lcd_put_wchar(prefix); if (prefix >= 0) lcd_put_wchar(prefix);
@ -540,7 +540,7 @@ FORCE_INLINE void _draw_heater_status(const heater_ind_t heater, const char pref
#if HAS_HEATED_BED #if HAS_HEATED_BED
isBed ? thermalManager.bed_idle.timed_out : isBed ? thermalManager.bed_idle.timed_out :
#endif #endif
thermalManager.hotend_idle[heater].timed_out thermalManager.hotend_idle[heater_id].timed_out
); );
if (!blink && is_idle) { if (!blink && is_idle) {
@ -990,7 +990,7 @@ void MarlinUI::draw_status_screen() {
void MarlinUI::draw_hotend_status(const uint8_t row, const uint8_t extruder) { void MarlinUI::draw_hotend_status(const uint8_t row, const uint8_t extruder) {
if (row < LCD_HEIGHT) { if (row < LCD_HEIGHT) {
lcd_moveto(LCD_WIDTH - 9, row); lcd_moveto(LCD_WIDTH - 9, row);
_draw_heater_status((heater_ind_t)extruder, LCD_STR_THERMOMETER[0], get_blink()); _draw_heater_status((heater_id_t)extruder, LCD_STR_THERMOMETER[0], get_blink());
} }
} }

View File

@ -178,17 +178,17 @@ FORCE_INLINE void _draw_centered_temp(const int16_t temp, const uint8_t tx, cons
#if DO_DRAW_HOTENDS #if DO_DRAW_HOTENDS
// Draw hotend bitmap with current and target temperatures // Draw hotend bitmap with current and target temperatures
FORCE_INLINE void _draw_hotend_status(const heater_ind_t heater, const bool blink) { FORCE_INLINE void _draw_hotend_status(const heater_id_t heater_id, const bool blink) {
#if !HEATER_IDLE_HANDLER #if !HEATER_IDLE_HANDLER
UNUSED(blink); UNUSED(blink);
#endif #endif
const bool isHeat = HOTEND_ALT(heater); const bool isHeat = HOTEND_ALT(heater_id);
const uint8_t tx = STATUS_HOTEND_TEXT_X(heater); const uint8_t tx = STATUS_HOTEND_TEXT_X(heater_id);
const float temp = thermalManager.degHotend(heater), const float temp = thermalManager.degHotend(heater_id),
target = thermalManager.degTargetHotend(heater); target = thermalManager.degTargetHotend(heater_id);
#if DISABLED(STATUS_HOTEND_ANIM) #if DISABLED(STATUS_HOTEND_ANIM)
#define STATIC_HOTEND true #define STATIC_HOTEND true
@ -237,24 +237,24 @@ FORCE_INLINE void _draw_centered_temp(const int16_t temp, const uint8_t tx, cons
#if ANIM_HOTEND #if ANIM_HOTEND
// Draw hotend bitmap, either whole or split by the heating percent // Draw hotend bitmap, either whole or split by the heating percent
const uint8_t hx = STATUS_HOTEND_X(heater), const uint8_t hx = STATUS_HOTEND_X(heater_id),
bw = STATUS_HOTEND_BYTEWIDTH(heater); bw = STATUS_HOTEND_BYTEWIDTH(heater_id);
#if ENABLED(STATUS_HEAT_PERCENT) #if ENABLED(STATUS_HEAT_PERCENT)
if (isHeat && tall <= BAR_TALL) { if (isHeat && tall <= BAR_TALL) {
const uint8_t ph = STATUS_HEATERS_HEIGHT - 1 - tall; const uint8_t ph = STATUS_HEATERS_HEIGHT - 1 - tall;
u8g.drawBitmapP(hx, STATUS_HEATERS_Y, bw, ph, HOTEND_BITMAP(heater, false)); u8g.drawBitmapP(hx, STATUS_HEATERS_Y, bw, ph, HOTEND_BITMAP(heater_id, false));
u8g.drawBitmapP(hx, STATUS_HEATERS_Y + ph, bw, tall + 1, HOTEND_BITMAP(heater, true) + ph * bw); u8g.drawBitmapP(hx, STATUS_HEATERS_Y + ph, bw, tall + 1, HOTEND_BITMAP(heater_id, true) + ph * bw);
} }
else else
#endif #endif
u8g.drawBitmapP(hx, STATUS_HEATERS_Y, bw, STATUS_HEATERS_HEIGHT, HOTEND_BITMAP(heater, isHeat)); u8g.drawBitmapP(hx, STATUS_HEATERS_Y, bw, STATUS_HEATERS_HEIGHT, HOTEND_BITMAP(heater_id, isHeat));
#endif #endif
} // PAGE_CONTAINS } // PAGE_CONTAINS
if (PAGE_UNDER(7)) { if (PAGE_UNDER(7)) {
#if HEATER_IDLE_HANDLER #if HEATER_IDLE_HANDLER
const bool dodraw = (blink || !thermalManager.hotend_idle[heater].timed_out); const bool dodraw = (blink || !thermalManager.hotend_idle[heater_id].timed_out);
#else #else
constexpr bool dodraw = true; constexpr bool dodraw = true;
#endif #endif
@ -597,7 +597,7 @@ void MarlinUI::draw_status_screen() {
// Extruders // Extruders
#if DO_DRAW_HOTENDS #if DO_DRAW_HOTENDS
LOOP_L_N(e, MAX_HOTEND_DRAW) LOOP_L_N(e, MAX_HOTEND_DRAW)
_draw_hotend_status((heater_ind_t)e, blink); _draw_hotend_status((heater_id_t)e, blink);
#endif #endif
// Laser / Spindle // Laser / Spindle

View File

@ -868,7 +868,7 @@ namespace ExtUI {
} }
void startPIDTune(const float temp, extruder_t tool) { void startPIDTune(const float temp, extruder_t tool) {
thermalManager.PID_autotune(temp, (heater_ind_t)tool, 8, true); thermalManager.PID_autotune(temp, (heater_id_t)tool, 8, true);
} }
#endif #endif

View File

@ -377,7 +377,7 @@ volatile bool Temperature::raw_temps_ready = false;
* Needs sufficient heater power to make some overshoot at target * Needs sufficient heater power to make some overshoot at target
* temperature to succeed. * temperature to succeed.
*/ */
void Temperature::PID_autotune(const float &target, const heater_ind_t heater, const int8_t ncycles, const bool set_result/*=false*/) { void Temperature::PID_autotune(const float &target, const heater_id_t heater_id, const int8_t ncycles, const bool set_result/*=false*/) {
float current_temp = 0.0; float current_temp = 0.0;
int cycles = 0; int cycles = 0;
bool heating = true; bool heating = true;
@ -389,11 +389,11 @@ volatile bool Temperature::raw_temps_ready = false;
PID_t tune_pid = { 0, 0, 0 }; PID_t tune_pid = { 0, 0, 0 };
float maxT = 0, minT = 10000; float maxT = 0, minT = 10000;
const bool isbed = (heater == H_BED); const bool isbed = (heater_id == H_BED);
#if HAS_PID_FOR_BOTH #if HAS_PID_FOR_BOTH
#define GHV(B,H) (isbed ? (B) : (H)) #define GHV(B,H) (isbed ? (B) : (H))
#define SHV(B,H) do{ if (isbed) temp_bed.soft_pwm_amount = B; else temp_hotend[heater].soft_pwm_amount = H; }while(0) #define SHV(B,H) do{ if (isbed) temp_bed.soft_pwm_amount = B; else temp_hotend[heater_id].soft_pwm_amount = H; }while(0)
#define ONHEATINGSTART() (isbed ? printerEventLEDs.onBedHeatingStart() : printerEventLEDs.onHotendHeatingStart()) #define ONHEATINGSTART() (isbed ? printerEventLEDs.onBedHeatingStart() : printerEventLEDs.onHotendHeatingStart())
#define ONHEATING(S,C,T) (isbed ? printerEventLEDs.onBedHeating(S,C,T) : printerEventLEDs.onHotendHeating(S,C,T)) #define ONHEATING(S,C,T) (isbed ? printerEventLEDs.onBedHeating(S,C,T) : printerEventLEDs.onHotendHeating(S,C,T))
#elif ENABLED(PIDTEMPBED) #elif ENABLED(PIDTEMPBED)
@ -403,7 +403,7 @@ volatile bool Temperature::raw_temps_ready = false;
#define ONHEATING(S,C,T) printerEventLEDs.onBedHeating(S,C,T) #define ONHEATING(S,C,T) printerEventLEDs.onBedHeating(S,C,T)
#else #else
#define GHV(B,H) H #define GHV(B,H) H
#define SHV(B,H) (temp_hotend[heater].soft_pwm_amount = H) #define SHV(B,H) (temp_hotend[heater_id].soft_pwm_amount = H)
#define ONHEATINGSTART() printerEventLEDs.onHotendHeatingStart() #define ONHEATINGSTART() printerEventLEDs.onHotendHeatingStart()
#define ONHEATING(S,C,T) printerEventLEDs.onHotendHeating(S,C,T) #define ONHEATING(S,C,T) printerEventLEDs.onHotendHeating(S,C,T)
#endif #endif
@ -427,7 +427,7 @@ volatile bool Temperature::raw_temps_ready = false;
TERN_(HAS_AUTO_FAN, next_auto_fan_check_ms = next_temp_ms + 2500UL); TERN_(HAS_AUTO_FAN, next_auto_fan_check_ms = next_temp_ms + 2500UL);
if (target > GHV(BED_MAX_TARGET, temp_range[heater].maxtemp - HOTEND_OVERSHOOT)) { if (target > GHV(BED_MAX_TARGET, temp_range[heater_id].maxtemp - HOTEND_OVERSHOOT)) {
SERIAL_ECHOLNPGM(STR_PID_TEMP_TOO_HIGH); SERIAL_ECHOLNPGM(STR_PID_TEMP_TOO_HIGH);
TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_TEMP_TOO_HIGH)); TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_TEMP_TOO_HIGH));
return; return;
@ -441,7 +441,7 @@ volatile bool Temperature::raw_temps_ready = false;
SHV(bias = d = (MAX_BED_POWER) >> 1, bias = d = (PID_MAX) >> 1); SHV(bias = d = (MAX_BED_POWER) >> 1, bias = d = (PID_MAX) >> 1);
#if ENABLED(PRINTER_EVENT_LEDS) #if ENABLED(PRINTER_EVENT_LEDS)
const float start_temp = GHV(temp_bed.celsius, temp_hotend[heater].celsius); const float start_temp = GHV(temp_bed.celsius, temp_hotend[heater_id].celsius);
LEDColor color = ONHEATINGSTART(); LEDColor color = ONHEATINGSTART();
#endif #endif
@ -457,7 +457,7 @@ volatile bool Temperature::raw_temps_ready = false;
updateTemperaturesFromRawValues(); updateTemperaturesFromRawValues();
// Get the current temperature and constrain it // Get the current temperature and constrain it
current_temp = GHV(temp_bed.celsius, temp_hotend[heater].celsius); current_temp = GHV(temp_bed.celsius, temp_hotend[heater_id].celsius);
NOLESS(maxT, current_temp); NOLESS(maxT, current_temp);
NOMORE(minT, current_temp); NOMORE(minT, current_temp);
@ -549,7 +549,7 @@ volatile bool Temperature::raw_temps_ready = false;
// Report heater states every 2 seconds // Report heater states every 2 seconds
if (ELAPSED(ms, next_temp_ms)) { if (ELAPSED(ms, next_temp_ms)) {
#if HAS_TEMP_SENSOR #if HAS_TEMP_SENSOR
print_heater_states(isbed ? active_extruder : heater); print_heater_states(isbed ? active_extruder : heater_id);
SERIAL_EOL(); SERIAL_EOL();
#endif #endif
next_temp_ms = ms + 2000UL; next_temp_ms = ms + 2000UL;
@ -564,10 +564,10 @@ volatile bool Temperature::raw_temps_ready = false;
if (current_temp > watch_temp_target) heated = true; // - Flag if target temperature reached if (current_temp > watch_temp_target) heated = true; // - Flag if target temperature reached
} }
else if (ELAPSED(ms, temp_change_ms)) // Watch timer expired else if (ELAPSED(ms, temp_change_ms)) // Watch timer expired
_temp_error(heater, str_t_heating_failed, GET_TEXT(MSG_HEATING_FAILED_LCD)); _temp_error(heater_id, str_t_heating_failed, GET_TEXT(MSG_HEATING_FAILED_LCD));
} }
else if (current_temp < target - (MAX_OVERSHOOT_PID_AUTOTUNE)) // Heated, then temperature fell too far? else if (current_temp < target - (MAX_OVERSHOOT_PID_AUTOTUNE)) // Heated, then temperature fell too far?
_temp_error(heater, str_t_thermal_runaway, GET_TEXT(MSG_THERMAL_RUNAWAY)); _temp_error(heater_id, str_t_thermal_runaway, GET_TEXT(MSG_THERMAL_RUNAWAY));
} }
#endif #endif
} // every 2 seconds } // every 2 seconds
@ -608,9 +608,9 @@ volatile bool Temperature::raw_temps_ready = false;
}while(0) }while(0)
#define _SET_EXTRUDER_PID() do { \ #define _SET_EXTRUDER_PID() do { \
PID_PARAM(Kp, heater) = tune_pid.Kp; \ PID_PARAM(Kp, heater_id) = tune_pid.Kp; \
PID_PARAM(Ki, heater) = scalePID_i(tune_pid.Ki); \ PID_PARAM(Ki, heater_id) = scalePID_i(tune_pid.Ki); \
PID_PARAM(Kd, heater) = scalePID_d(tune_pid.Kd); \ PID_PARAM(Kd, heater_id) = scalePID_d(tune_pid.Kd); \
updatePID(); }while(0) updatePID(); }while(0)
// Use the result? (As with "M303 U1") // Use the result? (As with "M303 U1")
@ -651,7 +651,7 @@ volatile bool Temperature::raw_temps_ready = false;
* Class and Instance Methods * Class and Instance Methods
*/ */
int16_t Temperature::getHeaterPower(const heater_ind_t heater_id) { int16_t Temperature::getHeaterPower(const heater_id_t heater_id) {
switch (heater_id) { switch (heater_id) {
#if HAS_HEATED_BED #if HAS_HEATED_BED
case H_BED: return temp_bed.soft_pwm_amount; case H_BED: return temp_bed.soft_pwm_amount;
@ -758,7 +758,7 @@ int16_t Temperature::getHeaterPower(const heater_ind_t heater_id) {
// Temperature Error Handlers // Temperature Error Handlers
// //
inline void loud_kill(PGM_P const lcd_msg, const heater_ind_t heater) { inline void loud_kill(PGM_P const lcd_msg, const heater_id_t heater_id) {
marlin_state = MF_KILLED; marlin_state = MF_KILLED;
#if USE_BEEPER #if USE_BEEPER
for (uint8_t i = 20; i--;) { for (uint8_t i = 20; i--;) {
@ -767,10 +767,10 @@ inline void loud_kill(PGM_P const lcd_msg, const heater_ind_t heater) {
} }
WRITE(BEEPER_PIN, HIGH); WRITE(BEEPER_PIN, HIGH);
#endif #endif
kill(lcd_msg, HEATER_PSTR(heater)); kill(lcd_msg, HEATER_PSTR(heater_id));
} }
void Temperature::_temp_error(const heater_ind_t heater, PGM_P const serial_msg, PGM_P const lcd_msg) { void Temperature::_temp_error(const heater_id_t heater_id, PGM_P const serial_msg, PGM_P const lcd_msg) {
static uint8_t killed = 0; static uint8_t killed = 0;
@ -778,9 +778,9 @@ void Temperature::_temp_error(const heater_ind_t heater, PGM_P const serial_msg,
SERIAL_ERROR_START(); SERIAL_ERROR_START();
serialprintPGM(serial_msg); serialprintPGM(serial_msg);
SERIAL_ECHOPGM(STR_STOPPED_HEATER); SERIAL_ECHOPGM(STR_STOPPED_HEATER);
if (heater >= 0) if (heater_id >= 0)
SERIAL_ECHO((int)heater); SERIAL_ECHO((int)heater_id);
else if (TERN0(HAS_HEATED_CHAMBER, heater == H_CHAMBER)) else if (TERN0(HAS_HEATED_CHAMBER, heater_id == H_CHAMBER))
SERIAL_ECHOPGM(STR_HEATER_CHAMBER); SERIAL_ECHOPGM(STR_HEATER_CHAMBER);
else else
SERIAL_ECHOPGM(STR_HEATER_BED); SERIAL_ECHOPGM(STR_HEATER_BED);
@ -801,25 +801,25 @@ void Temperature::_temp_error(const heater_ind_t heater, PGM_P const serial_msg,
if (ELAPSED(ms, expire_ms)) ++killed; if (ELAPSED(ms, expire_ms)) ++killed;
break; break;
case 2: case 2:
loud_kill(lcd_msg, heater); loud_kill(lcd_msg, heater_id);
++killed; ++killed;
break; break;
} }
#elif defined(BOGUS_TEMPERATURE_GRACE_PERIOD) #elif defined(BOGUS_TEMPERATURE_GRACE_PERIOD)
UNUSED(killed); UNUSED(killed);
#else #else
if (!killed) { killed = 1; loud_kill(lcd_msg, heater); } if (!killed) { killed = 1; loud_kill(lcd_msg, heater_id); }
#endif #endif
} }
void Temperature::max_temp_error(const heater_ind_t heater) { void Temperature::max_temp_error(const heater_id_t heater_id) {
TERN_(DWIN_CREALITY_LCD, Popup_Window_Temperature(1)); TERN_(DWIN_CREALITY_LCD, Popup_Window_Temperature(1));
_temp_error(heater, PSTR(STR_T_MAXTEMP), GET_TEXT(MSG_ERR_MAXTEMP)); _temp_error(heater_id, PSTR(STR_T_MAXTEMP), GET_TEXT(MSG_ERR_MAXTEMP));
} }
void Temperature::min_temp_error(const heater_ind_t heater) { void Temperature::min_temp_error(const heater_id_t heater_id) {
TERN_(DWIN_CREALITY_LCD, Popup_Window_Temperature(0)); TERN_(DWIN_CREALITY_LCD, Popup_Window_Temperature(0));
_temp_error(heater, PSTR(STR_T_MINTEMP), GET_TEXT(MSG_ERR_MINTEMP)); _temp_error(heater_id, PSTR(STR_T_MINTEMP), GET_TEXT(MSG_ERR_MINTEMP));
} }
#if HAS_HOTEND #if HAS_HOTEND
@ -1041,14 +1041,14 @@ void Temperature::manage_heater() {
HOTEND_LOOP() { HOTEND_LOOP() {
#if ENABLED(THERMAL_PROTECTION_HOTENDS) #if ENABLED(THERMAL_PROTECTION_HOTENDS)
if (degHotend(e) > temp_range[e].maxtemp) if (degHotend(e) > temp_range[e].maxtemp)
_temp_error((heater_ind_t)e, str_t_thermal_runaway, GET_TEXT(MSG_THERMAL_RUNAWAY)); _temp_error((heater_id_t)e, str_t_thermal_runaway, GET_TEXT(MSG_THERMAL_RUNAWAY));
#endif #endif
TERN_(HEATER_IDLE_HANDLER, hotend_idle[e].update(ms)); TERN_(HEATER_IDLE_HANDLER, hotend_idle[e].update(ms));
#if ENABLED(THERMAL_PROTECTION_HOTENDS) #if ENABLED(THERMAL_PROTECTION_HOTENDS)
// Check for thermal runaway // Check for thermal runaway
thermal_runaway_protection(tr_state_machine[e], temp_hotend[e].celsius, temp_hotend[e].target, (heater_ind_t)e, THERMAL_PROTECTION_PERIOD, THERMAL_PROTECTION_HYSTERESIS); thermal_runaway_protection(tr_state_machine[e], temp_hotend[e].celsius, temp_hotend[e].target, (heater_id_t)e, THERMAL_PROTECTION_PERIOD, THERMAL_PROTECTION_HYSTERESIS);
#endif #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_preheating(e)) && temp_hotend[e].celsius < temp_range[e].maxtemp ? (int)get_pid_output_hotend(e) >> 1 : 0;
@ -1058,7 +1058,7 @@ void Temperature::manage_heater() {
if (watch_hotend[e].next_ms && ELAPSED(ms, watch_hotend[e].next_ms)) { // Time to check this extruder? if (watch_hotend[e].next_ms && ELAPSED(ms, watch_hotend[e].next_ms)) { // Time to check this extruder?
if (degHotend(e) < watch_hotend[e].target) { // Failed to increase enough? if (degHotend(e) < watch_hotend[e].target) { // Failed to increase enough?
TERN_(DWIN_CREALITY_LCD, Popup_Window_Temperature(0)); TERN_(DWIN_CREALITY_LCD, Popup_Window_Temperature(0));
_temp_error((heater_ind_t)e, str_t_heating_failed, GET_TEXT(MSG_HEATING_FAILED_LCD)); _temp_error((heater_id_t)e, str_t_heating_failed, GET_TEXT(MSG_HEATING_FAILED_LCD));
} }
else // Start again if the target is still far off else // Start again if the target is still far off
start_watching_hotend(e); start_watching_hotend(e);
@ -1945,7 +1945,7 @@ void Temperature::init() {
Temperature::tr_state_machine_t Temperature::tr_state_machine_chamber; // = { TRInactive, 0 }; Temperature::tr_state_machine_t Temperature::tr_state_machine_chamber; // = { TRInactive, 0 };
#endif #endif
void Temperature::thermal_runaway_protection(Temperature::tr_state_machine_t &sm, const float &current, const float &target, const heater_ind_t heater_id, const uint16_t period_seconds, const uint16_t hysteresis_degc) { void Temperature::thermal_runaway_protection(Temperature::tr_state_machine_t &sm, const float &current, const float &target, const heater_id_t heater_id, const uint16_t period_seconds, const uint16_t hysteresis_degc) {
static float tr_target_temperature[HOTENDS + 1] = { 0.0 }; static float tr_target_temperature[HOTENDS + 1] = { 0.0 };
@ -2311,12 +2311,12 @@ void Temperature::readings_ready() {
const bool heater_on = (temp_hotend[e].target > 0 const bool heater_on = (temp_hotend[e].target > 0
|| TERN0(PIDTEMP, temp_hotend[e].soft_pwm_amount) > 0 || TERN0(PIDTEMP, temp_hotend[e].soft_pwm_amount) > 0
); );
if (rawtemp > temp_range[e].raw_max * tdir) max_temp_error((heater_ind_t)e); if (rawtemp > temp_range[e].raw_max * tdir) max_temp_error((heater_id_t)e);
if (heater_on && rawtemp < temp_range[e].raw_min * tdir && !is_preheating(e)) { if (heater_on && rawtemp < temp_range[e].raw_min * tdir && !is_preheating(e)) {
#ifdef MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED #ifdef MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED
if (++consecutive_low_temperature_error[e] >= MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED) if (++consecutive_low_temperature_error[e] >= MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED)
#endif #endif
min_temp_error((heater_ind_t)e); min_temp_error((heater_id_t)e);
} }
#ifdef MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED #ifdef MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED
else else
@ -2883,7 +2883,7 @@ void Temperature::tick() {
#if ENABLED(SHOW_TEMP_ADC_VALUES) #if ENABLED(SHOW_TEMP_ADC_VALUES)
, const float r , const float r
#endif #endif
, const heater_ind_t e=INDEX_NONE , const heater_id_t e=INDEX_NONE
) { ) {
char k; char k;
switch (e) { switch (e) {
@ -2974,10 +2974,10 @@ void Temperature::tick() {
#if ENABLED(SHOW_TEMP_ADC_VALUES) #if ENABLED(SHOW_TEMP_ADC_VALUES)
, rawHotendTemp(e) , rawHotendTemp(e)
#endif #endif
, (heater_ind_t)e , (heater_id_t)e
); );
#endif #endif
SERIAL_ECHOPAIR(" @:", getHeaterPower((heater_ind_t)target_extruder)); SERIAL_ECHOPAIR(" @:", getHeaterPower((heater_id_t)target_extruder));
#if HAS_HEATED_BED #if HAS_HEATED_BED
SERIAL_ECHOPAIR(" B@:", getHeaterPower(H_BED)); SERIAL_ECHOPAIR(" B@:", getHeaterPower(H_BED));
#endif #endif
@ -2988,7 +2988,7 @@ void Temperature::tick() {
HOTEND_LOOP() { HOTEND_LOOP() {
SERIAL_ECHOPAIR(" @", e); SERIAL_ECHOPAIR(" @", e);
SERIAL_CHAR(':'); SERIAL_CHAR(':');
SERIAL_ECHO(getHeaterPower((heater_ind_t)e)); SERIAL_ECHO(getHeaterPower((heater_id_t)e));
} }
#endif #endif
} }

View File

@ -45,7 +45,7 @@ typedef enum : int8_t {
INDEX_NONE = -5, INDEX_NONE = -5,
H_PROBE, H_REDUNDANT, H_CHAMBER, H_BED, H_PROBE, H_REDUNDANT, H_CHAMBER, H_BED,
H_E0, H_E1, H_E2, H_E3, H_E4, H_E5, H_E6, H_E7 H_E0, H_E1, H_E2, H_E3, H_E4, H_E5, H_E6, H_E7
} heater_ind_t; } heater_id_t;
// PID storage // PID storage
typedef struct { float Kp, Ki, Kd; } PID_t; typedef struct { float Kp, Ki, Kd; } PID_t;
@ -701,7 +701,7 @@ class Temperature {
/** /**
* The software PWM power for a heater * The software PWM power for a heater
*/ */
static int16_t getHeaterPower(const heater_ind_t heater); static int16_t getHeaterPower(const heater_id_t heater_id);
/** /**
* Switch off all heaters, set all target temperatures to 0 * Switch off all heaters, set all target temperatures to 0
@ -720,7 +720,7 @@ class Temperature {
* Perform auto-tuning for hotend or bed in response to M303 * Perform auto-tuning for hotend or bed in response to M303
*/ */
#if HAS_PID_HEATING #if HAS_PID_HEATING
static void PID_autotune(const float &target, const heater_ind_t hotend, const int8_t ncycles, const bool set_result=false); static void PID_autotune(const float &target, const heater_id_t heater_id, const int8_t ncycles, const bool set_result=false);
#if ENABLED(NO_FAN_SLOWING_IN_PID_TUNING) #if ENABLED(NO_FAN_SLOWING_IN_PID_TUNING)
static bool adaptive_fan_slowing; static bool adaptive_fan_slowing;
@ -811,9 +811,9 @@ class Temperature {
TERN_(HAS_HEATED_CHAMBER, static float get_pid_output_chamber()); TERN_(HAS_HEATED_CHAMBER, static float get_pid_output_chamber());
static void _temp_error(const heater_ind_t e, PGM_P const serial_msg, PGM_P const lcd_msg); static void _temp_error(const heater_id_t e, PGM_P const serial_msg, PGM_P const lcd_msg);
static void min_temp_error(const heater_ind_t e); static void min_temp_error(const heater_id_t e);
static void max_temp_error(const heater_ind_t e); static void max_temp_error(const heater_id_t e);
#define HAS_THERMAL_PROTECTION (EITHER(THERMAL_PROTECTION_HOTENDS, THERMAL_PROTECTION_CHAMBER) || HAS_THERMALLY_PROTECTED_BED) #define HAS_THERMAL_PROTECTION (EITHER(THERMAL_PROTECTION_HOTENDS, THERMAL_PROTECTION_CHAMBER) || HAS_THERMALLY_PROTECTED_BED)
@ -830,7 +830,7 @@ class Temperature {
TERN_(HAS_THERMALLY_PROTECTED_BED, static tr_state_machine_t tr_state_machine_bed); TERN_(HAS_THERMALLY_PROTECTED_BED, static tr_state_machine_t tr_state_machine_bed);
TERN_(THERMAL_PROTECTION_CHAMBER, static tr_state_machine_t tr_state_machine_chamber); TERN_(THERMAL_PROTECTION_CHAMBER, static tr_state_machine_t tr_state_machine_chamber);
static void thermal_runaway_protection(tr_state_machine_t &state, const float &current, const float &target, const heater_ind_t heater_id, const uint16_t period_seconds, const uint16_t hysteresis_degc); static void thermal_runaway_protection(tr_state_machine_t &state, const float &current, const float &target, const heater_id_t heater_id, const uint16_t period_seconds, const uint16_t hysteresis_degc);
#endif // HAS_THERMAL_PROTECTION #endif // HAS_THERMAL_PROTECTION
}; };