Browse Source

Fix M301 access to lpq_len (#10714)

Co-Authored-By: Zwaubel
Scott Lahteine 6 years ago
parent
commit
625035a9ce
No account linked to committer's email address

+ 0
- 4
Marlin/src/Marlin.cpp View File

@@ -204,10 +204,6 @@ millis_t max_inactive_time, // = 0
204 204
   bool chdkActive; // = false;
205 205
 #endif
206 206
 
207
-#if ENABLED(PID_EXTRUSION_SCALING)
208
-  int lpq_len = 20;
209
-#endif
210
-
211 207
 #if ENABLED(I2C_POSITION_ENCODERS)
212 208
   I2CPositionEncodersMgr I2CPEM;
213 209
 #endif

+ 0
- 4
Marlin/src/Marlin.h View File

@@ -207,10 +207,6 @@ extern millis_t max_inactive_time, stepper_inactive_time;
207 207
   extern uint8_t controllerFanSpeed;
208 208
 #endif
209 209
 
210
-#if ENABLED(PID_EXTRUSION_SCALING)
211
-  extern int lpq_len;
212
-#endif
213
-
214 210
 #if HAS_POWER_SWITCH
215 211
   extern bool powersupply_on;
216 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 View File

@@ -37,7 +37,7 @@
37 37
  * With PID_EXTRUSION_SCALING:
38 38
  *
39 39
  *   C[float] Kc term
40
- *   L[float] LPQ length
40
+ *   L[int] LPQ length
41 41
  */
42 42
 void GcodeSuite::M301() {
43 43
 
@@ -51,8 +51,9 @@ void GcodeSuite::M301() {
51 51
     if (parser.seen('D')) PID_PARAM(Kd, e) = scalePID_d(parser.value_float());
52 52
     #if ENABLED(PID_EXTRUSION_SCALING)
53 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 57
     #endif
57 58
 
58 59
     thermalManager.updatePID();

+ 12
- 8
Marlin/src/module/configuration_store.cpp View File

@@ -88,6 +88,10 @@
88 88
   #include "../feature/pause.h"
89 89
 #endif
90 90
 
91
+#if ENABLED(PID_EXTRUSION_SCALING)
92
+  #define LPQ_LEN thermalManager.lpq_len
93
+#endif
94
+
91 95
 #pragma pack(push, 1) // No padding between variables
92 96
 
93 97
 typedef struct PID { float Kp, Ki, Kd; } PID;
@@ -198,7 +202,7 @@ typedef struct SettingsDataStruct {
198 202
   //
199 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 208
   // PIDTEMPBED
@@ -594,9 +598,9 @@ void MarlinSettings::postprocess() {
594 598
     _FIELD_TEST(lpq_len);
595 599
 
596 600
     #if DISABLED(PID_EXTRUSION_SCALING)
597
-      int lpq_len = 20;
601
+      const int16_t LPQ_LEN = 20;
598 602
     #endif
599
-    EEPROM_WRITE(lpq_len);
603
+    EEPROM_WRITE(LPQ_LEN);
600 604
 
601 605
     #if DISABLED(PIDTEMPBED)
602 606
       dummy = DUMMY_PID_VALUE;
@@ -1199,9 +1203,9 @@ void MarlinSettings::postprocess() {
1199 1203
       _FIELD_TEST(lpq_len);
1200 1204
 
1201 1205
       #if DISABLED(PID_EXTRUSION_SCALING)
1202
-        int lpq_len;
1206
+        int16_t LPQ_LEN;
1203 1207
       #endif
1204
-      EEPROM_READ(lpq_len);
1208
+      EEPROM_READ(LPQ_LEN);
1205 1209
 
1206 1210
       //
1207 1211
       // Heated Bed PID
@@ -1812,7 +1816,7 @@ void MarlinSettings::reset(PORTARG_SOLO) {
1812 1816
       #endif
1813 1817
     }
1814 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 1820
     #endif
1817 1821
   #endif // PIDTEMP
1818 1822
 
@@ -2288,7 +2292,7 @@ void MarlinSettings::reset(PORTARG_SOLO) {
2288 2292
               SERIAL_ECHOPAIR_P(port, " D", unscalePID_d(PID_PARAM(Kd, e)));
2289 2293
               #if ENABLED(PID_EXTRUSION_SCALING)
2290 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 2296
               #endif
2293 2297
               SERIAL_EOL_P(port);
2294 2298
             }
@@ -2303,7 +2307,7 @@ void MarlinSettings::reset(PORTARG_SOLO) {
2303 2307
           SERIAL_ECHOPAIR_P(port, " D", unscalePID_d(PID_PARAM(Kd, 0)));
2304 2308
           #if ENABLED(PID_EXTRUSION_SCALING)
2305 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 2311
           #endif
2308 2312
           SERIAL_EOL_P(port);
2309 2313
         }

+ 4
- 0
Marlin/src/module/temperature.cpp View File

@@ -244,6 +244,10 @@ uint8_t Temperature::soft_pwm_amount[HOTENDS];
244 244
   uint8_t Temperature::ADCKey_count = 0;
245 245
 #endif
246 246
 
247
+#if ENABLED(PID_EXTRUSION_SCALING)
248
+  int16_t Temperature::lpq_len; // Initialized in configuration_store
249
+#endif
250
+
247 251
 #if HAS_PID_HEATING
248 252
 
249 253
   /**

+ 4
- 0
Marlin/src/module/temperature.h View File

@@ -299,6 +299,10 @@ class Temperature {
299 299
       static uint8_t ADCKey_count;
300 300
     #endif
301 301
 
302
+    #if ENABLED(PID_EXTRUSION_SCALING)
303
+      static int16_t lpq_len;
304
+    #endif
305
+
302 306
     /**
303 307
      * Instance Methods
304 308
      */

Loading…
Cancel
Save