From 439a3e846370b5f4dfddf5808a9572eac9e0efc2 Mon Sep 17 00:00:00 2001
From: Marcio Teixeira <marcio@alephobjects.com>
Date: Tue, 27 Nov 2018 12:45:25 -0700
Subject: [PATCH] Improve runout sensor, fix LIGHTWEIGHT_UI screen size
 (#12544)

---
 Marlin/src/feature/runout.h        | 12 ++++++++----
 Marlin/src/inc/Conditionals_post.h |  8 ++------
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/Marlin/src/feature/runout.h b/Marlin/src/feature/runout.h
index c6a6f0804a..55bde42fa3 100644
--- a/Marlin/src/feature/runout.h
+++ b/Marlin/src/feature/runout.h
@@ -186,7 +186,8 @@ class FilamentSensorBase {
         old_state = new_state;
 
         #ifdef FILAMENT_RUNOUT_SENSOR_DEBUG
-          if (change) SERIAL_PROTOCOLLNPAIR("Motion detected: ", int(change));
+          for (uint8_t e = 0; e < EXTRUDERS; e++)
+            if (TEST(change, e)) SERIAL_PROTOCOLLNPAIR("Motion detected T", e);
         #endif
 
         motion_detected |= change;
@@ -295,9 +296,12 @@ class FilamentSensorBase {
       }
 
       static inline void block_completed(const block_t* const b) {
-        const uint8_t e = b->extruder;
-        const int32_t steps = b->steps[E_AXIS];
-        runout_mm_countdown[e] -= (TEST(b->direction_bits, E_AXIS) ? -steps : steps) * planner.steps_to_mm[E_AXIS_N(e)];
+        if (b->steps[X_AXIS] || b->steps[Y_AXIS] || b->steps[Z_AXIS]) {
+          // Only trigger on extrusion with XYZ movement to allow filament change and retract/recover.
+          const uint8_t e = b->extruder;
+          const int32_t steps = b->steps[E_AXIS];
+          runout_mm_countdown[e] -= (TEST(b->direction_bits, E_AXIS) ? -steps : steps) * planner.steps_to_mm[E_AXIS_N(e)];
+        }
       }
   };
 
diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h
index 4d4cf07a0a..4e1097f93b 100644
--- a/Marlin/src/inc/Conditionals_post.h
+++ b/Marlin/src/inc/Conditionals_post.h
@@ -1641,9 +1641,7 @@
 
 // Get LCD character width/height, which may be overridden by pins, configs, etc.
 #ifndef LCD_WIDTH
-  #if ENABLED(LIGHTWEIGHT_UI)
-    #define LCD_WIDTH 16
-  #elif HAS_GRAPHICAL_LCD
+  #if HAS_GRAPHICAL_LCD
     #define LCD_WIDTH 22
   #elif ENABLED(ULTIPANEL)
     #define LCD_WIDTH 20
@@ -1652,9 +1650,7 @@
   #endif
 #endif
 #ifndef LCD_HEIGHT
-  #if ENABLED(LIGHTWEIGHT_UI)
-    #define LCD_HEIGHT 4
-  #elif HAS_GRAPHICAL_LCD
+  #if HAS_GRAPHICAL_LCD
     #define LCD_HEIGHT 5
   #elif ENABLED(ULTIPANEL)
     #define LCD_HEIGHT 4
-- 
GitLab