From 81209f53102e53a0a00227eae5d2ea0ee3bdd255 Mon Sep 17 00:00:00 2001 From: Tim Moore Date: Thu, 27 Jun 2019 19:29:53 -0700 Subject: [PATCH] 'M105 R' to report redundant temp sensor (#14324) --- Marlin/src/gcode/temperature/M105.cpp | 6 ++- Marlin/src/module/temperature.cpp | 55 ++++++++++++++++++--------- Marlin/src/module/temperature.h | 6 ++- 3 files changed, 47 insertions(+), 20 deletions(-) diff --git a/Marlin/src/gcode/temperature/M105.cpp b/Marlin/src/gcode/temperature/M105.cpp index ea613e6316..586d477286 100644 --- a/Marlin/src/gcode/temperature/M105.cpp +++ b/Marlin/src/gcode/temperature/M105.cpp @@ -33,7 +33,11 @@ void GcodeSuite::M105() { #if HAS_TEMP_SENSOR SERIAL_ECHOPGM(MSG_OK); - thermalManager.print_heater_states(target_extruder); + thermalManager.print_heater_states(target_extruder + #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) + , parser.boolval('R') + #endif + ); #else // !HAS_TEMP_SENSOR SERIAL_ERROR_MSG(MSG_ERR_NO_THERMISTORS); #endif diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 3382368da3..9553e8e3b7 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -112,7 +112,11 @@ Temperature thermalManager; bool Temperature::adaptive_fan_slowing = true; #endif -hotend_info_t Temperature::temp_hotend[HOTENDS]; // = { 0 } +hotend_info_t Temperature::temp_hotend[HOTENDS + #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) + + 1 + #endif +]; // = { 0 } #if ENABLED(AUTO_POWER_E_FANS) uint8_t Temperature::autofan_speed[HOTENDS]; // = { 0 } @@ -2773,22 +2777,25 @@ void Temperature::isr() { #endif , const int8_t e=-3 ) { - #if !(HAS_HEATED_BED && HAS_TEMP_HOTEND && HAS_TEMP_CHAMBER) && HOTENDS <= 1 - UNUSED(e); - #endif - - SERIAL_CHAR(' '); - SERIAL_CHAR( - #if HAS_TEMP_CHAMBER && HAS_HEATED_BED && HAS_TEMP_HOTEND - e == -2 ? 'C' : e == -1 ? 'B' : 'T' - #elif HAS_HEATED_BED && HAS_TEMP_HOTEND - e == -1 ? 'B' : 'T' - #elif HAS_TEMP_HOTEND - 'T' - #else - 'B' + char k; + switch (e) { + #if HAS_TEMP_CHAMBER + case -2: k = 'C'; break; #endif - ); + #if HAS_TEMP_HOTEND + default: k = 'T'; break; + #if HAS_HEATED_BED + case -1: k = 'B'; break; + #endif + #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) + case -3: k = 'R'; break; + #endif + #elif HAS_HEATED_BED + default: k = 'B'; break; + #endif + } + SERIAL_CHAR(' '); + SERIAL_CHAR(k); #if HOTENDS > 1 if (e >= 0) SERIAL_CHAR('0' + e); #endif @@ -2796,19 +2803,31 @@ void Temperature::isr() { SERIAL_ECHO(c); SERIAL_ECHOPAIR(" /" , t); #if ENABLED(SHOW_TEMP_ADC_VALUES) - SERIAL_ECHOPAIR(" (", r / OVERSAMPLENR); + SERIAL_ECHOPAIR(" (", r * RECIPROCAL(OVERSAMPLENR)); SERIAL_CHAR(')'); #endif delay(2); } - void Temperature::print_heater_states(const uint8_t target_extruder) { + void Temperature::print_heater_states(const uint8_t target_extruder + #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) + , const bool include_r/*=false*/ + #endif + ) { #if HAS_TEMP_HOTEND print_heater_state(degHotend(target_extruder), degTargetHotend(target_extruder) #if ENABLED(SHOW_TEMP_ADC_VALUES) , rawHotendTemp(target_extruder) #endif ); + #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) + if (include_r) print_heater_state(redundant_temperature, degTargetHotend(target_extruder) + #if ENABLED(SHOW_TEMP_ADC_VALUES) + , redundant_temperature_raw + #endif + , -3 // REDUNDANT + ); + #endif #endif #if HAS_HEATED_BED print_heater_state(degBed(), degTargetBed() diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index ddcdd3909c..1d1858ee9e 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -756,7 +756,11 @@ class Temperature { #endif // HEATER_IDLE_HANDLER #if HAS_TEMP_SENSOR - static void print_heater_states(const uint8_t target_extruder); + static void print_heater_states(const uint8_t target_extruder + #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) + , const bool include_r=false + #endif + ); #if ENABLED(AUTO_REPORT_TEMPERATURES) static uint8_t auto_report_temp_interval; static millis_t next_temp_report_ms;