Filament sensor cleanup

2.0.x
Scott Lahteine 4 years ago committed by Scott Lahteine
parent dd42831cba
commit 1aa421efe5

@ -192,11 +192,7 @@ bool load_filament(const float &slow_load_length/*=0*/, const float &fast_load_l
KEEPALIVE_STATE(PAUSED_FOR_USER);
wait_for_user = true; // LCD click or M108 will clear this
#if ENABLED(HOST_PROMPT_SUPPORT)
const char tool = '0'
#if NUM_RUNOUT_SENSORS > 1
+ active_extruder
#endif
;
const char tool = '0' + TERN0(MULTI_FILAMENT_SENSOR, active_extruder);
host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Load Filament T"), tool, CONTINUE_STR);
#endif

@ -88,11 +88,7 @@ void event_filament_runout() {
TERN_(EXTENSIBLE_UI, ExtUI::onFilamentRunout(ExtUI::getActiveTool()));
#if EITHER(HOST_PROMPT_SUPPORT, HOST_ACTION_COMMANDS)
const char tool = '0'
#if NUM_RUNOUT_SENSORS > 1
+ active_extruder
#endif
;
const char tool = '0' + TERN0(MULTI_FILAMENT_SENSOR, active_extruder);
#endif
//action:out_of_filament

@ -230,7 +230,7 @@ class FilamentSensorBase {
change = old_state ^ new_state;
old_state = new_state;
#ifdef FILAMENT_RUNOUT_SENSOR_DEBUG
#if ENABLED(FILAMENT_RUNOUT_SENSOR_DEBUG)
if (change) {
SERIAL_ECHOPGM("Motion detected:");
LOOP_L_N(e, NUM_RUNOUT_SENSORS)
@ -266,12 +266,12 @@ class FilamentSensorBase {
private:
static inline bool poll_runout_state(const uint8_t extruder) {
const uint8_t runout_states = poll_runout_states();
#if NUM_RUNOUT_SENSORS == 1
UNUSED(extruder);
#else
#if MULTI_FILAMENT_SENSOR
if ( !TERN0(DUAL_X_CARRIAGE, idex_is_duplicating())
&& !TERN0(MULTI_NOZZLE_DUPLICATION, extruder_duplication_enabled)
) return TEST(runout_states, extruder); // A specific extruder ran out
#else
UNUSED(extruder);
#endif
return !!runout_states; // Any extruder ran out
}
@ -282,7 +282,7 @@ class FilamentSensorBase {
static inline void run() {
const bool out = poll_runout_state(active_extruder);
if (!out) filament_present(active_extruder);
#ifdef FILAMENT_RUNOUT_SENSOR_DEBUG
#if ENABLED(FILAMENT_RUNOUT_SENSOR_DEBUG)
static bool was_out = false;
if (out != was_out) {
was_out = out;
@ -315,7 +315,7 @@ class FilamentSensorBase {
}
static inline void run() {
#ifdef FILAMENT_RUNOUT_SENSOR_DEBUG
#if ENABLED(FILAMENT_RUNOUT_SENSOR_DEBUG)
static millis_t t = 0;
const millis_t ms = millis();
if (ELAPSED(ms, t)) {

@ -83,7 +83,7 @@ void GcodeSuite::M600() {
int8_t DXC_ext = target_extruder;
if (!parser.seen('T')) { // If no tool index is specified, M600 was (probably) sent in response to filament runout.
// In this case, for duplicating modes set DXC_ext to the extruder that ran out.
#if HAS_FILAMENT_SENSOR && NUM_RUNOUT_SENSORS > 1
#if MULTI_FILAMENT_SENSOR
if (idex_is_duplicating())
DXC_ext = (READ(FIL_RUNOUT2_PIN) == FIL_RUNOUT2_STATE) ? 1 : 0;
#else

@ -128,6 +128,9 @@
#if ENABLED(FILAMENT_RUNOUT_SENSOR)
#define HAS_FILAMENT_SENSOR 1
#if NUM_RUNOUT_SENSORS > 1
#define MULTI_FILAMENT_SENSOR 1
#endif
#ifdef FILAMENT_RUNOUT_DISTANCE_MM
#define HAS_FILAMENT_RUNOUT_DISTANCE 1
#endif

@ -340,8 +340,10 @@ namespace ExtUI {
#endif
}
extruder_t getActiveTool() {
switch (active_extruder) {
extruder_t getTool(const uint8_t extruder) {
switch (extruder) {
case 7: return E7;
case 6: return E6;
case 5: return E5;
case 4: return E4;
case 3: return E3;
@ -351,6 +353,8 @@ namespace ExtUI {
}
}
extruder_t getActiveTool() { return getTool(active_extruder); }
bool isMoving() { return planner.has_blocks_queued(); }
bool canMove(const axis_t axis) {

@ -215,6 +215,7 @@ namespace ExtUI {
void setAxisMaxJerk_mm_s(const float, const extruder_t);
#endif
extruder_t getTool(const uint8_t extruder);
extruder_t getActiveTool();
void setActiveTool(const extruder_t, bool no_move);

@ -35,7 +35,7 @@
#define MOSFET_D_PIN 7
#define FIL_RUNOUT_PIN 2
#if NUM_RUNOUT_SENSORS > 1
#if NUM_RUNOUT_SENSORS >= 2
#define FIL_RUNOUT2_PIN 15 // Creality CR-X can use dual runout sensors
#endif

Loading…
Cancel
Save