Ver código fonte

Fix M301 access to lpq_len (#10714)

Co-Authored-By: Zwaubel
Scott Lahteine 7 anos atrás
pai
commit
625035a9ce
Nenhuma conta vinculada ao e-mail do autor do commit

+ 0
- 4
Marlin/src/Marlin.cpp Ver arquivo

204
   bool chdkActive; // = false;
204
   bool chdkActive; // = false;
205
 #endif
205
 #endif
206
 
206
 
207
-#if ENABLED(PID_EXTRUSION_SCALING)
208
-  int lpq_len = 20;
209
-#endif
210
-
211
 #if ENABLED(I2C_POSITION_ENCODERS)
207
 #if ENABLED(I2C_POSITION_ENCODERS)
212
   I2CPositionEncodersMgr I2CPEM;
208
   I2CPositionEncodersMgr I2CPEM;
213
 #endif
209
 #endif

+ 0
- 4
Marlin/src/Marlin.h Ver arquivo

207
   extern uint8_t controllerFanSpeed;
207
   extern uint8_t controllerFanSpeed;
208
 #endif
208
 #endif
209
 
209
 
210
-#if ENABLED(PID_EXTRUSION_SCALING)
211
-  extern int lpq_len;
212
-#endif
213
-
214
 #if HAS_POWER_SWITCH
210
 #if HAS_POWER_SWITCH
215
   extern bool powersupply_on;
211
   extern bool powersupply_on;
216
   #define PSU_PIN_ON()  do{ OUT_WRITE(PS_ON_PIN, PS_ON_AWAKE); powersupply_on = true; }while(0)
212
   #define PSU_PIN_ON()  do{ OUT_WRITE(PS_ON_PIN, PS_ON_AWAKE); powersupply_on = true; }while(0)

+ 4
- 3
Marlin/src/gcode/config/M301.cpp Ver arquivo

37
  * With PID_EXTRUSION_SCALING:
37
  * With PID_EXTRUSION_SCALING:
38
  *
38
  *
39
  *   C[float] Kc term
39
  *   C[float] Kc term
40
- *   L[float] LPQ length
40
+ *   L[int] LPQ length
41
  */
41
  */
42
 void GcodeSuite::M301() {
42
 void GcodeSuite::M301() {
43
 
43
 
51
     if (parser.seen('D')) PID_PARAM(Kd, e) = scalePID_d(parser.value_float());
51
     if (parser.seen('D')) PID_PARAM(Kd, e) = scalePID_d(parser.value_float());
52
     #if ENABLED(PID_EXTRUSION_SCALING)
52
     #if ENABLED(PID_EXTRUSION_SCALING)
53
       if (parser.seen('C')) PID_PARAM(Kc, e) = parser.value_float();
53
       if (parser.seen('C')) PID_PARAM(Kc, e) = parser.value_float();
54
-      if (parser.seen('L')) lpq_len = parser.value_float();
55
-      NOMORE(lpq_len, LPQ_MAX_LEN);
54
+      if (parser.seenval('L')) thermalManager.lpq_len = parser.value_int();
55
+      NOMORE(thermalManager.lpq_len, LPQ_MAX_LEN);
56
+      NOLESS(thermalManager.lpq_len, 0);
56
     #endif
57
     #endif
57
 
58
 
58
     thermalManager.updatePID();
59
     thermalManager.updatePID();

+ 12
- 8
Marlin/src/module/configuration_store.cpp Ver arquivo

88
   #include "../feature/pause.h"
88
   #include "../feature/pause.h"
89
 #endif
89
 #endif
90
 
90
 
91
+#if ENABLED(PID_EXTRUSION_SCALING)
92
+  #define LPQ_LEN thermalManager.lpq_len
93
+#endif
94
+
91
 #pragma pack(push, 1) // No padding between variables
95
 #pragma pack(push, 1) // No padding between variables
92
 
96
 
93
 typedef struct PID { float Kp, Ki, Kd; } PID;
97
 typedef struct PID { float Kp, Ki, Kd; } PID;
198
   //
202
   //
199
   PIDC hotendPID[MAX_EXTRUDERS];                        // M301 En PIDC / M303 En U
203
   PIDC hotendPID[MAX_EXTRUDERS];                        // M301 En PIDC / M303 En U
200
 
204
 
201
-  int lpq_len;                                          // M301 L
205
+  int16_t lpq_len;                                      // M301 L
202
 
206
 
203
   //
207
   //
204
   // PIDTEMPBED
208
   // PIDTEMPBED
594
     _FIELD_TEST(lpq_len);
598
     _FIELD_TEST(lpq_len);
595
 
599
 
596
     #if DISABLED(PID_EXTRUSION_SCALING)
600
     #if DISABLED(PID_EXTRUSION_SCALING)
597
-      int lpq_len = 20;
601
+      const int16_t LPQ_LEN = 20;
598
     #endif
602
     #endif
599
-    EEPROM_WRITE(lpq_len);
603
+    EEPROM_WRITE(LPQ_LEN);
600
 
604
 
601
     #if DISABLED(PIDTEMPBED)
605
     #if DISABLED(PIDTEMPBED)
602
       dummy = DUMMY_PID_VALUE;
606
       dummy = DUMMY_PID_VALUE;
1199
       _FIELD_TEST(lpq_len);
1203
       _FIELD_TEST(lpq_len);
1200
 
1204
 
1201
       #if DISABLED(PID_EXTRUSION_SCALING)
1205
       #if DISABLED(PID_EXTRUSION_SCALING)
1202
-        int lpq_len;
1206
+        int16_t LPQ_LEN;
1203
       #endif
1207
       #endif
1204
-      EEPROM_READ(lpq_len);
1208
+      EEPROM_READ(LPQ_LEN);
1205
 
1209
 
1206
       //
1210
       //
1207
       // Heated Bed PID
1211
       // Heated Bed PID
1812
       #endif
1816
       #endif
1813
     }
1817
     }
1814
     #if ENABLED(PID_EXTRUSION_SCALING)
1818
     #if ENABLED(PID_EXTRUSION_SCALING)
1815
-      lpq_len = 20; // default last-position-queue size
1819
+      thermalManager.lpq_len = 20; // default last-position-queue size
1816
     #endif
1820
     #endif
1817
   #endif // PIDTEMP
1821
   #endif // PIDTEMP
1818
 
1822
 
2288
               SERIAL_ECHOPAIR_P(port, " D", unscalePID_d(PID_PARAM(Kd, e)));
2292
               SERIAL_ECHOPAIR_P(port, " D", unscalePID_d(PID_PARAM(Kd, e)));
2289
               #if ENABLED(PID_EXTRUSION_SCALING)
2293
               #if ENABLED(PID_EXTRUSION_SCALING)
2290
                 SERIAL_ECHOPAIR_P(port, " C", PID_PARAM(Kc, e));
2294
                 SERIAL_ECHOPAIR_P(port, " C", PID_PARAM(Kc, e));
2291
-                if (e == 0) SERIAL_ECHOPAIR_P(port, " L", lpq_len);
2295
+                if (e == 0) SERIAL_ECHOPAIR_P(port, " L", thermalManager.lpq_len);
2292
               #endif
2296
               #endif
2293
               SERIAL_EOL_P(port);
2297
               SERIAL_EOL_P(port);
2294
             }
