Browse Source

Add "P" parameter to M302

Scott Lahteine 8 years ago
parent
commit
d4c68279c8
3 changed files with 31 additions and 3 deletions
  1. 28
    2
      Marlin/Marlin_main.cpp
  2. 1
    0
      Marlin/temperature.cpp
  3. 2
    1
      Marlin/temperature.h

+ 28
- 2
Marlin/Marlin_main.cpp View File

@@ -5703,10 +5703,36 @@ inline void gcode_M226() {
5703 5703
 #if ENABLED(PREVENT_DANGEROUS_EXTRUDE)
5704 5704
 
5705 5705
   /**
5706
-   * M302: Allow cold extrudes, or set the minimum extrude S<temperature>.
5706
+   * M302: Allow cold extrudes, or set the minimum extrude temperature
5707
+   *
5708
+   *       S<temperature> sets the minimum extrude temperature
5709
+   *       P<bool> enables (1) or disables (0) cold extrusion
5710
+   *
5711
+   *  Examples:
5712
+   *
5713
+   *       M302         ; report current cold extrusion state
5714
+   *       M302 P0      ; enable cold extrusion checking
5715
+   *       M302 P1      ; disables cold extrusion checking
5716
+   *       M302 S0      ; always allow extrusion (disables checking)
5717
+   *       M302 S170    ; only allow extrusion above 170
5718
+   *       M302 S170 P1 ; set min extrude temp to 170 but leave disabled
5707 5719
    */
5708 5720
   inline void gcode_M302() {
5709
-    thermalManager.extrude_min_temp = code_seen('S') ? code_value_temp_abs() : 0;
5721
+    bool seen_S = code_seen('S');
5722
+    if (seen_S) {
5723
+      thermalManager.extrude_min_temp = code_value_temp_abs();
5724
+      thermalManager.allow_cold_extrude = (thermalManager.extrude_min_temp == 0);
5725
+    }
5726
+
5727
+    if (code_seen('P'))
5728
+      thermalManager.allow_cold_extrude = (thermalManager.extrude_min_temp == 0) || code_value_bool();
5729
+    else if (!seen_S) {
5730
+      // Report current state
5731
+      SERIAL_ECHO_START;
5732
+      SERIAL_ECHOPAIR("Cold extrudes are ", (thermalManager.allow_cold_extrude ? "en" : "dis"));
5733
+      SERIAL_ECHOPAIR("abled (min temp ", int(thermalManager.extrude_min_temp + 0.5));
5734
+      SERIAL_ECHOLNPGM("C)");
5735
+    }
5710 5736
   }
5711 5737
 
5712 5738
 #endif // PREVENT_DANGEROUS_EXTRUDE

+ 1
- 0
Marlin/temperature.cpp View File

@@ -107,6 +107,7 @@ unsigned char Temperature::soft_pwm_bed;
107 107
 #endif
108 108
 
109 109
 #if ENABLED(PREVENT_DANGEROUS_EXTRUDE)
110
+  bool Temperature::allow_cold_extrude = false;
110 111
   float Temperature::extrude_min_temp = EXTRUDE_MINTEMP;
111 112
 #endif
112 113
 

+ 2
- 1
Marlin/temperature.h View File

@@ -121,12 +121,13 @@ class Temperature {
121 121
     #endif
122 122
 
123 123
     #if ENABLED(PREVENT_DANGEROUS_EXTRUDE)
124
+      static bool allow_cold_extrude;
124 125
       static float extrude_min_temp;
125 126
       static bool tooColdToExtrude(uint8_t e) {
126 127
         #if HOTENDS == 1
127 128
           UNUSED(e);
128 129
         #endif
129
-        return degHotend(HOTEND_INDEX) < extrude_min_temp;
130
+        return allow_cold_extrude ? false : degHotend(HOTEND_INDEX) < extrude_min_temp;
130 131
       }
131 132
     #else
132 133
       static bool tooColdToExtrude(uint8_t e) { UNUSED(e); return false; }

Loading…
Cancel
Save