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

@ -204,10 +204,6 @@ bool wait_for_heatup = true;
bool wait_for_user; // = false;
#endif
#if HAS_AUTO_REPORTING || ENABLED(HOST_KEEPALIVE_FEATURE)
bool suspend_auto_report; // = false
#endif
// Inactivity shutdown
millis_t max_inactive_time, // = 0
stepper_inactive_time = (DEFAULT_STEPPER_DEACTIVE_TIME) * 1000UL;
@ -432,7 +428,7 @@ void startOrResumeJob() {
* - Pulse FET_SAFETY_PIN if it exists
*/
void manage_inactivity(const bool ignore_stepper_queue/*=false*/) {
inline void manage_inactivity(const bool ignore_stepper_queue=false) {
#if HAS_FILAMENT_SENSOR
runout.run();
@ -697,7 +693,7 @@ void idle(
#endif
#if HAS_AUTO_REPORTING
if (!suspend_auto_report) {
if (!gcode.autoreport_paused) {
#if ENABLED(AUTO_REPORT_TEMPERATURES)
thermalManager.auto_report_temperatures();
#endif

View file

@ -44,8 +44,6 @@ void idle(
#endif
);
void manage_inactivity(const bool ignore_stepper_queue=false);
#if ENABLED(EXPERIMENTAL_I2CBUS)
#include "feature/twibus.h"
extern TWIBus i2c;
@ -84,10 +82,6 @@ extern bool wait_for_heatup;
extern bool wait_for_user;
#endif
#if HAS_AUTO_REPORTING || ENABLED(HOST_KEEPALIVE_FEATURE)
extern bool suspend_auto_report;
#endif
// Inactivity shutdown timer
extern millis_t max_inactive_time, stepper_inactive_time;

View file

@ -35,6 +35,18 @@ void safe_delay(millis_t ms) {
thermalManager.manage_heater(); // This keeps us safe if too many small safe_delay() calls are made
}
// A delay to provide brittle hosts time to receive bytes
#if ENABLED(SERIAL_OVERRUN_PROTECTION)
#include "../gcode/gcode.h" // for set_autoreport_paused
void serial_delay(const millis_t ms) {
const bool was = gcode.set_autoreport_paused(true);
safe_delay(ms);
gcode.set_autoreport_paused(was);
}
#endif
#if ENABLED(DEBUG_LEVELING_FEATURE)
#include "../module/probe.h"

View file

@ -27,14 +27,11 @@
// Delay that ensures heaters and watchdog are kept alive
void safe_delay(millis_t ms);
// A delay to provide brittle hosts time to receive bytes
inline void serial_delay(const millis_t ms) {
#if ENABLED(SERIAL_OVERRUN_PROTECTION)
safe_delay(ms);
#else
UNUSED(ms);
#endif
}
#if ENABLED(SERIAL_OVERRUN_PROTECTION)
void serial_delay(const millis_t ms);
#else
inline void serial_delay(const millis_t) {}
#endif
#if GRID_MAX_POINTS_X && GRID_MAX_POINTS_Y

View file

@ -28,6 +28,8 @@
unified_bed_leveling ubl;
#include "../../../MarlinCore.h"
#include "../../../module/configuration_store.h"
#include "../../../module/planner.h"
#include "../../../module/motion.h"
@ -151,9 +153,7 @@
* 4: Compact Human-Readable
*/
void unified_bed_leveling::display_map(const int map_type) {
#if HAS_AUTO_REPORTING || ENABLED(HOST_KEEPALIVE_FEATURE)
suspend_auto_report = true;
#endif
const bool was = gcode.set_autoreport_paused(true);
constexpr uint8_t eachsp = 1 + 6 + 1, // [-3.567]
twixt = eachsp * (GRID_MAX_POINTS_X) - 9 * 2; // Leading 4sp, Coordinates 9sp each
@ -229,9 +229,7 @@
SERIAL_EOL();
}
#if HAS_AUTO_REPORTING || ENABLED(HOST_KEEPALIVE_FEATURE)
suspend_auto_report = false;
#endif
set_gcode.set_autoreport_paused(was);
}
bool unified_bed_leveling::sanity_check() {

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