Ver código fonte

Add sanity checks to Linear Advance 1.5 (#9873)

Scott Lahteine 7 anos atrás
pai
commit
118899357d
Nenhuma conta vinculada ao e-mail do autor do commit

+ 12
- 7
Marlin/src/gcode/feature/advance/M900.cpp Ver arquivo

34
  *  K<factor>                  Set advance K factor
34
  *  K<factor>                  Set advance K factor
35
  */
35
  */
36
 void GcodeSuite::M900() {
36
 void GcodeSuite::M900() {
37
-    stepper.synchronize();
38
-
39
-    const float newK = parser.floatval('K', -1);
40
-    if (newK >= 0) planner.extruder_advance_K = newK;
41
-
37
+  if (parser.seenval('K')) {
38
+    const float newK = parser.floatval('K');
39
+    if (WITHIN(newK, 0, 10)) {
40
+      stepper.synchronize();
41
+      planner.extruder_advance_K = newK;
42
+    }
43
+    else
44
+      SERIAL_PROTOCOLLNPGM("?K value out of range (0-10).");
45
+  }
46
+  else {
42
     SERIAL_ECHO_START();
47
     SERIAL_ECHO_START();
43
-    SERIAL_ECHOPAIR("Advance K=", planner.extruder_advance_K);
44
-    SERIAL_EOL();
48
+    SERIAL_ECHOLNPAIR("Advance K=", planner.extruder_advance_K);
49
+  }
45
 }
50
 }
46
 
51
 
47
 #endif // LIN_ADVANCE
52
 #endif // LIN_ADVANCE

+ 10
- 0
Marlin/src/inc/SanityCheck.h Ver arquivo

555
 #endif
555
 #endif
556
 
556
 
557
 /**
557
 /**
558
+ * Linear Advance 1.5 - Check K value range
559
+ */
560
+#if ENABLED(LIN_ADVANCE)
561
+  static_assert(
562
+    WITHIN(LIN_ADVANCE_K, 0, 10),
563
+    "LIN_ADVANCE_K must be a value from 0 to 10 (Changed in LIN_ADVANCE v1.5, Marlin 1.1.9)."
564
+  );
565
+#endif
566
+
567
+/**
558
  * Parking Extruder requirements
568
  * Parking Extruder requirements
559
  */
569
  */
560
 #if ENABLED(PARKING_EXTRUDER)
570
 #if ENABLED(PARKING_EXTRUDER)

Carregando…
Cancelar
Salvar