Inline manage_inactivity, tweak autoreport_paused

This commit is contained in:
Scott Lahteine
2020-02-20 20:09:37 -06:00
parent 2b788e9aa6
commit a1f026f57a
7 changed files with 41 additions and 28 deletions

View File

@ -53,7 +53,7 @@ GcodeSuite gcode;
#include "../feature/cancel_object.h"
#endif
#include "../MarlinCore.h" // for idle() and suspend_auto_report
#include "../MarlinCore.h" // for idle()
millis_t GcodeSuite::previous_move_ms;
@ -66,6 +66,10 @@ uint8_t GcodeSuite::axis_relative = (
| (ar_init.e ? _BV(REL_E) : 0)
);
#if HAS_AUTO_REPORTING || ENABLED(HOST_KEEPALIVE_FEATURE)
bool GcodeSuite::autoreport_paused; // = false
#endif
#if ENABLED(HOST_KEEPALIVE_FEATURE)
GcodeSuite::MarlinBusyState GcodeSuite::busy_state = NOT_BUSY;
uint8_t GcodeSuite::host_keepalive_interval = DEFAULT_KEEPALIVE_INTERVAL;
@ -942,7 +946,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 (!suspend_auto_report && 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:

View File

@ -351,6 +351,18 @@ public:
process_subcommands_now_P(G28_STR);
}
#if HAS_AUTO_REPORTING || ENABLED(HOST_KEEPALIVE_FEATURE)
static bool autoreport_paused;
static inline bool set_autoreport_paused(const bool p) {
const bool was = autoreport_paused;
autoreport_paused = p;
return was;
}
#else
static constexpr bool autoreport_paused = false;
static inline bool set_autoreport_paused(const bool) { return false; }
#endif
#if ENABLED(HOST_KEEPALIVE_FEATURE)
/**
* States for managing Marlin and host communication