Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid int8_t underflow on filament runout #13895

Merged
merged 1 commit into from
May 7, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions Marlin/src/feature/runout.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
#endif

//#define FILAMENT_RUNOUT_SENSOR_DEBUG
#ifndef FILAMENT_RUNOUT_THRESHOLD
#define FILAMENT_RUNOUT_THRESHOLD 5
#endif

class FilamentMonitorBase {
public:
Expand Down Expand Up @@ -332,11 +335,11 @@ class FilamentSensorBase {

class RunoutResponseDebounced {
private:
static constexpr int8_t runout_threshold = 5;
static constexpr int8_t runout_threshold = FILAMENT_RUNOUT_THRESHOLD;
static int8_t runout_count;
public:
static inline void reset() { runout_count = runout_threshold; }
static inline void run() { runout_count--; }
static inline void run() { if (runout_count >= 0) runout_count--; }
thinkyhead marked this conversation as resolved.
Show resolved Hide resolved
static inline bool has_run_out() { return runout_count < 0; }
static inline void block_completed(const block_t* const b) { UNUSED(b); }
static inline void filament_present(const uint8_t extruder) { runout_count = runout_threshold; UNUSED(extruder); }
Expand Down