Skip to content

Commit

Permalink
Inline manage_inactivity, tweak autoreport_paused
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Feb 21, 2020
1 parent 2b788e9 commit a1f026f
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 28 deletions.
8 changes: 2 additions & 6 deletions Marlin/src/MarlinCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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
Expand Down
6 changes: 0 additions & 6 deletions Marlin/src/MarlinCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down
12 changes: 12 additions & 0 deletions Marlin/src/core/utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
13 changes: 5 additions & 8 deletions Marlin/src/core/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 4 additions & 6 deletions Marlin/src/feature/bedlevel/ubl/ubl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@

unified_bed_leveling ubl;

#include "../../../MarlinCore.h"

#include "../../../module/configuration_store.h"
#include "../../../module/planner.h"
#include "../../../module/motion.h"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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() {
Expand Down
8 changes: 6 additions & 2 deletions Marlin/src/gcode/gcode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand Down Expand Up @@ -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:
Expand Down
12 changes: 12 additions & 0 deletions Marlin/src/gcode/gcode.h
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,18 @@ class GcodeSuite {
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
Expand Down

0 comments on commit a1f026f

Please sign in to comment.