diff --git a/Marlin/src/Marlin.cpp b/Marlin/src/Marlin.cpp index e9f740305c..bf32f7bc82 100644 --- a/Marlin/src/Marlin.cpp +++ b/Marlin/src/Marlin.cpp @@ -374,23 +374,6 @@ bool pin_is_protected(const int8_t pin) { return false; } -#if ENABLED(AUTO_REPORT_TEMPERATURES) && (HAS_TEMP_HOTEND || HAS_TEMP_BED) - - static uint8_t auto_report_temp_interval; - static millis_t next_temp_report_ms; - - inline void auto_report_temperatures() { - if (auto_report_temp_interval && ELAPSED(millis(), next_temp_report_ms)) { - next_temp_report_ms = millis() + 1000UL * auto_report_temp_interval; - thermalManager.print_heaterstates(); - SERIAL_EOL(); - } - } - - #include "gcode/temperature/M155.h" - -#endif // AUTO_REPORT_TEMPERATURES && (HAS_TEMP_HOTEND || HAS_TEMP_BED) - #if DISABLED(EMERGENCY_PARSER) #include "gcode/control/M108.h" #include "gcode/control/M112.h" @@ -902,7 +885,7 @@ void idle( #endif #if ENABLED(AUTO_REPORT_TEMPERATURES) && (HAS_TEMP_HOTEND || HAS_TEMP_BED) - auto_report_temperatures(); + thermalManager.auto_report_temperatures(); #endif manage_inactivity( diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index 6f9b16f0de..081a17015f 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -144,7 +144,6 @@ extern void gcode_M140(); extern void gcode_M145(); extern void gcode_M149(); extern void gcode_M150(); -extern void gcode_M155(); extern void gcode_M163(); extern void gcode_M164(); extern void gcode_M165(); @@ -495,9 +494,7 @@ void GcodeSuite::process_next_command() { return; // "ok" already printed #if ENABLED(AUTO_REPORT_TEMPERATURES) && (HAS_TEMP_HOTEND || HAS_TEMP_BED) - case 155: // M155: Set temperature auto-report interval - gcode_M155(); - break; + case 155: M155(); break; // M155: Set temperature auto-report interval #endif #if HAS_TEMP_BED diff --git a/Marlin/src/gcode/temperature/M155.h b/Marlin/src/gcode/temperature/M155.cpp similarity index 71% rename from Marlin/src/gcode/temperature/M155.h rename to Marlin/src/gcode/temperature/M155.cpp index b5d4248db4..d97e7b9ae9 100644 --- a/Marlin/src/gcode/temperature/M155.h +++ b/Marlin/src/gcode/temperature/M155.cpp @@ -20,13 +20,21 @@ * */ +#include "../../inc/MarlinConfig.h" + +#if ENABLED(AUTO_REPORT_TEMPERATURES) && (HAS_TEMP_HOTEND || HAS_TEMP_BED) + +#include "../gcode.h" +#include "../../module/temperature.h" + /** * M155: Set temperature auto-report interval. M155 S */ -void gcode_M155() { - if (parser.seenval('S')) { - auto_report_temp_interval = parser.value_byte(); - NOMORE(auto_report_temp_interval, 60); - next_temp_report_ms = millis() + 1000UL * auto_report_temp_interval; - } +void GcodeSuite::M155() { + + if (parser.seenval('S')) + thermalManager.set_auto_report_interval(parser.value_byte()); + } + +#endif // AUTO_REPORT_TEMPERATURES && (HAS_TEMP_HOTEND || HAS_TEMP_BED) diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 5bf392fdae..03cce00f78 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -2259,4 +2259,19 @@ void Temperature::isr() { #endif } + #if ENABLED(AUTO_REPORT_TEMPERATURES) + + uint8_t Temperature::auto_report_temp_interval; + millis_t Temperature::next_temp_report_ms; + + void Temperature::auto_report_temperatures() { + if (auto_report_temp_interval && ELAPSED(millis(), next_temp_report_ms)) { + next_temp_report_ms = millis() + 1000UL * auto_report_temp_interval; + print_heaterstates(); + SERIAL_EOL(); + } + } + + #endif // AUTO_REPORT_TEMPERATURES + #endif // HAS_TEMP_HOTEND || HAS_TEMP_BED diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index 9959d18248..e18bd10e22 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -527,6 +527,16 @@ class Temperature { #if HAS_TEMP_HOTEND || HAS_TEMP_BED static void print_heaterstates(); + #if ENABLED(AUTO_REPORT_TEMPERATURES) + static uint8_t auto_report_temp_interval; + static millis_t next_temp_report_ms; + static void auto_report_temperatures(void); + FORCE_INLINE void set_auto_report_interval(uint8_t v) { + NOMORE(v, 60); + auto_report_temp_interval = v; + next_temp_report_ms = millis() + 1000UL * v; + } + #endif #endif private: