From a658880332234c17eaaa10d0e535f11fa929b0d5 Mon Sep 17 00:00:00 2001 From: shitcreek Date: Thu, 25 Jun 2020 22:01:38 -0500 Subject: [PATCH 1/5] add P parameter to M155 auto report position with M155 P --- Marlin/src/gcode/gcode.cpp | 3 ++- Marlin/src/gcode/gcode.h | 1 + Marlin/src/gcode/temp/M155.cpp | 6 ++++++ Marlin/src/module/temperature.cpp | 6 +++++- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index d34e0665c6..4f56385473 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -71,7 +71,8 @@ uint8_t GcodeSuite::axis_relative = ( ); #if EITHER(HAS_AUTO_REPORTING, HOST_KEEPALIVE_FEATURE) - bool GcodeSuite::autoreport_paused; // = false + bool GcodeSuite::autoreport_paused; // = false + bool GcodeSuite::autoreport_position; // = false /new/ #endif #if ENABLED(HOST_KEEPALIVE_FEATURE) diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index ab17cc8d7d..2707833dd1 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -354,6 +354,7 @@ public: } #if EITHER(HAS_AUTO_REPORTING, HOST_KEEPALIVE_FEATURE) + static bool autoreport_position; static bool autoreport_paused; static inline bool set_autoreport_paused(const bool p) { const bool was = autoreport_paused; diff --git a/Marlin/src/gcode/temp/M155.cpp b/Marlin/src/gcode/temp/M155.cpp index 8859736f50..74ba66e1cf 100644 --- a/Marlin/src/gcode/temp/M155.cpp +++ b/Marlin/src/gcode/temp/M155.cpp @@ -31,6 +31,12 @@ * M155: Set temperature auto-report interval. M155 S */ void GcodeSuite::M155() { + if (parser.seen('P')) //automatically report_current_position_projected(); + { + gcode.autoreport_position = true; + } + else + gcode.autoreport_position = false; if (parser.seenval('S')) thermalManager.set_auto_report_interval(parser.value_byte()); diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index f909476592..0337dcd12c 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -2988,7 +2988,11 @@ void Temperature::tick() { next_temp_report_ms = millis() + 1000UL * auto_report_temp_interval; PORT_REDIRECT(SERIAL_BOTH); print_heater_states(active_extruder); - SERIAL_EOL(); + if(gcode.autoreport_position){ + SERIAL_CHAR(' '); + report_current_position_projected();} + else + SERIAL_EOL(); } } From 0153bf8c14cbd328c4cd386daf3aed0df0d0bcaa Mon Sep 17 00:00:00 2001 From: shitcreek Date: Thu, 25 Jun 2020 22:02:44 -0500 Subject: [PATCH 2/5] Update gcode.cpp --- Marlin/src/gcode/gcode.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index 4f56385473..a51e5b9187 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -72,7 +72,7 @@ uint8_t GcodeSuite::axis_relative = ( #if EITHER(HAS_AUTO_REPORTING, HOST_KEEPALIVE_FEATURE) bool GcodeSuite::autoreport_paused; // = false - bool GcodeSuite::autoreport_position; // = false /new/ + bool GcodeSuite::autoreport_position; // = false #endif #if ENABLED(HOST_KEEPALIVE_FEATURE) From f28a03be609ddcf273e2d146f4eea57985537ca8 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 25 Jun 2020 23:04:40 -0500 Subject: [PATCH 3/5] Tweaks to style --- Marlin/src/MarlinCore.cpp | 2 +- Marlin/src/gcode/gcode.cpp | 5 ++--- Marlin/src/gcode/gcode.h | 15 ++++++++++----- Marlin/src/gcode/temp/M155.cpp | 9 +++------ Marlin/src/module/temperature.cpp | 5 +++-- 5 files changed, 19 insertions(+), 17 deletions(-) diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 66d3c78ca4..3a3879990d 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -728,7 +728,7 @@ void idle(TERN_(ADVANCED_PAUSE_FEATURE, bool no_stepper_sleep/*=false*/)) { // Auto-report Temperatures / SD Status #if HAS_AUTO_REPORTING - if (!gcode.autoreport_paused) { + if (!gcode.autoreport.paused) { TERN_(AUTO_REPORT_TEMPERATURES, thermalManager.auto_report_temperatures()); TERN_(AUTO_REPORT_SD_STATUS, card.auto_report_sd_status()); } diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index a51e5b9187..54e4ff4d97 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -71,8 +71,7 @@ uint8_t GcodeSuite::axis_relative = ( ); #if EITHER(HAS_AUTO_REPORTING, HOST_KEEPALIVE_FEATURE) - bool GcodeSuite::autoreport_paused; // = false - bool GcodeSuite::autoreport_position; // = false + GcodeSuite::autoreport_t GcodeSuite::autoreport{0}; #endif #if ENABLED(HOST_KEEPALIVE_FEATURE) @@ -975,7 +974,7 @@ void GcodeSuite::process_subcommands_now(char * gcode) { void GcodeSuite::host_keepalive() { const millis_t ms = millis(); static millis_t next_busy_signal_ms = 0; - if (!autoreport_paused && host_keepalive_interval && busy_state != NOT_BUSY) { + if (!autoreport.paused && host_keepalive_interval && busy_state != NOT_BUSY) { if (PENDING(ms, next_busy_signal_ms)) return; switch (busy_state) { case IN_HANDLER: diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index 2707833dd1..8aea4d02cc 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -353,16 +353,21 @@ public: process_subcommands_now_P(G28_STR); } + typedef struct { + bool paused:1; + bool position:1; + } autoreport_t; + #if EITHER(HAS_AUTO_REPORTING, HOST_KEEPALIVE_FEATURE) - static bool autoreport_position; - static bool autoreport_paused; + static autoreport_t autoreport; + static inline bool set_autoreport_paused(const bool p) { - const bool was = autoreport_paused; - autoreport_paused = p; + const bool was = autoreport.paused; + autoreport.paused = p; return was; } #else - static constexpr bool autoreport_paused = false; + static constexpr autoreport_t{false}; static inline bool set_autoreport_paused(const bool) { return false; } #endif diff --git a/Marlin/src/gcode/temp/M155.cpp b/Marlin/src/gcode/temp/M155.cpp index 74ba66e1cf..c6ca45fd08 100644 --- a/Marlin/src/gcode/temp/M155.cpp +++ b/Marlin/src/gcode/temp/M155.cpp @@ -31,12 +31,9 @@ * M155: Set temperature auto-report interval. M155 S */ void GcodeSuite::M155() { - if (parser.seen('P')) //automatically report_current_position_projected(); - { - gcode.autoreport_position = true; - } - else - gcode.autoreport_position = false; + + if (parser.seen('P')) + autoreport.position = parser.value_bool(); if (parser.seenval('S')) thermalManager.set_auto_report_interval(parser.value_byte()); diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 0337dcd12c..ceba730363 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -2988,9 +2988,10 @@ void Temperature::tick() { next_temp_report_ms = millis() + 1000UL * auto_report_temp_interval; PORT_REDIRECT(SERIAL_BOTH); print_heater_states(active_extruder); - if(gcode.autoreport_position){ + if (gcode.autoreport.position) { SERIAL_CHAR(' '); - report_current_position_projected();} + report_current_position_projected(); + } else SERIAL_EOL(); } From 88089c331cca8c057aef64bb6ff4920c9e39ca54 Mon Sep 17 00:00:00 2001 From: Luu Lac <45380455+shitcreek@users.noreply.github.com> Date: Thu, 25 Jun 2020 23:28:56 -0500 Subject: [PATCH 4/5] Update temperature.cpp --- Marlin/src/module/temperature.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index ceba730363..31ce590119 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -2988,12 +2988,8 @@ void Temperature::tick() { next_temp_report_ms = millis() + 1000UL * auto_report_temp_interval; PORT_REDIRECT(SERIAL_BOTH); print_heater_states(active_extruder); - if (gcode.autoreport.position) { - SERIAL_CHAR(' '); - report_current_position_projected(); - } - else - SERIAL_EOL(); + SERIAL_EOL(); + if(gcode.autoreport_position) report_current_position_projected(); } } From 9fce244ef0b4632ff669fbf17471a19521f3d38f Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 26 Jun 2020 01:04:30 -0500 Subject: [PATCH 5/5] Update temperature.cpp --- Marlin/src/module/temperature.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 31ce590119..cc83606a46 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -2989,7 +2989,7 @@ void Temperature::tick() { PORT_REDIRECT(SERIAL_BOTH); print_heater_states(active_extruder); SERIAL_EOL(); - if(gcode.autoreport_position) report_current_position_projected(); + if (gcode.autoreport.position) report_current_position_projected(); } }