Browse Source

Guards for large BLOCK_BUFFER_SIZE (>=128) (#20130)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
FanDjango 3 years ago
parent
commit
110e0d782f
No account linked to committer's email address
3 changed files with 15 additions and 11 deletions
  1. 2
    0
      Marlin/src/inc/SanityCheck.h
  2. 8
    10
      Marlin/src/module/planner.cpp
  3. 5
    1
      Marlin/src/module/planner.h

+ 2
- 0
Marlin/src/inc/SanityCheck.h View File

@@ -2759,6 +2759,8 @@ static_assert(   _ARR_TEST(3,0) && _ARR_TEST(3,1) && _ARR_TEST(3,2)
2759 2759
 
2760 2760
 #if !BLOCK_BUFFER_SIZE || !IS_POWER_OF_2(BLOCK_BUFFER_SIZE)
2761 2761
   #error "BLOCK_BUFFER_SIZE must be a power of 2."
2762
+#elif BLOCK_BUFFER_SIZE > 64
2763
+  #error "A very large BLOCK_BUFFER_SIZE is not needed and takes longer to drain the buffer on pause / cancel."
2762 2764
 #endif
2763 2765
 
2764 2766
 #if ENABLED(LED_CONTROL_MENU) && !IS_ULTIPANEL

+ 8
- 10
Marlin/src/module/planner.cpp View File

@@ -213,7 +213,7 @@ xyze_float_t Planner::previous_speed;
213 213
 float Planner::previous_nominal_speed_sqr;
214 214
 
215 215
 #if ENABLED(DISABLE_INACTIVE_EXTRUDER)
216
-  uint8_t Planner::g_uc_extruder_last_move[EXTRUDERS] = { 0 };
216
+  last_move_t Planner::g_uc_extruder_last_move[EXTRUDERS] = { 0 };
217 217
 #endif
218 218
 
219 219
 #ifdef XY_FREQUENCY_LIMIT
@@ -2037,22 +2037,20 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
2037 2037
       #if ENABLED(DISABLE_INACTIVE_EXTRUDER) // Enable only the selected extruder
2038 2038
 
2039 2039
         LOOP_L_N(i, EXTRUDERS)
2040
-          if (g_uc_extruder_last_move[i] > 0) g_uc_extruder_last_move[i]--;
2041
-
2042
-        #if HAS_DUPLICATION_MODE
2043
-          if (extruder_duplication_enabled && extruder == 0) {
2044
-            ENABLE_AXIS_E1();
2045
-            g_uc_extruder_last_move[1] = (BLOCK_BUFFER_SIZE) * 2;
2046
-          }
2047
-        #endif
2040
+          if (g_uc_extruder_last_move[i]) g_uc_extruder_last_move[i]--;
2048 2041
 
2049 2042
         #define ENABLE_ONE_E(N) do{ \
2050 2043
           if (extruder == N) { \
2051 2044
             ENABLE_AXIS_E##N(); \
2052 2045
             g_uc_extruder_last_move[N] = (BLOCK_BUFFER_SIZE) * 2; \
2046
+            if ((N) == 0 && TERN0(HAS_DUPLICATION_MODE, extruder_duplication_enabled)) \
2047
+              ENABLE_AXIS_E1(); \
2053 2048
           } \
2054
-          else if (!g_uc_extruder_last_move[N]) \
2049
+          else if (!g_uc_extruder_last_move[N]) { \
2055 2050
             DISABLE_AXIS_E##N(); \
2051
+            if ((N) == 0 && TERN0(HAS_DUPLICATION_MODE, extruder_duplication_enabled)) \
2052
+              DISABLE_AXIS_E1(); \
2053
+          } \
2056 2054
         }while(0);
2057 2055
 
2058 2056
       #else

+ 5
- 1
Marlin/src/module/planner.h View File

@@ -287,6 +287,10 @@ typedef struct {
287 287
   #endif
288 288
 } skew_factor_t;
289 289
 
290
+#if ENABLED(DISABLE_INACTIVE_EXTRUDER)
291
+  typedef IF<(BLOCK_BUFFER_SIZE > 64), uint16_t, uint8_t>::type last_move_t;
292
+#endif
293
+
290 294
 class Planner {
291 295
   public:
292 296
 
@@ -435,7 +439,7 @@ class Planner {
435 439
 
436 440
     #if ENABLED(DISABLE_INACTIVE_EXTRUDER)
437 441
        // Counters to manage disabling inactive extruders
438
-      static uint8_t g_uc_extruder_last_move[EXTRUDERS];
442
+      static last_move_t g_uc_extruder_last_move[EXTRUDERS];
439 443
     #endif
440 444
 
441 445
     #if HAS_WIRED_LCD

Loading…
Cancel
Save