2298
             }
2303
           SERIAL_ECHOPAIR_P(port, " D", unscalePID_d(PID_PARAM(Kd, 0)));
2307
           SERIAL_ECHOPAIR_P(port, " D", unscalePID_d(PID_PARAM(Kd, 0)));
2304
           #if ENABLED(PID_EXTRUSION_SCALING)
2308
           #if ENABLED(PID_EXTRUSION_SCALING)
2305
             SERIAL_ECHOPAIR_P(port, " C", PID_PARAM(Kc, 0));
2309
             SERIAL_ECHOPAIR_P(port, " C", PID_PARAM(Kc, 0));
2306
-            SERIAL_ECHOPAIR_P(port, " L", lpq_len);
2310
+            SERIAL_ECHOPAIR_P(port, " L", thermalManager.lpq_len);
2307
           #endif
2311
           #endif
2308
           SERIAL_EOL_P(port);
2312
           SERIAL_EOL_P(port);
2309
         }
2313
         }

+ 4
- 0
Marlin/src/module/temperature.cpp Ver arquivo

244
   uint8_t Temperature::ADCKey_count = 0;
244
   uint8_t Temperature::ADCKey_count = 0;
245
 #endif
245
 #endif
246
 
246
 
247
+#if ENABLED(PID_EXTRUSION_SCALING)
248
+  int16_t Temperature::lpq_len; // Initialized in configuration_store
249
+#endif
250
+
247
 #if HAS_PID_HEATING
251
 #if HAS_PID_HEATING
248
 
252
 
249
   /**
253
   /**

+ 4
- 0
Marlin/src/module/temperature.h Ver arquivo

299
       static uint8_t ADCKey_count;
299
       static uint8_t ADCKey_count;
300
     #endif
300
     #endif
301
 
301
 
302
+    #if ENABLED(PID_EXTRUSION_SCALING)
303
+      static int16_t lpq_len;
304
+    #endif
305
+
302
     /**
306
     /**
303
      * Instance Methods
307
      * Instance Methods
304
      */
308
      */

Carregando…
Cancelar
Salvar