diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 976edfe7ce70..5c4f5a4413d6 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -240,10 +240,6 @@ bool wait_for_heatup = true; #endif -// Inactivity shutdown -millis_t max_inactive_time, // = 0 - stepper_inactive_time = SEC_TO_MS(DEFAULT_STEPPER_DEACTIVE_TIME); - #if PIN_EXISTS(CHDK) extern millis_t chdk_timeout; #endif @@ -469,26 +465,39 @@ inline void manage_inactivity(const bool ignore_stepper_queue=false) { const millis_t ms = millis(); - if (max_inactive_time && ELAPSED(ms, gcode.previous_move_ms + max_inactive_time)) { + // Prevent steppers timing-out in the middle of M600 + // unless PAUSE_PARK_NO_STEPPER_TIMEOUT is disabled + const bool parked_or_ignoring = ignore_stepper_queue || + (BOTH(ADVANCED_PAUSE_FEATURE, PAUSE_PARK_NO_STEPPER_TIMEOUT) && did_pause_print); + + // Reset both the M18/M84 activity timeout and the M85 max 'kill' timeout + if (parked_or_ignoring) gcode.reset_stepper_timeout(ms); + + if (gcode.stepper_max_timed_out(ms)) { SERIAL_ERROR_START(); SERIAL_ECHOLNPAIR(STR_KILL_INACTIVE_TIME, parser.command_ptr); kill(); } - // Prevent steppers timing-out in the middle of M600 - #define STAY_TEST (BOTH(ADVANCED_PAUSE_FEATURE, PAUSE_PARK_NO_STEPPER_TIMEOUT) && did_pause_print) + // M18 / M94 : Handle steppers inactive time timeout + if (gcode.stepper_inactive_time) { - if (stepper_inactive_time) { static bool already_shutdown_steppers; // = false + + // Any moves in the planner? Resets both the M18/M84 + // activity timeout and the M85 max 'kill' timeout if (planner.has_blocks_queued()) - gcode.reset_stepper_timeout(); - else if (!STAY_TEST && !ignore_stepper_queue && ELAPSED(ms, gcode.previous_move_ms + stepper_inactive_time)) { + gcode.reset_stepper_timeout(ms); + else if (!parked_or_ignoring && gcode.stepper_inactive_timeout()) { if (!already_shutdown_steppers) { already_shutdown_steppers = true; // L6470 SPI will consume 99% of free time without this + + // Individual axes will be disabled if configured if (ENABLED(DISABLE_INACTIVE_X)) DISABLE_AXIS_X(); if (ENABLED(DISABLE_INACTIVE_Y)) DISABLE_AXIS_Y(); if (ENABLED(DISABLE_INACTIVE_Z)) DISABLE_AXIS_Z(); if (ENABLED(DISABLE_INACTIVE_E)) disable_e_steppers(); + #if BOTH(HAS_LCD_MENU, AUTO_BED_LEVELING_UBL) if (ubl.lcd_map_control) { ubl.lcd_map_control = false; @@ -601,7 +610,7 @@ inline void manage_inactivity(const bool ignore_stepper_queue=false) { } #endif // !SWITCHING_EXTRUDER - gcode.reset_stepper_timeout(); + gcode.reset_stepper_timeout(ms); } #endif // EXTRUDER_RUNOUT_PREVENT diff --git a/Marlin/src/MarlinCore.h b/Marlin/src/MarlinCore.h index 1ed897483572..18b679aca136 100644 --- a/Marlin/src/MarlinCore.h +++ b/Marlin/src/MarlinCore.h @@ -87,9 +87,6 @@ extern bool wait_for_heatup; void wait_for_user_response(millis_t ms=0, const bool no_sleep=false); #endif -// Inactivity shutdown timer -extern millis_t max_inactive_time, stepper_inactive_time; - #if ENABLED(PSU_CONTROL) extern bool powersupply_on; #define PSU_PIN_ON() do{ OUT_WRITE(PS_ON_PIN, PSU_ACTIVE_HIGH); powersupply_on = true; }while(0) diff --git a/Marlin/src/feature/bedlevel/ubl/ubl.cpp b/Marlin/src/feature/bedlevel/ubl/ubl.cpp index 8d382e827327..e08debf1d34b 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl.cpp @@ -206,7 +206,7 @@ if (human) SERIAL_CHAR(is_current ? ']' : ' '); SERIAL_FLUSHTX(); - idle(); + idle_no_sleep(); } if (!lcd) SERIAL_EOL(); diff --git a/Marlin/src/gcode/bedlevel/abl/G29.cpp b/Marlin/src/gcode/bedlevel/abl/G29.cpp index 01871ec7e662..99f07bc19b3e 100644 --- a/Marlin/src/gcode/bedlevel/abl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/abl/G29.cpp @@ -164,6 +164,8 @@ */ G29_TYPE GcodeSuite::G29() { + reset_stepper_timeout(); + const bool seenQ = EITHER(DEBUG_LEVELING_FEATURE, PROBE_MANUALLY) && parser.seen('Q'); // G29 Q is also available if debugging @@ -675,7 +677,7 @@ G29_TYPE GcodeSuite::G29() { #endif abl_should_enable = false; - idle(); + idle_no_sleep(); } // inner } // outer diff --git a/Marlin/src/gcode/calibrate/G28.cpp b/Marlin/src/gcode/calibrate/G28.cpp index 982c9e9d3cab..806a8d50d678 100644 --- a/Marlin/src/gcode/calibrate/G28.cpp +++ b/Marlin/src/gcode/calibrate/G28.cpp @@ -203,15 +203,15 @@ */ void GcodeSuite::G28() { -#if ENABLED(LASER_MOVE_G28_OFF) - cutter.set_inline_enabled(false); // turn off laser -#endif - if (DEBUGGING(LEVELING)) { DEBUG_ECHOLNPGM(">>> G28"); log_machine_info(); } + #if ENABLED(LASER_MOVE_G28_OFF) + cutter.set_inline_enabled(false); // turn off laser + #endif + TERN_(DWIN_CREALITY_LCD, HMI_flag.home_flag = true); #if ENABLED(DUAL_X_CARRIAGE) @@ -251,6 +251,9 @@ void GcodeSuite::G28() { TERN_(CNC_WORKSPACE_PLANES, workspace_plane = PLANE_XY); + // Count this command as movement / activity + reset_stepper_timeout(); + #define HAS_CURRENT_HOME(N) (defined(N##_CURRENT_HOME) && N##_CURRENT_HOME != N##_CURRENT) #if HAS_CURRENT_HOME(X) || HAS_CURRENT_HOME(X2) || HAS_CURRENT_HOME(Y) || HAS_CURRENT_HOME(Y2) #define HAS_HOMING_CURRENT 1 diff --git a/Marlin/src/gcode/config/M301.cpp b/Marlin/src/gcode/config/M301.cpp index 54d32c865074..a68b64e0583f 100644 --- a/Marlin/src/gcode/config/M301.cpp +++ b/Marlin/src/gcode/config/M301.cpp @@ -30,6 +30,8 @@ /** * M301: Set PID parameters P I D (and optionally C, L) * + * E[extruder] Default: 0 + * * P[float] Kp term * I[float] Ki term (unscaled) * D[float] Kd term (unscaled) @@ -65,6 +67,7 @@ void GcodeSuite::M301() { #endif thermalManager.updatePID(); + SERIAL_ECHO_START(); #if ENABLED(PID_PARAMS_PER_HOTEND) SERIAL_ECHOPAIR(" e:", e); // specify extruder in serial output diff --git a/Marlin/src/gcode/control/M17_M18_M84.cpp b/Marlin/src/gcode/control/M17_M18_M84.cpp index aee7d616a139..55a219917c7d 100644 --- a/Marlin/src/gcode/control/M17_M18_M84.cpp +++ b/Marlin/src/gcode/control/M17_M18_M84.cpp @@ -50,6 +50,7 @@ void GcodeSuite::M17() { */ void GcodeSuite::M18_M84() { if (parser.seenval('S')) { + reset_stepper_timeout(); stepper_inactive_time = parser.value_millis_from_seconds(); } else { diff --git a/Marlin/src/gcode/control/M85.cpp b/Marlin/src/gcode/control/M85.cpp index 1cdf49f6096c..224defed738a 100644 --- a/Marlin/src/gcode/control/M85.cpp +++ b/Marlin/src/gcode/control/M85.cpp @@ -21,7 +21,6 @@ */ #include "../gcode.h" -#include "../../MarlinCore.h" // for max_inactive_time /** * M85: Set inactivity shutdown timer with parameter S. To disable set zero (default) diff --git a/Marlin/src/gcode/control/T.cpp b/Marlin/src/gcode/control/T.cpp index e6b3bb5d6817..872b3d548801 100644 --- a/Marlin/src/gcode/control/T.cpp +++ b/Marlin/src/gcode/control/T.cpp @@ -53,6 +53,9 @@ void GcodeSuite::T(const uint8_t tool_index) { DEBUG_POS("BEFORE", current_position); } + // Count this command as movement / activity + reset_stepper_timeout(); + #if ENABLED(PRUSA_MMU2) if (parser.string_arg) { mmu2.tool_change(parser.string_arg); // Special commands T?/Tx/Tc diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index d34e0665c6e5..0b0a29cc2039 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -59,7 +59,10 @@ GcodeSuite gcode; #include "../MarlinCore.h" // for idle() -millis_t GcodeSuite::previous_move_ms; +// Inactivity shutdown +millis_t GcodeSuite::previous_move_ms = 0, + GcodeSuite::max_inactive_time = 0, + GcodeSuite::stepper_inactive_time = SEC_TO_MS(DEFAULT_STEPPER_DEACTIVE_TIME); // Relative motion mode for each logical axis static constexpr xyze_bool_t ar_init = AXIS_RELATIVE_MODES; diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index ab17cc8d7df3..72ae1f92df85 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -334,8 +334,14 @@ class GcodeSuite { static bool select_coordinate_system(const int8_t _new); #endif - static millis_t previous_move_ms; - FORCE_INLINE static void reset_stepper_timeout() { previous_move_ms = millis(); } + static millis_t previous_move_ms, max_inactive_time, stepper_inactive_time; + FORCE_INLINE static void reset_stepper_timeout(const millis_t ms=millis()) { previous_move_ms = ms; } + FORCE_INLINE static bool stepper_max_timed_out(const millis_t ms=millis()) { + return max_inactive_time && ELAPSED(ms, previous_move_ms + max_inactive_time); + } + FORCE_INLINE static bool stepper_inactive_timeout(const millis_t ms=millis()) { + return ELAPSED(ms, previous_move_ms + stepper_inactive_time); + } static int8_t get_target_extruder_from_command(); static int8_t get_target_e_stepper_from_command(); diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index 71b5d7a89aa4..639c5765afb1 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -477,6 +477,8 @@ #define HAS_MULTI_HOTEND 1 #define HAS_HOTEND_OFFSET 1 #endif +#else + #undef PID_PARAMS_PER_HOTEND #endif // Helper macros for extruder and hotend arrays diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index d99330916176..87caa23a8067 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -1629,28 +1629,8 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal #endif /** - * Test Heater, Temp Sensor, and Extruder Pins; Sensor Type must also be set. + * A Sensor ID has to be set for each heater */ -#if !HAS_HEATER_0 - #error "HEATER_0_PIN not defined for this board." -#elif !ANY_PIN(TEMP_0, MAX6675_SS) - #error "TEMP_0_PIN not defined for this board." -#elif ((defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__)) && !PINS_EXIST(E0_STEP, E0_DIR)) - #error "E0_STEP_PIN or E0_DIR_PIN not defined for this board." -#elif ( !(defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__)) && (!PINS_EXIST(E0_STEP, E0_DIR) || !HAS_E0_ENABLE)) - #error "E0_STEP_PIN, E0_DIR_PIN, or E0_ENABLE_PIN not defined for this board." -#elif EXTRUDERS && TEMP_SENSOR_0 == 0 - #error "TEMP_SENSOR_0 is required with any extruders." -#endif - -// Pins are required for heaters -#if ENABLED(HEATER_0_USES_MAX6675) && !PIN_EXISTS(MAX6675_SS) - #error "MAX6675_SS_PIN (required for TEMP_SENSOR_0) not defined for this board." -#elif HAS_HOTEND && !HAS_TEMP_HOTEND - #error "TEMP_0_PIN (required for TEMP_SENSOR_0) not defined for this board." -#elif EITHER(HAS_MULTI_HOTEND, HEATERS_PARALLEL) && !HAS_HEATER_1 - #error "HEATER_1_PIN not defined for this board." -#endif #if HAS_MULTI_HOTEND #if ENABLED(HEATER_1_USES_MAX6675) && !PIN_EXISTS(MAX6675_SS2) @@ -1792,6 +1772,30 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal #error "TEMP_SENSOR_1 is required with TEMP_SENSOR_1_AS_REDUNDANT." #endif +/** + * Test Heater, Temp Sensor, and Extruder Pins + */ +#if !HAS_HEATER_0 + #error "HEATER_0_PIN not defined for this board." +#elif !ANY_PIN(TEMP_0, MAX6675_SS) + #error "TEMP_0_PIN not defined for this board." +#elif ((defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__)) && !PINS_EXIST(E0_STEP, E0_DIR)) + #error "E0_STEP_PIN or E0_DIR_PIN not defined for this board." +#elif ( !(defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__)) && (!PINS_EXIST(E0_STEP, E0_DIR) || !HAS_E0_ENABLE)) + #error "E0_STEP_PIN, E0_DIR_PIN, or E0_ENABLE_PIN not defined for this board." +#elif EXTRUDERS && TEMP_SENSOR_0 == 0 + #error "TEMP_SENSOR_0 is required if there are any extruders." +#endif + +// Pins are required for heaters +#if ENABLED(HEATER_0_USES_MAX6675) && !PIN_EXISTS(MAX6675_SS) + #error "MAX6675_SS_PIN (required for TEMP_SENSOR_0) not defined for this board." +#elif HAS_HOTEND && !HAS_TEMP_HOTEND + #error "TEMP_0_PIN (required for TEMP_SENSOR_0) not defined for this board." +#elif EITHER(HAS_MULTI_HOTEND, HEATERS_PARALLEL) && !HAS_HEATER_1 + #error "HEATER_1_PIN is not defined. TEMP_SENSOR_1 might not be set, or the board (not EEB / EEF?) doesn't define a pin." +#endif + /** * Temperature status LEDs */ diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index f3fea10e0aac..f8d83c393437 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2020-07-01" + #define STRING_DISTRIBUTION_DATE "2020-07-02" #endif /** diff --git a/Marlin/src/lcd/menu/menu_advanced.cpp b/Marlin/src/lcd/menu/menu_advanced.cpp index b57e442b6fba..d53a4d2495f5 100644 --- a/Marlin/src/lcd/menu/menu_advanced.cpp +++ b/Marlin/src/lcd/menu/menu_advanced.cpp @@ -205,16 +205,12 @@ void menu_cancelobject(); // Helpers for editing PID Ki & Kd values // grab the PID value out of the temp variable; scale it; then update the PID driver void copy_and_scalePID_i(int16_t e) { - #if DISABLED(PID_PARAMS_PER_HOTEND) || HOTENDS == 1 - UNUSED(e); - #endif + TERN(PID_PARAMS_PER_HOTEND,,UNUSED(e)); PID_PARAM(Ki, e) = scalePID_i(raw_Ki); thermalManager.updatePID(); } void copy_and_scalePID_d(int16_t e) { - #if DISABLED(PID_PARAMS_PER_HOTEND) || HOTENDS == 1 - UNUSED(e); - #endif + TERN(PID_PARAMS_PER_HOTEND,,UNUSED(e)); PID_PARAM(Kd, e) = scalePID_d(raw_Kd); thermalManager.updatePID(); } @@ -239,7 +235,7 @@ void menu_cancelobject(); #if HAS_HOTEND DEFINE_PIDTEMP_FUNCS(0); - #if BOTH(HAS_MULTI_HOTEND, PID_PARAMS_PER_HOTEND) + #if ENABLED(PID_PARAMS_PER_HOTEND) REPEAT_S(1, HOTENDS, DEFINE_PIDTEMP_FUNCS) #endif #endif @@ -314,7 +310,7 @@ void menu_cancelobject(); #endif PID_EDIT_MENU_ITEMS(0); - #if BOTH(HAS_MULTI_HOTEND, PID_PARAMS_PER_HOTEND) + #if ENABLED(PID_PARAMS_PER_HOTEND) REPEAT_S(1, HOTENDS, PID_EDIT_MENU_ITEMS) #endif diff --git a/Marlin/src/module/configuration_store.cpp b/Marlin/src/module/configuration_store.cpp index 41ce618a0432..8ff873111413 100644 --- a/Marlin/src/module/configuration_store.cpp +++ b/Marlin/src/module/configuration_store.cpp @@ -2587,12 +2587,59 @@ void MarlinSettings::reset() { // #if ENABLED(PIDTEMP) + #if ENABLED(PID_PARAMS_PER_HOTEND) + constexpr float defKp[] = + #ifdef DEFAULT_Kp_LIST + DEFAULT_Kp_LIST + #else + ARRAY_BY_HOTENDS1(DEFAULT_Kp) + #endif + , defKi[] = + #ifdef DEFAULT_Ki_LIST + DEFAULT_Ki_LIST + #else + ARRAY_BY_HOTENDS1(DEFAULT_Ki) + #endif + , defKd[] = + #ifdef DEFAULT_Kd_LIST + DEFAULT_Kd_LIST + #else + ARRAY_BY_HOTENDS1(DEFAULT_Kd) + #endif + ; + static_assert(WITHIN(COUNT(defKp), 1, HOTENDS), "DEFAULT_Kp_LIST must have between 1 and HOTENDS items."); + static_assert(WITHIN(COUNT(defKi), 1, HOTENDS), "DEFAULT_Ki_LIST must have between 1 and HOTENDS items."); + static_assert(WITHIN(COUNT(defKd), 1, HOTENDS), "DEFAULT_Kd_LIST must have between 1 and HOTENDS items."); + #if ENABLED(PID_EXTRUSION_SCALING) + constexpr float defKc[] = + #ifdef DEFAULT_Kc_LIST + DEFAULT_Kc_LIST + #else + ARRAY_BY_HOTENDS1(DEFAULT_Kc) + #endif + ; + static_assert(WITHIN(COUNT(defKc), 1, HOTENDS), "DEFAULT_Kc_LIST must have between 1 and HOTENDS items."); + #endif + #if ENABLED(PID_FAN_SCALING) + constexpr float defKf[] = + #ifdef DEFAULT_Kf_LIST + DEFAULT_Kf_LIST + #else + ARRAY_BY_HOTENDS1(DEFAULT_Kf) + #endif + ; + static_assert(WITHIN(COUNT(defKf), 1, HOTENDS), "DEFAULT_Kf_LIST must have between 1 and HOTENDS items."); + #endif + #define PID_DEFAULT(N,E) def##N[E] + #else + #define PID_DEFAULT(N,E) DEFAULT_##N + #endif HOTEND_LOOP() { - PID_PARAM(Kp, e) = float(DEFAULT_Kp); - PID_PARAM(Ki, e) = scalePID_i(DEFAULT_Ki); - PID_PARAM(Kd, e) = scalePID_d(DEFAULT_Kd); - TERN_(PID_EXTRUSION_SCALING, PID_PARAM(Kc, e) = DEFAULT_Kc); - TERN_(PID_FAN_SCALING, PID_PARAM(Kf, e) = DEFAULT_Kf); + PID_PARAM(Kp, e) = float(PID_DEFAULT(Kp, ALIM(e, defKp))); + PID_PARAM(Ki, e) = scalePID_i(PID_DEFAULT(Ki, ALIM(e, defKi))); + PID_PARAM(Kd, e) = scalePID_d(PID_DEFAULT(Kd, ALIM(e, defKd))); + TERN_(PID_EXTRUSION_SCALING, PID_PARAM(Kc, e) = float(PID_DEFAULT(Kc, ALIM(e, defKc)))); + TERN_(PID_FAN_SCALING, PID_PARAM(Kf, e) = float(PID_DEFAULT(Kf, ALIM(e, defKf)))); } #endif @@ -3140,7 +3187,7 @@ void MarlinSettings::reset() { HOTEND_LOOP() { CONFIG_ECHO_START(); SERIAL_ECHOPAIR_P( - #if BOTH(HAS_MULTI_HOTEND, PID_PARAMS_PER_HOTEND) + #if ENABLED(PID_PARAMS_PER_HOTEND) PSTR(" M301 E"), e, SP_P_STR #else diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index b95fdbdd86c7..1ca988e5d7fb 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -110,12 +110,12 @@ #if HOTEND_USES_THERMISTOR #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) - static const void* heater_ttbl_map[2] = { (void*)HEATER_0_TEMPTABLE, (void*)HEATER_1_TEMPTABLE }; + static const temp_entry_t* heater_ttbl_map[2] = { HEATER_0_TEMPTABLE, HEATER_1_TEMPTABLE }; static constexpr uint8_t heater_ttbllen_map[2] = { HEATER_0_TEMPTABLE_LEN, HEATER_1_TEMPTABLE_LEN }; #else #define NEXT_TEMPTABLE(N) ,HEATER_##N##_TEMPTABLE #define NEXT_TEMPTABLE_LEN(N) ,HEATER_##N##_TEMPTABLE_LEN - static const void* heater_ttbl_map[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_TEMPTABLE REPEAT_S(1, HOTENDS, NEXT_TEMPTABLE)); + static const temp_entry_t* heater_ttbl_map[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_TEMPTABLE REPEAT_S(1, HOTENDS, NEXT_TEMPTABLE)); static constexpr uint8_t heater_ttbllen_map[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_TEMPTABLE_LEN REPEAT_S(1, HOTENDS, NEXT_TEMPTABLE_LEN)); #endif #endif @@ -900,11 +900,13 @@ void Temperature::min_temp_error(const heater_ind_t heater) { SERIAL_ECHO_START(); SERIAL_ECHOPAIR(STR_PID_DEBUG, ee, STR_PID_DEBUG_INPUT, temp_hotend[ee].celsius, STR_PID_DEBUG_OUTPUT, pid_output); #if DISABLED(PID_OPENLOOP) + { SERIAL_ECHOPAIR( STR_PID_DEBUG_PTERM, work_pid[ee].Kp, STR_PID_DEBUG_ITERM, work_pid[ee].Ki, STR_PID_DEBUG_DTERM, work_pid[ee].Kd #if ENABLED(PID_EXTRUSION_SCALING) , STR_PID_DEBUG_CTERM, work_pid[ee].Kc #endif ); + } #endif SERIAL_EOL(); } @@ -920,7 +922,7 @@ void Temperature::min_temp_error(const heater_ind_t heater) { return pid_output; } -#endif // HOTENDS +#endif // HAS_HOTEND #if ENABLED(PIDTEMPBED) @@ -1058,7 +1060,7 @@ void Temperature::manage_heater() { } // HOTEND_LOOP - #endif // HOTENDS + #endif // HAS_HOTEND #if HAS_AUTO_FAN if (ELAPSED(ms, next_auto_fan_check_ms)) { // only need to check fan state very infrequently @@ -1208,22 +1210,22 @@ void Temperature::manage_heater() { * Bisect search for the range of the 'raw' value, then interpolate * proportionally between the under and over values. */ -#define SCAN_THERMISTOR_TABLE(TBL,LEN) do{ \ - uint8_t l = 0, r = LEN, m; \ - for (;;) { \ - m = (l + r) >> 1; \ - if (!m) return short(pgm_read_word(&TBL[0][1])); \ - if (m == l || m == r) return short(pgm_read_word(&TBL[LEN-1][1])); \ - short v00 = pgm_read_word(&TBL[m-1][0]), \ - v10 = pgm_read_word(&TBL[m-0][0]); \ - if (raw < v00) r = m; \ - else if (raw > v10) l = m; \ - else { \ - const short v01 = short(pgm_read_word(&TBL[m-1][1])), \ - v11 = short(pgm_read_word(&TBL[m-0][1])); \ - return v01 + (raw - v00) * float(v11 - v01) / float(v10 - v00); \ - } \ - } \ +#define SCAN_THERMISTOR_TABLE(TBL,LEN) do{ \ + uint8_t l = 0, r = LEN, m; \ + for (;;) { \ + m = (l + r) >> 1; \ + if (!m) return int16_t(pgm_read_word(&TBL[0].celsius)); \ + if (m == l || m == r) return int16_t(pgm_read_word(&TBL[LEN-1].celsius)); \ + int16_t v00 = pgm_read_word(&TBL[m-1].value), \ + v10 = pgm_read_word(&TBL[m-0].value); \ + if (raw < v00) r = m; \ + else if (raw > v10) l = m; \ + else { \ + const int16_t v01 = int16_t(pgm_read_word(&TBL[m-1].celsius)), \ + v11 = int16_t(pgm_read_word(&TBL[m-0].celsius)); \ + return v01 + (raw - v00) * float(v11 - v01) / float(v10 - v00); \ + } \ + } \ }while(0) #if HAS_USER_THERMISTORS @@ -1452,13 +1454,13 @@ void Temperature::manage_heater() { #if HOTEND_USES_THERMISTOR // Thermistor with conversion table? - const short(*tt)[][2] = (short(*)[][2])(heater_ttbl_map[e]); + const temp_entry_t(*tt)[] = (temp_entry_t(*)[])(heater_ttbl_map[e]); SCAN_THERMISTOR_TABLE((*tt), heater_ttbllen_map[e]); #endif return 0; } -#endif // HOTENDS +#endif // HAS_HOTEND #if HAS_HEATED_BED // Derived from RepRap FiveD extruder::getTemperature() @@ -1790,80 +1792,91 @@ void Temperature::init() { #if HAS_HOTEND #define _TEMP_MIN_E(NR) do{ \ - temp_range[NR].mintemp = HEATER_ ##NR## _MINTEMP; \ - while (analog_to_celsius_hotend(temp_range[NR].raw_min, NR) < HEATER_ ##NR## _MINTEMP) \ + const int16_t tmin = _MAX(HEATER_ ##NR## _MINTEMP, (int16_t)pgm_read_word(&HEATER_ ##NR## _TEMPTABLE[HEATER_ ##NR## _SENSOR_MINTEMP_IND].celsius)); \ + temp_range[NR].mintemp = tmin; \ + while (analog_to_celsius_hotend(temp_range[NR].raw_min, NR) < tmin) \ temp_range[NR].raw_min += TEMPDIR(NR) * (OVERSAMPLENR); \ }while(0) #define _TEMP_MAX_E(NR) do{ \ - temp_range[NR].maxtemp = HEATER_ ##NR## _MAXTEMP; \ - while (analog_to_celsius_hotend(temp_range[NR].raw_max, NR) > HEATER_ ##NR## _MAXTEMP) \ + const int16_t tmax = _MIN(HEATER_ ##NR## _MAXTEMP, (int16_t)pgm_read_word(&HEATER_ ##NR## _TEMPTABLE[HEATER_ ##NR## _SENSOR_MAXTEMP_IND].celsius) - 1); \ + temp_range[NR].maxtemp = tmax; \ + while (analog_to_celsius_hotend(temp_range[NR].raw_max, NR) > tmax) \ temp_range[NR].raw_max -= TEMPDIR(NR) * (OVERSAMPLENR); \ }while(0) - #ifdef HEATER_0_MINTEMP + #if THERMISTOR_HEATER_0 + #ifdef HEATER_0_MINTEMP _TEMP_MIN_E(0); + #endif + #ifdef HEATER_0_MAXTEMP + _TEMP_MAX_E(0); + #endif #endif - #ifdef HEATER_0_MAXTEMP - _TEMP_MAX_E(0); - #endif - #if HAS_MULTI_HOTEND + + #if HAS_MULTI_HOTEND && THERMISTOR_HEATER_1 #ifdef HEATER_1_MINTEMP _TEMP_MIN_E(1); #endif #ifdef HEATER_1_MAXTEMP _TEMP_MAX_E(1); #endif - #if HOTENDS > 2 - #ifdef HEATER_2_MINTEMP - _TEMP_MIN_E(2); - #endif - #ifdef HEATER_2_MAXTEMP - _TEMP_MAX_E(2); - #endif - #if HOTENDS > 3 - #ifdef HEATER_3_MINTEMP - _TEMP_MIN_E(3); - #endif - #ifdef HEATER_3_MAXTEMP - _TEMP_MAX_E(3); - #endif - #if HOTENDS > 4 - #ifdef HEATER_4_MINTEMP - _TEMP_MIN_E(4); - #endif - #ifdef HEATER_4_MAXTEMP - _TEMP_MAX_E(4); - #endif - #if HOTENDS > 5 - #ifdef HEATER_5_MINTEMP - _TEMP_MIN_E(5); - #endif - #ifdef HEATER_5_MAXTEMP - _TEMP_MAX_E(5); - #endif - #if HOTENDS > 6 - #ifdef HEATER_6_MINTEMP - _TEMP_MIN_E(6); - #endif - #ifdef HEATER_6_MAXTEMP - _TEMP_MAX_E(6); - #endif - #if HOTENDS > 7 - #ifdef HEATER_7_MINTEMP - _TEMP_MIN_E(7); - #endif - #ifdef HEATER_7_MAXTEMP - _TEMP_MAX_E(7); - #endif - #endif // HOTENDS > 7 - #endif // HOTENDS > 6 - #endif // HOTENDS > 5 - #endif // HOTENDS > 4 - #endif // HOTENDS > 3 - #endif // HOTENDS > 2 - #endif // HAS_MULTI_HOTEND - - #endif // HOTENDS + #endif + + #if HOTENDS > 2 && THERMISTOR_HEATER_2 + #ifdef HEATER_2_MINTEMP + _TEMP_MIN_E(2); + #endif + #ifdef HEATER_2_MAXTEMP + _TEMP_MAX_E(2); + #endif + #endif + + #if HOTENDS > 3 && THERMISTOR_HEATER_3 + #ifdef HEATER_3_MINTEMP + _TEMP_MIN_E(3); + #endif + #ifdef HEATER_3_MAXTEMP + _TEMP_MAX_E(3); + #endif + #endif + + #if HOTENDS > 4 && THERMISTOR_HEATER_4 + #ifdef HEATER_4_MINTEMP + _TEMP_MIN_E(4); + #endif + #ifdef HEATER_4_MAXTEMP + _TEMP_MAX_E(4); + #endif + #endif + + #if HOTENDS > 5 && THERMISTOR_HEATER_5 + #ifdef HEATER_5_MINTEMP + _TEMP_MIN_E(5); + #endif + #ifdef HEATER_5_MAXTEMP + _TEMP_MAX_E(5); + #endif + #endif + + #if HOTENDS > 6 && THERMISTOR_HEATER_6 + #ifdef HEATER_6_MINTEMP + _TEMP_MIN_E(6); + #endif + #ifdef HEATER_6_MAXTEMP + _TEMP_MAX_E(6); + #endif + #endif + + #if HOTENDS > 7 && THERMISTOR_HEATER_7 + #ifdef HEATER_7_MINTEMP + _TEMP_MIN_E(7); + #endif + #ifdef HEATER_7_MAXTEMP + _TEMP_MAX_E(7); + #endif + #endif + + #endif // HAS_HOTEND #if HAS_HEATED_BED #ifdef BED_MINTEMP @@ -2319,7 +2332,7 @@ void Temperature::readings_ready() { } } - #endif // HOTENDS + #endif // HAS_HOTEND #if HAS_HEATED_BED #if TEMPDIR(BED) < 0 @@ -2573,6 +2586,10 @@ void Temperature::tick() { _SLOW_PWM(BED, soft_pwm_bed, temp_bed); #endif + #if HAS_HEATED_CHAMBER + _SLOW_PWM(CHAMBER, soft_pwm_chamber, temp_chamber); + #endif + } // slow_pwm_count == 0 #if HAS_HOTEND @@ -2584,6 +2601,10 @@ void Temperature::tick() { _PWM_OFF(BED, soft_pwm_bed); #endif + #if HAS_HEATED_CHAMBER + _PWM_OFF(CHAMBER, soft_pwm_chamber); + #endif + #if ENABLED(FAN_SOFT_PWM) if (pwm_count_tmp >= 127) { pwm_count_tmp = 0; @@ -2662,6 +2683,7 @@ void Temperature::tick() { HOTEND_LOOP() soft_pwm_hotend[e].dec(); #endif TERN_(HAS_HEATED_BED, soft_pwm_bed.dec()); + TERN_(HAS_HEATED_CHAMBER, soft_pwm_chamber.dec()); } #endif // SLOW_PWM_HEATERS diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index a6d702646dae..2f8ddbf7be22 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -37,13 +37,8 @@ #define SOFT_PWM_SCALE 0 #endif -#if HOTENDS <= 1 - #define HOTEND_INDEX 0 - #define E_NAME -#else - #define HOTEND_INDEX e - #define E_NAME e -#endif +#define HOTEND_INDEX TERN(HAS_MULTI_HOTEND, e, 0) +#define E_NAME TERN_(HAS_MULTI_HOTEND, e) // Identifiers for other heaters typedef enum : int8_t { @@ -74,30 +69,18 @@ hotend_pid_t; typedef IF<(LPQ_MAX_LEN > 255), uint16_t, uint8_t>::type lpq_ptr_t; #endif +#define PID_PARAM(F,H) _PID_##F(TERN(PID_PARAMS_PER_HOTEND, H, 0)) +#define _PID_Kp(H) TERN(PIDTEMP, Temperature::temp_hotend[H].pid.Kp, NAN) +#define _PID_Ki(H) TERN(PIDTEMP, Temperature::temp_hotend[H].pid.Ki, NAN) +#define _PID_Kd(H) TERN(PIDTEMP, Temperature::temp_hotend[H].pid.Kd, NAN) #if ENABLED(PIDTEMP) - #define _PID_Kp(H) Temperature::temp_hotend[H].pid.Kp - #define _PID_Ki(H) Temperature::temp_hotend[H].pid.Ki - #define _PID_Kd(H) Temperature::temp_hotend[H].pid.Kd - #if ENABLED(PID_EXTRUSION_SCALING) - #define _PID_Kc(H) Temperature::temp_hotend[H].pid.Kc - #else - #define _PID_Kc(H) 1 - #endif - - #if ENABLED(PID_FAN_SCALING) - #define _PID_Kf(H) Temperature::temp_hotend[H].pid.Kf - #else - #define _PID_Kf(H) 0 - #endif + #define _PID_Kc(H) TERN(PID_EXTRUSION_SCALING, Temperature::temp_hotend[H].pid.Kc, 1) + #define _PID_Kf(H) TERN(PID_FAN_SCALING, Temperature::temp_hotend[H].pid.Kf, 0) #else - #define _PID_Kp(H) NAN - #define _PID_Ki(H) NAN - #define _PID_Kd(H) NAN #define _PID_Kc(H) 1 + #define _PID_Kf(H) 0 #endif -#define PID_PARAM(F,H) _PID_##F(H) - /** * States for ADC reading in the ISR */ @@ -625,7 +608,7 @@ class Temperature { return ABS(degHotend(e) - temp) < (TEMP_HYSTERESIS); } - #endif // HOTENDS + #endif // HAS_HOTEND #if HAS_HEATED_BED diff --git a/Marlin/src/module/thermistor/thermistor_1.h b/Marlin/src/module/thermistor/thermistor_1.h index f3226da4754a..75ec433abc81 100644 --- a/Marlin/src/module/thermistor/thermistor_1.h +++ b/Marlin/src/module/thermistor/thermistor_1.h @@ -22,7 +22,7 @@ #pragma once // R25 = 100 kOhm, beta25 = 4092 K, 4.7 kOhm pull-up, bed thermistor -const short temptable_1[][2] PROGMEM = { +const temp_entry_t temptable_1[] PROGMEM = { { OV( 23), 300 }, { OV( 25), 295 }, { OV( 27), 290 }, diff --git a/Marlin/src/module/thermistor/thermistor_10.h b/Marlin/src/module/thermistor/thermistor_10.h index 9e89eab84a43..991440bce523 100644 --- a/Marlin/src/module/thermistor/thermistor_10.h +++ b/Marlin/src/module/thermistor/thermistor_10.h @@ -22,7 +22,7 @@ #pragma once // R25 = 100 kOhm, beta25 = 3960 K, 4.7 kOhm pull-up, RS thermistor 198-961 -const short temptable_10[][2] PROGMEM = { +const temp_entry_t temptable_10[] PROGMEM = { { OV( 1), 929 }, { OV( 36), 299 }, { OV( 71), 246 }, diff --git a/Marlin/src/module/thermistor/thermistor_1010.h b/Marlin/src/module/thermistor/thermistor_1010.h index 200d9aed56f5..71e830d952fd 100644 --- a/Marlin/src/module/thermistor/thermistor_1010.h +++ b/Marlin/src/module/thermistor/thermistor_1010.h @@ -22,7 +22,7 @@ #pragma once // Pt1000 with 1k0 pullup -const short temptable_1010[][2] PROGMEM = { +const temp_entry_t temptable_1010[] PROGMEM = { PtLine( 0, 1000, 1000), PtLine( 25, 1000, 1000), PtLine( 50, 1000, 1000), diff --git a/Marlin/src/module/thermistor/thermistor_1047.h b/Marlin/src/module/thermistor/thermistor_1047.h index af41a20a10c7..6a82d04be8fe 100644 --- a/Marlin/src/module/thermistor/thermistor_1047.h +++ b/Marlin/src/module/thermistor/thermistor_1047.h @@ -22,7 +22,7 @@ #pragma once // Pt1000 with 4k7 pullup -const short temptable_1047[][2] PROGMEM = { +const temp_entry_t temptable_1047[] PROGMEM = { // only a few values are needed as the curve is very flat PtLine( 0, 1000, 4700), PtLine( 50, 1000, 4700), @@ -30,5 +30,9 @@ const short temptable_1047[][2] PROGMEM = { PtLine(150, 1000, 4700), PtLine(200, 1000, 4700), PtLine(250, 1000, 4700), - PtLine(300, 1000, 4700) + PtLine(300, 1000, 4700), + PtLine(350, 1000, 4700), + PtLine(400, 1000, 4700), + PtLine(450, 1000, 4700), + PtLine(500, 1000, 4700) }; diff --git a/Marlin/src/module/thermistor/thermistor_11.h b/Marlin/src/module/thermistor/thermistor_11.h index 1b2da4a71a8b..339f11d56b48 100644 --- a/Marlin/src/module/thermistor/thermistor_11.h +++ b/Marlin/src/module/thermistor/thermistor_11.h @@ -22,7 +22,7 @@ #pragma once // R25 = 100 kOhm, beta25 = 3950 K, 4.7 kOhm pull-up, QU-BD silicone bed QWG-104F-3950 thermistor -const short temptable_11[][2] PROGMEM = { +const temp_entry_t temptable_11[] PROGMEM = { { OV( 1), 938 }, { OV( 31), 314 }, { OV( 41), 290 }, diff --git a/Marlin/src/module/thermistor/thermistor_110.h b/Marlin/src/module/thermistor/thermistor_110.h index fe8f4fbb8070..32ee08580769 100644 --- a/Marlin/src/module/thermistor/thermistor_110.h +++ b/Marlin/src/module/thermistor/thermistor_110.h @@ -22,7 +22,7 @@ #pragma once // Pt100 with 1k0 pullup -const short temptable_110[][2] PROGMEM = { +const temp_entry_t temptable_110[] PROGMEM = { // only a few values are needed as the curve is very flat PtLine( 0, 100, 1000), PtLine( 50, 100, 1000), diff --git a/Marlin/src/module/thermistor/thermistor_12.h b/Marlin/src/module/thermistor/thermistor_12.h index f9e994a959c2..3b8cda870e74 100644 --- a/Marlin/src/module/thermistor/thermistor_12.h +++ b/Marlin/src/module/thermistor/thermistor_12.h @@ -22,7 +22,7 @@ #pragma once // R25 = 100 kOhm, beta25 = 4700 K, 4.7 kOhm pull-up, (personal calibration for Makibox hot bed) -const short temptable_12[][2] PROGMEM = { +const temp_entry_t temptable_12[] PROGMEM = { { OV( 35), 180 }, // top rating 180C { OV( 211), 140 }, { OV( 233), 135 }, diff --git a/Marlin/src/module/thermistor/thermistor_13.h b/Marlin/src/module/thermistor/thermistor_13.h index 44c5243c1fe2..9bf3e02081d8 100644 --- a/Marlin/src/module/thermistor/thermistor_13.h +++ b/Marlin/src/module/thermistor/thermistor_13.h @@ -22,7 +22,7 @@ #pragma once // R25 = 100 kOhm, beta25 = 4100 K, 4.7 kOhm pull-up, Hisens thermistor -const short temptable_13[][2] PROGMEM = { +const temp_entry_t temptable_13[] PROGMEM = { { OV( 20.04), 300 }, { OV( 23.19), 290 }, { OV( 26.71), 280 }, diff --git a/Marlin/src/module/thermistor/thermistor_147.h b/Marlin/src/module/thermistor/thermistor_147.h index 8fead6c42991..61a82affa74b 100644 --- a/Marlin/src/module/thermistor/thermistor_147.h +++ b/Marlin/src/module/thermistor/thermistor_147.h @@ -22,7 +22,7 @@ #pragma once // Pt100 with 4k7 pullup -const short temptable_147[][2] PROGMEM = { +const temp_entry_t temptable_147[] PROGMEM = { // only a few values are needed as the curve is very flat PtLine( 0, 100, 4700), PtLine( 50, 100, 4700), diff --git a/Marlin/src/module/thermistor/thermistor_15.h b/Marlin/src/module/thermistor/thermistor_15.h index 85602abb3a9c..04d022101080 100644 --- a/Marlin/src/module/thermistor/thermistor_15.h +++ b/Marlin/src/module/thermistor/thermistor_15.h @@ -22,7 +22,7 @@ #pragma once // 100k bed thermistor in JGAurora A5. Calibrated by Sam Pinches 21st Jan 2018 using cheap k-type thermocouple inserted into heater block, using TM-902C meter. -const short temptable_15[][2] PROGMEM = { +const temp_entry_t temptable_15[] PROGMEM = { { OV( 31), 275 }, { OV( 33), 270 }, { OV( 35), 260 }, diff --git a/Marlin/src/module/thermistor/thermistor_18.h b/Marlin/src/module/thermistor/thermistor_18.h index f6a3edec4974..0f12d6996ae4 100644 --- a/Marlin/src/module/thermistor/thermistor_18.h +++ b/Marlin/src/module/thermistor/thermistor_18.h @@ -22,7 +22,7 @@ #pragma once // ATC Semitec 204GT-2 (4.7k pullup) Dagoma.Fr - MKS_Base_DKU001327 - version (measured/tested/approved) -const short temptable_18[][2] PROGMEM = { +const temp_entry_t temptable_18[] PROGMEM = { { OV( 1), 713 }, { OV( 17), 284 }, { OV( 20), 275 }, diff --git a/Marlin/src/module/thermistor/thermistor_2.h b/Marlin/src/module/thermistor/thermistor_2.h index f3fe470603c9..ec296ec670af 100644 --- a/Marlin/src/module/thermistor/thermistor_2.h +++ b/Marlin/src/module/thermistor/thermistor_2.h @@ -26,7 +26,7 @@ // Verified by linagee. Source: http://shop.arcol.hu/static/datasheets/thermistors.pdf // Calculated using 4.7kohm pullup, voltage divider math, and manufacturer provided temp/resistance // -const short temptable_2[][2] PROGMEM = { +const temp_entry_t temptable_2[] PROGMEM = { { OV( 1), 848 }, { OV( 30), 300 }, // top rating 300C { OV( 34), 290 }, diff --git a/Marlin/src/module/thermistor/thermistor_20.h b/Marlin/src/module/thermistor/thermistor_20.h index 49b212da50b0..a2d3c7a61833 100644 --- a/Marlin/src/module/thermistor/thermistor_20.h +++ b/Marlin/src/module/thermistor/thermistor_20.h @@ -21,10 +21,10 @@ */ #pragma once -#define REVERSE_TEMP_SENSOR_RANGE +#define REVERSE_TEMP_SENSOR_RANGE_20 1 // Pt100 with INA826 amp on Ultimaker v2.0 electronics -const short temptable_20[][2] PROGMEM = { +const temp_entry_t temptable_20[] PROGMEM = { { OV( 0), 0 }, { OV(227), 1 }, { OV(236), 10 }, diff --git a/Marlin/src/module/thermistor/thermistor_201.h b/Marlin/src/module/thermistor/thermistor_201.h index d92f95756175..1ddd259172de 100644 --- a/Marlin/src/module/thermistor/thermistor_201.h +++ b/Marlin/src/module/thermistor/thermistor_201.h @@ -21,10 +21,10 @@ */ #pragma once -#define REVERSE_TEMP_SENSOR_RANGE +#define REVERSE_TEMP_SENSOR_RANGE_201 1 // Pt100 with LMV324 amp on Overlord v1.1 electronics -const short temptable_201[][2] PROGMEM = { +const temp_entry_t temptable_201[] PROGMEM = { { OV( 0), 0 }, { OV( 8), 1 }, { OV( 23), 6 }, diff --git a/Marlin/src/module/thermistor/thermistor_202.h b/Marlin/src/module/thermistor/thermistor_202.h index 9da3d45f454c..c5229607ae33 100644 --- a/Marlin/src/module/thermistor/thermistor_202.h +++ b/Marlin/src/module/thermistor/thermistor_202.h @@ -3,7 +3,7 @@ // Temptable sent from dealer technologyoutlet.co.uk // -const short temptable_202[][2] PROGMEM = { +const temp_entry_t temptable_202[] PROGMEM = { { OV( 1), 864 }, { OV( 35), 300 }, { OV( 38), 295 }, diff --git a/Marlin/src/module/thermistor/thermistor_21.h b/Marlin/src/module/thermistor/thermistor_21.h index 655f56685dac..144692cd12bd 100644 --- a/Marlin/src/module/thermistor/thermistor_21.h +++ b/Marlin/src/module/thermistor/thermistor_21.h @@ -21,13 +21,13 @@ */ #pragma once -#define REVERSE_TEMP_SENSOR_RANGE +#define REVERSE_TEMP_SENSOR_RANGE_21 1 #undef OV_SCALE #define OV_SCALE(N) (float((N) * 5) / 3.3f) // Pt100 with INA826 amp with 3.3v excitation based on "Pt100 with INA826 amp on Ultimaker v2.0 electronics" -const short temptable_21[][2] PROGMEM = { +const temp_entry_t temptable_21[] PROGMEM = { { OV( 0), 0 }, { OV(227), 1 }, { OV(236), 10 }, diff --git a/Marlin/src/module/thermistor/thermistor_22.h b/Marlin/src/module/thermistor/thermistor_22.h index e9b6acbb1e34..dd4d9d9131c8 100644 --- a/Marlin/src/module/thermistor/thermistor_22.h +++ b/Marlin/src/module/thermistor/thermistor_22.h @@ -21,7 +21,7 @@ */ // 100k hotend thermistor with 4.7k pull up to 3.3v and 220R to analog input as in GTM32 Pro vB -const short temptable_22[][2] PROGMEM = { +const temp_entry_t temptable_22[] PROGMEM = { { OV( 1), 352 }, { OV( 6), 341 }, { OV( 11), 330 }, diff --git a/Marlin/src/module/thermistor/thermistor_23.h b/Marlin/src/module/thermistor/thermistor_23.h index 13918c5893cf..eb156f4358de 100644 --- a/Marlin/src/module/thermistor/thermistor_23.h +++ b/Marlin/src/module/thermistor/thermistor_23.h @@ -21,7 +21,7 @@ */ // 100k hotbed thermistor with 4.7k pull up to 3.3v and 220R to analog input as in GTM32 Pro vB -const short temptable_23[][2] PROGMEM = { +const temp_entry_t temptable_23[] PROGMEM = { { OV( 1), 938 }, { OV( 11), 423 }, { OV( 21), 351 }, diff --git a/Marlin/src/module/thermistor/thermistor_3.h b/Marlin/src/module/thermistor/thermistor_3.h index e37c2ace7b8d..1b44218d556d 100644 --- a/Marlin/src/module/thermistor/thermistor_3.h +++ b/Marlin/src/module/thermistor/thermistor_3.h @@ -22,7 +22,7 @@ #pragma once // R25 = 100 kOhm, beta25 = 4120 K, 4.7 kOhm pull-up, mendel-parts -const short temptable_3[][2] PROGMEM = { +const temp_entry_t temptable_3[] PROGMEM = { { OV( 1), 864 }, { OV( 21), 300 }, { OV( 25), 290 }, diff --git a/Marlin/src/module/thermistor/thermistor_331.h b/Marlin/src/module/thermistor/thermistor_331.h index 434492d7e78c..b8d4959a3be0 100644 --- a/Marlin/src/module/thermistor/thermistor_331.h +++ b/Marlin/src/module/thermistor/thermistor_331.h @@ -24,7 +24,7 @@ #define OVM(V) OV((V)*(0.327/0.5)) // R25 = 100 kOhm, beta25 = 4092 K, 4.7 kOhm pull-up, bed thermistor -const short temptable_331[][2] PROGMEM = { +const temp_entry_t temptable_331[] PROGMEM = { { OVM( 23), 300 }, { OVM( 25), 295 }, { OVM( 27), 290 }, diff --git a/Marlin/src/module/thermistor/thermistor_332.h b/Marlin/src/module/thermistor/thermistor_332.h index 3112751b95e4..21c82ca12ebf 100644 --- a/Marlin/src/module/thermistor/thermistor_332.h +++ b/Marlin/src/module/thermistor/thermistor_332.h @@ -24,7 +24,7 @@ #define OVM(V) OV((V)*(0.327/0.327)) // R25 = 100 kOhm, beta25 = 4092 K, 4.7 kOhm pull-up, bed thermistor -const short temptable_332[][2] PROGMEM = { +const temp_entry_t temptable_332[] PROGMEM = { { OVM( 268), 150 }, { OVM( 293), 145 }, { OVM( 320), 141 }, diff --git a/Marlin/src/module/thermistor/thermistor_4.h b/Marlin/src/module/thermistor/thermistor_4.h index 00e0d9ed9755..3cc6da9f25af 100644 --- a/Marlin/src/module/thermistor/thermistor_4.h +++ b/Marlin/src/module/thermistor/thermistor_4.h @@ -22,7 +22,7 @@ #pragma once // R25 = 10 kOhm, beta25 = 3950 K, 4.7 kOhm pull-up, Generic 10k thermistor -const short temptable_4[][2] PROGMEM = { +const temp_entry_t temptable_4[] PROGMEM = { { OV( 1), 430 }, { OV( 54), 137 }, { OV( 107), 107 }, diff --git a/Marlin/src/module/thermistor/thermistor_5.h b/Marlin/src/module/thermistor/thermistor_5.h index 8f414de15e8f..f1a04d2ed206 100644 --- a/Marlin/src/module/thermistor/thermistor_5.h +++ b/Marlin/src/module/thermistor/thermistor_5.h @@ -26,7 +26,7 @@ // ATC Semitec 104GT-2/104NT-4-R025H42G (Used in ParCan) // Verified by linagee. Source: http://shop.arcol.hu/static/datasheets/thermistors.pdf // Calculated using 4.7kohm pullup, voltage divider math, and manufacturer provided temp/resistance -const short temptable_5[][2] PROGMEM = { +const temp_entry_t temptable_5[] PROGMEM = { { OV( 1), 713 }, { OV( 17), 300 }, // top rating 300C { OV( 20), 290 }, diff --git a/Marlin/src/module/thermistor/thermistor_501.h b/Marlin/src/module/thermistor/thermistor_501.h index 3db433644edd..a1ef6e53cbd0 100644 --- a/Marlin/src/module/thermistor/thermistor_501.h +++ b/Marlin/src/module/thermistor/thermistor_501.h @@ -22,7 +22,7 @@ #pragma once // 100k Zonestar thermistor. Adjusted By Hally -const short temptable_501[][2] PROGMEM = { +const temp_entry_t temptable_501[] PROGMEM = { { OV( 1), 713 }, { OV( 14), 300 }, // Top rating 300C { OV( 16), 290 }, diff --git a/Marlin/src/module/thermistor/thermistor_502.h b/Marlin/src/module/thermistor/thermistor_502.h index 1a4019ed5c28..b414e562e6f5 100644 --- a/Marlin/src/module/thermistor/thermistor_502.h +++ b/Marlin/src/module/thermistor/thermistor_502.h @@ -23,7 +23,7 @@ // Unknown thermistor for the Zonestar P802M hot bed. Adjusted By Nerseth // These were the shipped settings from Zonestar in original firmware: P802M_8_Repetier_V1.6_Zonestar.zip -const short temptable_502[][2] PROGMEM = { +const temp_entry_t temptable_502[] PROGMEM = { { OV( 56.0 / 4), 300 }, { OV( 187.0 / 4), 250 }, { OV( 615.0 / 4), 190 }, diff --git a/Marlin/src/module/thermistor/thermistor_51.h b/Marlin/src/module/thermistor/thermistor_51.h index f314777a5285..092bcb640814 100644 --- a/Marlin/src/module/thermistor/thermistor_51.h +++ b/Marlin/src/module/thermistor/thermistor_51.h @@ -26,7 +26,7 @@ // Verified by linagee. // Calculated using 1kohm pullup, voltage divider math, and manufacturer provided temp/resistance // Advantage: Twice the resolution and better linearity from 150C to 200C -const short temptable_51[][2] PROGMEM = { +const temp_entry_t temptable_51[] PROGMEM = { { OV( 1), 350 }, { OV( 190), 250 }, // top rating 250C { OV( 203), 245 }, diff --git a/Marlin/src/module/thermistor/thermistor_512.h b/Marlin/src/module/thermistor/thermistor_512.h index 5528e56b9763..ab59c585163a 100644 --- a/Marlin/src/module/thermistor/thermistor_512.h +++ b/Marlin/src/module/thermistor/thermistor_512.h @@ -22,7 +22,7 @@ // 100k thermistor supplied with RPW-Ultra hotend, 4.7k pullup -const short temptable_512[][2] PROGMEM = { +const temp_entry_t temptable_512[] PROGMEM = { { OV(26), 300 }, { OV(28), 295 }, { OV(30), 290 }, diff --git a/Marlin/src/module/thermistor/thermistor_52.h b/Marlin/src/module/thermistor/thermistor_52.h index 9a54ef4b6f66..031b094d8909 100644 --- a/Marlin/src/module/thermistor/thermistor_52.h +++ b/Marlin/src/module/thermistor/thermistor_52.h @@ -26,7 +26,7 @@ // Verified by linagee. Source: http://shop.arcol.hu/static/datasheets/thermistors.pdf // Calculated using 1kohm pullup, voltage divider math, and manufacturer provided temp/resistance // Advantage: More resolution and better linearity from 150C to 200C -const short temptable_52[][2] PROGMEM = { +const temp_entry_t temptable_52[] PROGMEM = { { OV( 1), 500 }, { OV( 125), 300 }, // top rating 300C { OV( 142), 290 }, diff --git a/Marlin/src/module/thermistor/thermistor_55.h b/Marlin/src/module/thermistor/thermistor_55.h index ead481e8655a..e137f174c773 100644 --- a/Marlin/src/module/thermistor/thermistor_55.h +++ b/Marlin/src/module/thermistor/thermistor_55.h @@ -26,7 +26,7 @@ // Verified by linagee. Source: http://shop.arcol.hu/static/datasheets/thermistors.pdf // Calculated using 1kohm pullup, voltage divider math, and manufacturer provided temp/resistance // Advantage: More resolution and better linearity from 150C to 200C -const short temptable_55[][2] PROGMEM = { +const temp_entry_t temptable_55[] PROGMEM = { { OV( 1), 500 }, { OV( 76), 300 }, { OV( 87), 290 }, diff --git a/Marlin/src/module/thermistor/thermistor_6.h b/Marlin/src/module/thermistor/thermistor_6.h index f84c64413c1f..35aeeabd77e5 100644 --- a/Marlin/src/module/thermistor/thermistor_6.h +++ b/Marlin/src/module/thermistor/thermistor_6.h @@ -22,7 +22,7 @@ #pragma once // R25 = 100 kOhm, beta25 = 4092 K, 8.2 kOhm pull-up, 100k Epcos (?) thermistor -const short temptable_6[][2] PROGMEM = { +const temp_entry_t temptable_6[] PROGMEM = { { OV( 1), 350 }, { OV( 28), 250 }, // top rating 250C { OV( 31), 245 }, diff --git a/Marlin/src/module/thermistor/thermistor_60.h b/Marlin/src/module/thermistor/thermistor_60.h index 167e0edcf88b..3f43740b5e75 100644 --- a/Marlin/src/module/thermistor/thermistor_60.h +++ b/Marlin/src/module/thermistor/thermistor_60.h @@ -31,7 +31,7 @@ // beta: 3950 // min adc: 1 at 0.0048828125 V // max adc: 1023 at 4.9951171875 V -const short temptable_60[][2] PROGMEM = { +const temp_entry_t temptable_60[] PROGMEM = { { OV( 51), 272 }, { OV( 61), 258 }, { OV( 71), 247 }, diff --git a/Marlin/src/module/thermistor/thermistor_61.h b/Marlin/src/module/thermistor/thermistor_61.h index 5f8171a1d4b6..837ee3781a85 100644 --- a/Marlin/src/module/thermistor/thermistor_61.h +++ b/Marlin/src/module/thermistor/thermistor_61.h @@ -30,7 +30,7 @@ // Resistance Tolerance + / -1% // B Value 3950K at 25/50 deg. C // B Value Tolerance + / - 1% -const short temptable_61[][2] PROGMEM = { +const temp_entry_t temptable_61[] PROGMEM = { { OV( 2.00), 420 }, // Guestimate to ensure we dont lose a reading and drop temps to -50 when over { OV( 12.07), 350 }, { OV( 12.79), 345 }, diff --git a/Marlin/src/module/thermistor/thermistor_66.h b/Marlin/src/module/thermistor/thermistor_66.h index 97f082348657..0ab45d64d158 100644 --- a/Marlin/src/module/thermistor/thermistor_66.h +++ b/Marlin/src/module/thermistor/thermistor_66.h @@ -22,7 +22,7 @@ #pragma once // R25 = 2.5 MOhm, beta25 = 4500 K, 4.7 kOhm pull-up, DyzeDesign 500 °C Thermistor -const short temptable_66[][2] PROGMEM = { +const temp_entry_t temptable_66[] PROGMEM = { { OV( 17.5), 850 }, { OV( 17.9), 500 }, { OV( 21.7), 480 }, diff --git a/Marlin/src/module/thermistor/thermistor_67.h b/Marlin/src/module/thermistor/thermistor_67.h index 5af203c8abd2..11fdca856835 100644 --- a/Marlin/src/module/thermistor/thermistor_67.h +++ b/Marlin/src/module/thermistor/thermistor_67.h @@ -22,7 +22,7 @@ #pragma once // R25 = 500 KOhm, beta25 = 3800 K, 4.7 kOhm pull-up, SliceEngineering 450 °C Thermistor -const short temptable_67[][2] PROGMEM = { +const temp_entry_t temptable_67[] PROGMEM = { { OV( 22 ), 500 }, { OV( 23 ), 490 }, { OV( 25 ), 480 }, diff --git a/Marlin/src/module/thermistor/thermistor_7.h b/Marlin/src/module/thermistor/thermistor_7.h index e791d0c33304..1e6ab1d34ae3 100644 --- a/Marlin/src/module/thermistor/thermistor_7.h +++ b/Marlin/src/module/thermistor/thermistor_7.h @@ -22,7 +22,7 @@ #pragma once // R25 = 100 kOhm, beta25 = 3974 K, 4.7 kOhm pull-up, Honeywell 135-104LAG-J01 -const short temptable_7[][2] PROGMEM = { +const temp_entry_t temptable_7[] PROGMEM = { { OV( 1), 941 }, { OV( 19), 362 }, { OV( 37), 299 }, // top rating 300C diff --git a/Marlin/src/module/thermistor/thermistor_70.h b/Marlin/src/module/thermistor/thermistor_70.h index b49804106970..d81424f9b611 100644 --- a/Marlin/src/module/thermistor/thermistor_70.h +++ b/Marlin/src/module/thermistor/thermistor_70.h @@ -26,7 +26,7 @@ // ANENG AN8009 DMM with a K-type probe used for measurements. // R25 = 100 kOhm, beta25 = 4100 K, 4.7 kOhm pull-up, bqh2 stock thermistor -const short temptable_70[][2] PROGMEM = { +const temp_entry_t temptable_70[] PROGMEM = { { OV( 18), 270 }, { OV( 27), 248 }, { OV( 34), 234 }, diff --git a/Marlin/src/module/thermistor/thermistor_71.h b/Marlin/src/module/thermistor/thermistor_71.h index c3a9193b79bb..c7bab2a0bcac 100644 --- a/Marlin/src/module/thermistor/thermistor_71.h +++ b/Marlin/src/module/thermistor/thermistor_71.h @@ -27,7 +27,7 @@ // Beta = 3974 // R1 = 0 Ohm // R2 = 4700 Ohm -const short temptable_71[][2] PROGMEM = { +const temp_entry_t temptable_71[] PROGMEM = { { OV( 35), 300 }, { OV( 51), 269 }, { OV( 59), 258 }, diff --git a/Marlin/src/module/thermistor/thermistor_75.h b/Marlin/src/module/thermistor/thermistor_75.h index 3a3cdc636409..1df64cc420ea 100644 --- a/Marlin/src/module/thermistor/thermistor_75.h +++ b/Marlin/src/module/thermistor/thermistor_75.h @@ -34,7 +34,7 @@ //#define HIGH_TEMP_RANGE_75 -const short temptable_75[][2] PROGMEM = { // Generic Silicon Heat Pad with NTC 100K MGB18-104F39050L32 thermistor +const temp_entry_t temptable_75[] PROGMEM = { // Generic Silicon Heat Pad with NTC 100K MGB18-104F39050L32 thermistor { OV(111.06), 200 }, // v=0.542 r=571.747 res=0.501 degC/count #ifdef HIGH_TEMP_RANGE_75 diff --git a/Marlin/src/module/thermistor/thermistor_8.h b/Marlin/src/module/thermistor/thermistor_8.h index f6e407a730da..ec97df613387 100644 --- a/Marlin/src/module/thermistor/thermistor_8.h +++ b/Marlin/src/module/thermistor/thermistor_8.h @@ -22,7 +22,7 @@ #pragma once // R25 = 100 kOhm, beta25 = 3950 K, 10 kOhm pull-up, NTCS0603E3104FHT -const short temptable_8[][2] PROGMEM = { +const temp_entry_t temptable_8[] PROGMEM = { { OV( 1), 704 }, { OV( 54), 216 }, { OV( 107), 175 }, diff --git a/Marlin/src/module/thermistor/thermistor_9.h b/Marlin/src/module/thermistor/thermistor_9.h index 5023fbe1d01a..e194df57c1ff 100644 --- a/Marlin/src/module/thermistor/thermistor_9.h +++ b/Marlin/src/module/thermistor/thermistor_9.h @@ -22,7 +22,7 @@ #pragma once // R25 = 100 kOhm, beta25 = 3960 K, 4.7 kOhm pull-up, GE Sensing AL03006-58.2K-97-G1 -const short temptable_9[][2] PROGMEM = { +const temp_entry_t temptable_9[] PROGMEM = { { OV( 1), 936 }, { OV( 36), 300 }, { OV( 71), 246 }, diff --git a/Marlin/src/module/thermistor/thermistor_99.h b/Marlin/src/module/thermistor/thermistor_99.h index 045a42b73804..b6d6bbac9d02 100644 --- a/Marlin/src/module/thermistor/thermistor_99.h +++ b/Marlin/src/module/thermistor/thermistor_99.h @@ -24,7 +24,7 @@ // 100k bed thermistor with a 10K pull-up resistor - made by $ buildroot/share/scripts/createTemperatureLookupMarlin.py --rp=10000 -const short temptable_99[][2] PROGMEM = { +const temp_entry_t temptable_99[] PROGMEM = { { OV( 5.81), 350 }, // v=0.028 r= 57.081 res=13.433 degC/count { OV( 6.54), 340 }, // v=0.032 r= 64.248 res=11.711 degC/count { OV( 7.38), 330 }, // v=0.036 r= 72.588 res=10.161 degC/count diff --git a/Marlin/src/module/thermistor/thermistor_998.h b/Marlin/src/module/thermistor/thermistor_998.h index 6f631d4b9abe..2802121c5040 100644 --- a/Marlin/src/module/thermistor/thermistor_998.h +++ b/Marlin/src/module/thermistor/thermistor_998.h @@ -27,7 +27,7 @@ #define DUMMY_THERMISTOR_998_VALUE 25 #endif -const short temptable_998[][2] PROGMEM = { +const temp_entry_t temptable_998[] PROGMEM = { { OV( 1), DUMMY_THERMISTOR_998_VALUE }, { OV(1023), DUMMY_THERMISTOR_998_VALUE } }; diff --git a/Marlin/src/module/thermistor/thermistor_999.h b/Marlin/src/module/thermistor/thermistor_999.h index d750d5597c38..cf6ebb3ae1d5 100644 --- a/Marlin/src/module/thermistor/thermistor_999.h +++ b/Marlin/src/module/thermistor/thermistor_999.h @@ -27,7 +27,7 @@ #define DUMMY_THERMISTOR_999_VALUE 25 #endif -const short temptable_999[][2] PROGMEM = { +const temp_entry_t temptable_999[] PROGMEM = { { OV( 1), DUMMY_THERMISTOR_999_VALUE }, { OV(1023), DUMMY_THERMISTOR_999_VALUE } }; diff --git a/Marlin/src/module/thermistor/thermistors.h b/Marlin/src/module/thermistor/thermistors.h index 04b091b2a093..afb3148dfd9e 100644 --- a/Marlin/src/module/thermistor/thermistors.h +++ b/Marlin/src/module/thermistor/thermistors.h @@ -42,6 +42,8 @@ #define ANY_THERMISTOR_IS(n) (THERMISTOR_HEATER_0 == n || THERMISTOR_HEATER_1 == n || THERMISTOR_HEATER_2 == n || THERMISTOR_HEATER_3 == n || THERMISTOR_HEATER_4 == n || THERMISTOR_HEATER_5 == n || THERMISTOR_HEATER_6 == n || THERMISTOR_HEATER_7 == n || THERMISTORBED == n || THERMISTORCHAMBER == n || THERMISTORPROBE == n) +typedef struct { int16_t value, celsius; } temp_entry_t; + // Pt1000 and Pt100 handling // // Rt=R0*(1+a*T+b*T*T) [for T>0] @@ -185,12 +187,13 @@ #include "thermistor_999.h" #endif #if ANY_THERMISTOR_IS(1000) // Custom - const short temptable_1000[][2] PROGMEM = { { 0, 0 } }; + const temp_entry_t temptable_1000[] PROGMEM = { { 0, 0 } }; #endif #define _TT_NAME(_N) temptable_ ## _N #define TT_NAME(_N) _TT_NAME(_N) + #if THERMISTOR_HEATER_0 #define HEATER_0_TEMPTABLE TT_NAME(THERMISTOR_HEATER_0) #define HEATER_0_TEMPTABLE_LEN COUNT(HEATER_0_TEMPTABLE) @@ -288,9 +291,12 @@ #else #define CHAMBER_TEMPTABLE_LEN 0 #endif + #ifdef THERMISTORPROBE #define PROBE_TEMPTABLE TT_NAME(THERMISTORPROBE) #define PROBE_TEMPTABLE_LEN COUNT(PROBE_TEMPTABLE) +#elif defined(HEATER_PROBE_USES_THERMISTOR) + #error "No probe thermistor table specified" #else #define PROBE_TEMPTABLE_LEN 0 #endif @@ -300,7 +306,7 @@ static_assert( HEATER_0_TEMPTABLE_LEN < 256 && HEATER_1_TEMPTABLE_LEN < 256 && HEATER_2_TEMPTABLE_LEN < 256 && HEATER_3_TEMPTABLE_LEN < 256 && HEATER_4_TEMPTABLE_LEN < 256 && HEATER_5_TEMPTABLE_LEN < 256 - && HEATER_6_TEMPTABLE_LEN < 258 && HEATER_7_TEMPTABLE_LEN < 258 + && HEATER_6_TEMPTABLE_LEN < 256 && HEATER_7_TEMPTABLE_LEN < 256 && BED_TEMPTABLE_LEN < 256 && CHAMBER_TEMPTABLE_LEN < 256 && PROBE_TEMPTABLE_LEN < 256, "Temperature conversion tables over 255 entries need special consideration." @@ -309,8 +315,85 @@ static_assert( // Set the high and low raw values for the heaters // For thermistors the highest temperature results in the lowest ADC value // For thermocouples the highest temperature results in the highest ADC value + +#define _TT_REV(N) REVERSE_TEMP_SENSOR_RANGE_##N +#define TT_REV(N) _TT_REV(N) + +#ifdef HEATER_0_TEMPTABLE + #if TT_REV(THERMISTOR_HEATER_0) + #define HEATER_0_SENSOR_MINTEMP_IND 0 + #define HEATER_0_SENSOR_MAXTEMP_IND HEATER_0_TEMPTABLE_LEN - 1 + #else + #define HEATER_0_SENSOR_MINTEMP_IND HEATER_0_TEMPTABLE_LEN - 1 + #define HEATER_0_SENSOR_MAXTEMP_IND 0 + #endif +#endif +#ifdef HEATER_1_TEMPTABLE + #if TT_REV(THERMISTOR_HEATER_1) + #define HEATER_1_SENSOR_MINTEMP_IND 0 + #define HEATER_1_SENSOR_MAXTEMP_IND HEATER_1_TEMPTABLE_LEN - 1 + #else + #define HEATER_1_SENSOR_MINTEMP_IND HEATER_1_TEMPTABLE_LEN - 1 + #define HEATER_1_SENSOR_MAXTEMP_IND 0 + #endif +#endif +#ifdef HEATER_2_TEMPTABLE + #if TT_REV(THERMISTOR_HEATER_2) + #define HEATER_2_SENSOR_MINTEMP_IND 0 + #define HEATER_2_SENSOR_MAXTEMP_IND HEATER_2_TEMPTABLE_LEN - 1 + #else + #define HEATER_2_SENSOR_MINTEMP_IND HEATER_2_TEMPTABLE_LEN - 1 + #define HEATER_2_SENSOR_MAXTEMP_IND 0 + #endif +#endif +#ifdef HEATER_3_TEMPTABLE + #if TT_REV(THERMISTOR_HEATER_3) + #define HEATER_3_SENSOR_MINTEMP_IND 0 + #define HEATER_3_SENSOR_MAXTEMP_IND HEATER_3_TEMPTABLE_LEN - 1 + #else + #define HEATER_3_SENSOR_MINTEMP_IND HEATER_3_TEMPTABLE_LEN - 1 + #define HEATER_3_SENSOR_MAXTEMP_IND 0 + #endif +#endif +#ifdef HEATER_4_TEMPTABLE + #if TT_REV(THERMISTOR_HEATER_4) + #define HEATER_4_SENSOR_MINTEMP_IND 0 + #define HEATER_4_SENSOR_MAXTEMP_IND HEATER_4_TEMPTABLE_LEN - 1 + #else + #define HEATER_4_SENSOR_MINTEMP_IND HEATER_4_TEMPTABLE_LEN - 1 + #define HEATER_4_SENSOR_MAXTEMP_IND 0 + #endif +#endif +#ifdef HEATER_5_TEMPTABLE + #if TT_REV(THERMISTOR_HEATER_5) + #define HEATER_5_SENSOR_MINTEMP_IND 0 + #define HEATER_5_SENSOR_MAXTEMP_IND HEATER_5_TEMPTABLE_LEN - 1 + #else + #define HEATER_5_SENSOR_MINTEMP_IND HEATER_5_TEMPTABLE_LEN - 1 + #define HEATER_5_SENSOR_MAXTEMP_IND 0 + #endif +#endif +#ifdef HEATER_6_TEMPTABLE + #if TT_REV(THERMISTOR_HEATER_6) + #define HEATER_6_SENSOR_MINTEMP_IND 0 + #define HEATER_6_SENSOR_MAXTEMP_IND HEATER_6_TEMPTABLE_LEN - 1 + #else + #define HEATER_6_SENSOR_MINTEMP_IND HEATER_6_TEMPTABLE_LEN - 1 + #define HEATER_6_SENSOR_MAXTEMP_IND 0 + #endif +#endif +#ifdef HEATER_7_TEMPTABLE + #if TT_REV(THERMISTOR_HEATER_7) + #define HEATER_7_SENSOR_MINTEMP_IND 0 + #define HEATER_7_SENSOR_MAXTEMP_IND HEATER_7_TEMPTABLE_LEN - 1 + #else + #define HEATER_7_SENSOR_MINTEMP_IND HEATER_7_TEMPTABLE_LEN - 1 + #define HEATER_7_SENSOR_MAXTEMP_IND 0 + #endif +#endif + #ifndef HEATER_0_RAW_HI_TEMP - #if defined(REVERSE_TEMP_SENSOR_RANGE) || !defined(HEATER_0_USES_THERMISTOR) + #if TT_REV(THERMISTOR_HEATER_0) || !defined(HEATER_0_USES_THERMISTOR) #define HEATER_0_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE #define HEATER_0_RAW_LO_TEMP 0 #else @@ -319,7 +402,7 @@ static_assert( #endif #endif #ifndef HEATER_1_RAW_HI_TEMP - #if defined(REVERSE_TEMP_SENSOR_RANGE) || !defined(HEATER_1_USES_THERMISTOR) + #if TT_REV(THERMISTOR_HEATER_1) || !defined(HEATER_1_USES_THERMISTOR) #define HEATER_1_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE #define HEATER_1_RAW_LO_TEMP 0 #else @@ -328,7 +411,7 @@ static_assert( #endif #endif #ifndef HEATER_2_RAW_HI_TEMP - #if defined(REVERSE_TEMP_SENSOR_RANGE) || !defined(HEATER_2_USES_THERMISTOR) + #if TT_REV(THERMISTOR_HEATER_2) || !defined(HEATER_2_USES_THERMISTOR) #define HEATER_2_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE #define HEATER_2_RAW_LO_TEMP 0 #else @@ -337,7 +420,7 @@ static_assert( #endif #endif #ifndef HEATER_3_RAW_HI_TEMP - #if defined(REVERSE_TEMP_SENSOR_RANGE) || !defined(HEATER_3_USES_THERMISTOR) + #if TT_REV(THERMISTOR_HEATER_3) || !defined(HEATER_3_USES_THERMISTOR) #define HEATER_3_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE #define HEATER_3_RAW_LO_TEMP 0 #else @@ -346,7 +429,7 @@ static_assert( #endif #endif #ifndef HEATER_4_RAW_HI_TEMP - #if defined(REVERSE_TEMP_SENSOR_RANGE) || !defined(HEATER_4_USES_THERMISTOR) + #if TT_REV(THERMISTOR_HEATER_4) || !defined(HEATER_4_USES_THERMISTOR) #define HEATER_4_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE #define HEATER_4_RAW_LO_TEMP 0 #else @@ -355,7 +438,7 @@ static_assert( #endif #endif #ifndef HEATER_5_RAW_HI_TEMP - #if defined(REVERSE_TEMP_SENSOR_RANGE) || !defined(HEATER_5_USES_THERMISTOR) + #if TT_REV(THERMISTOR_HEATER_5) || !defined(HEATER_5_USES_THERMISTOR) #define HEATER_5_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE #define HEATER_5_RAW_LO_TEMP 0 #else @@ -364,7 +447,7 @@ static_assert( #endif #endif #ifndef HEATER_6_RAW_HI_TEMP - #if defined(REVERSE_TEMP_SENSOR_RANGE) || !defined(HEATER_6_USES_THERMISTOR) + #if TT_REV(THERMISTOR_HEATER_6) || !defined(HEATER_6_USES_THERMISTOR) #define HEATER_6_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE #define HEATER_6_RAW_LO_TEMP 0 #else @@ -373,7 +456,7 @@ static_assert( #endif #endif #ifndef HEATER_7_RAW_HI_TEMP - #if defined(REVERSE_TEMP_SENSOR_RANGE) || !defined(HEATER_7_USES_THERMISTOR) + #if TT_REV(THERMISTOR_HEATER_7) || !defined(HEATER_7_USES_THERMISTOR) #define HEATER_7_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE #define HEATER_7_RAW_LO_TEMP 0 #else @@ -382,7 +465,7 @@ static_assert( #endif #endif #ifndef HEATER_BED_RAW_HI_TEMP - #if defined(REVERSE_TEMP_SENSOR_RANGE) || !defined(HEATER_BED_USES_THERMISTOR) + #if TT_REV(THERMISTORBED) || !defined(HEATER_BED_USES_THERMISTOR) #define HEATER_BED_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE #define HEATER_BED_RAW_LO_TEMP 0 #else @@ -391,7 +474,7 @@ static_assert( #endif #endif #ifndef HEATER_CHAMBER_RAW_HI_TEMP - #if defined(REVERSE_TEMP_SENSOR_RANGE) || !defined(HEATER_CHAMBER_USES_THERMISTOR) + #if TT_REV(THERMISTORCHAMBER) || !defined(HEATER_CHAMBER_USES_THERMISTOR) #define HEATER_CHAMBER_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE #define HEATER_CHAMBER_RAW_LO_TEMP 0 #else @@ -399,5 +482,15 @@ static_assert( #define HEATER_CHAMBER_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE #endif #endif +#ifndef HEATER_PROBE_RAW_HI_TEMP + #if TT_REV(THERMISTORPROBE) || !defined(HEATER_PROBE_USES_THERMISTOR) + #define HEATER_PROBE_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE + #define HEATER_PROBE_RAW_LO_TEMP 0 + #else + #define HEATER_PROBE_RAW_HI_TEMP 0 + #define HEATER_PROBE_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE + #endif +#endif -#undef REVERSE_TEMP_SENSOR_RANGE +#undef _TT_REV +#undef TT_REV