Просмотр исходного кода

🎨 Combine M104/M109 and M140/M190 code

Scott Lahteine 4 лет назад
Родитель
Сommit
aee971bcaf
3 измененных файлов: 27 добавлений и 118 удалений
  1. 6
    4
      Marlin/src/gcode/gcode.h
  2. 9
    69
      Marlin/src/gcode/temp/M104_M109.cpp
  3. 12
    45
      Marlin/src/gcode/temp/M140_M190.cpp

+ 6
- 4
Marlin/src/gcode/gcode.h Просмотреть файл

648
   #endif
648
   #endif
649
 
649
 
650
   #if HAS_EXTRUDERS
650
   #if HAS_EXTRUDERS
651
-    static void M104();
652
-    static void M109();
651
+    static void M104_M109(const bool isM109);
652
+    FORCE_INLINE static void M104() { M104_M109(false); }
653
+    FORCE_INLINE static void M109() { M104_M109(true); }
653
   #endif
654
   #endif
654
 
655
 
655
   static void M105();
656
   static void M105();
699
   #endif
700
   #endif
700
 
701
 
701
   #if HAS_HEATED_BED
702
   #if HAS_HEATED_BED
702
-    static void M140();
703
-    static void M190();
703
+    static void M140_M190(const bool isM190);
704
+    FORCE_INLINE static void M140() { M140_M190(false); }
705
+    FORCE_INLINE static void M190() { M140_M190(true); }
704
   #endif
706
   #endif
705
 
707
 
706
   #if HAS_HEATED_CHAMBER
708
   #if HAS_HEATED_CHAMBER

+ 9
- 69
Marlin/src/gcode/temp/M104_M109.cpp Просмотреть файл

51
 
51
 
52
 /**
52
 /**
53
  * M104: Set Hotend Temperature target and return immediately
53
  * M104: Set Hotend Temperature target and return immediately
54
- *
55
- * Parameters:
56
- *  I<preset> : Material Preset index (if material presets are defined)
57
- *  T<index>  : Tool index. If omitted, applies to the active tool
58
- *  S<target> : The target temperature in current units
59
- */
60
-void GcodeSuite::M104() {
61
-
62
-  if (DEBUGGING(DRYRUN)) return;
63
-
64
-  #if ENABLED(MIXING_EXTRUDER) && MIXING_VIRTUAL_TOOLS > 1
65
-    constexpr int8_t target_extruder = 0;
66
-  #else
67
-    const int8_t target_extruder = get_target_extruder_from_command();
68
-    if (target_extruder < 0) return;
69
-  #endif
70
-
71
-  bool got_temp = false;
72
-  celsius_t temp = 0;
73
-
74
-  // Accept 'I' if temperature presets are defined
75
-  #if PREHEAT_COUNT
76
-    got_temp = parser.seenval('I');
77
-    if (got_temp) {
78
-      const uint8_t index = parser.value_byte();
79
-      temp = ui.material_preset[_MIN(index, PREHEAT_COUNT - 1)].hotend_temp;
80
-    }
81
-  #endif
82
-
83
-  // If no 'I' get the temperature from 'S'
84
-  if (!got_temp) {
85
-    got_temp = parser.seenval('S');
86
-    if (got_temp) temp = parser.value_celsius();
87
-  }
88
-
89
-  if (got_temp) {
90
-    #if ENABLED(SINGLENOZZLE_STANDBY_TEMP)
91
-      thermalManager.singlenozzle_temp[target_extruder] = temp;
92
-      if (target_extruder != active_extruder) return;
93
-    #endif
94
-    thermalManager.setTargetHotend(temp, target_extruder);
95
-
96
-    #if ENABLED(DUAL_X_CARRIAGE)
97
-      if (idex_is_duplicating() && target_extruder == 0)
98
-        thermalManager.setTargetHotend(temp ? temp + duplicate_extruder_temp_offset : 0, 1);
99
-    #endif
100
-
101
-    #if ENABLED(PRINTJOB_TIMER_AUTOSTART)
102
-      /**
103
-       * Stop the timer at the end of print. Start is managed by 'heat and wait' M109.
104
-       * Hotends use EXTRUDE_MINTEMP / 2 to allow nozzles to be put into hot standby
105
-       * mode, for instance in a dual extruder setup, without affecting the running
106
-       * print timer.
107
-       */
108
-      thermalManager.auto_job_check_timer(false, true);
109
-    #endif
110
-  }
111
-
112
-  TERN_(AUTOTEMP, planner.autotemp_M104_M109());
113
-}
114
-
115
-/**
116
  * M109: Set Hotend Temperature target and wait
54
  * M109: Set Hotend Temperature target and wait
117
  *
55
  *
118
  * Parameters
56
  * Parameters
119
  *  I<preset> : Material Preset index (if material presets are defined)
57
  *  I<preset> : Material Preset index (if material presets are defined)
120
  *  T<index>  : Tool index. If omitted, applies to the active tool
58
  *  T<index>  : Tool index. If omitted, applies to the active tool
121
- *  S<target> : The target temperature in current units. Wait for heating only.
122
- *  R<target> : The target temperature in current units. Wait for heating and cooling.
59
+ *  S<target> : The target temperature in current units. For M109, only wait when heating up.
123
  *
60
  *
124
  * With AUTOTEMP...
61
  * With AUTOTEMP...
125
  *  F<factor> : Autotemp Scaling Factor. Set non-zero to enable Auto-temp.
62
  *  F<factor> : Autotemp Scaling Factor. Set non-zero to enable Auto-temp.
126
  *  S<min>    : Minimum temperature, in current units.
63
  *  S<min>    : Minimum temperature, in current units.
127
  *  B<max>    : Maximum temperature, in current units.
64
  *  B<max>    : Maximum temperature, in current units.
128
  *
65
  *
66
+ * M109 Parameters
67
+ *  R<target> : The target temperature in current units. Wait for heating and cooling.
68
+ *
129
  * Examples
69
  * Examples
130
- *  M109 S100 : Set target to 100°. Wait until the hotend is at or above 100°.
70
+ *  M104 S100 : Set target to 100° and return.
131
  *  M109 R150 : Set target to 150°. Wait until the hotend gets close to 150°.
71
  *  M109 R150 : Set target to 150°. Wait until the hotend gets close to 150°.
132
  *
72
  *
133
  * With PRINTJOB_TIMER_AUTOSTART turning on heaters will start the print job timer
73
  * With PRINTJOB_TIMER_AUTOSTART turning on heaters will start the print job timer
134
  *  (used by printingIsActive, etc.) and turning off heaters will stop the timer.
74
  *  (used by printingIsActive, etc.) and turning off heaters will stop the timer.
135
  */
75
  */
136
-void GcodeSuite::M109() {
76
+void GcodeSuite::M104_M109(const bool isM109) {
137
 
77
 
138
   if (DEBUGGING(DRYRUN)) return;
78
   if (DEBUGGING(DRYRUN)) return;
139
 
79
 
160
   bool no_wait_for_cooling = false;
100
   bool no_wait_for_cooling = false;
161
   if (!got_temp) {
101
   if (!got_temp) {
162
     no_wait_for_cooling = parser.seenval('S');
102
     no_wait_for_cooling = parser.seenval('S');
163
-    got_temp = no_wait_for_cooling || parser.seenval('R');
103
+    got_temp = no_wait_for_cooling || (isM109 && parser.seenval('R'));
164
     if (got_temp) temp = parser.value_celsius();
104
     if (got_temp) temp = parser.value_celsius();
165
   }
105
   }
166
 
106
 
182
        * standby mode, (e.g., in a dual extruder setup) without affecting
122
        * standby mode, (e.g., in a dual extruder setup) without affecting
183
        * the running print timer.
123
        * the running print timer.
184
        */
124
        */
185
-      thermalManager.auto_job_check_timer(true, true);
125
+      thermalManager.auto_job_check_timer(isM109, true);
186
     #endif
126
     #endif
187
 
127
 
188
     #if HAS_STATUS_MESSAGE
128
     #if HAS_STATUS_MESSAGE
193
 
133
 
194
   TERN_(AUTOTEMP, planner.autotemp_M104_M109());
134
   TERN_(AUTOTEMP, planner.autotemp_M104_M109());
195
 
135
 
196
-  if (got_temp)
136
+  if (isM109 && got_temp)
197
     (void)thermalManager.wait_for_hotend(target_extruder, no_wait_for_cooling);
137
     (void)thermalManager.wait_for_hotend(target_extruder, no_wait_for_cooling);
198
 }
138
 }
199
 
139
 

+ 12
- 45
Marlin/src/gcode/temp/M140_M190.cpp Просмотреть файл

35
 #include "../../lcd/marlinui.h"
35
 #include "../../lcd/marlinui.h"
36
 
36
 
37
 /**
37
 /**
38
- * M140: Set bed temperature
38
+ * M140 - Set Bed Temperature target and return immediately
39
+ * M190 - Set Bed Temperature target and wait
39
  *
40
  *
40
  *  I<index>  : Preset index (if material presets are defined)
41
  *  I<index>  : Preset index (if material presets are defined)
41
  *  S<target> : The target temperature in current units
42
  *  S<target> : The target temperature in current units
42
- */
43
-void GcodeSuite::M140() {
44
-  if (DEBUGGING(DRYRUN)) return;
45
-
46
-  bool got_temp = false;
47
-  celsius_t temp = 0;
48
-
49
-  // Accept 'I' if temperature presets are defined
50
-  #if PREHEAT_COUNT
51
-    got_temp = parser.seenval('I');
52
-    if (got_temp) {
53
-      const uint8_t index = parser.value_byte();
54
-      temp = ui.material_preset[_MIN(index, PREHEAT_COUNT - 1)].bed_temp;
55
-    }
56
-  #endif
57
-
58
-  // If no 'I' get the temperature from 'S'
59
-  if (!got_temp) {
60
-    got_temp = parser.seenval('S');
61
-    if (got_temp) temp = parser.value_celsius();
62
-  }
63
-
64
-  if (got_temp) {
65
-    thermalManager.setTargetBed(temp);
66
-
67
-    #if ENABLED(PRINTJOB_TIMER_AUTOSTART)
68
-      /**
69
-       * Stop the timer at the end of print. Hotend, bed target, and chamber
70
-       * temperatures need to be set below mintemp. Order of M140, M104, and M141
71
-       * at the end of the print does not matter.
72
-       */
73
-      thermalManager.auto_job_check_timer(false, true);
74
-    #endif
75
-  }
76
-}
77
-
78
-/**
79
- * M190 - Set Bed Temperature target and wait
80
  *
43
  *
81
- * Parameters:
44
+ * Parameters
82
  *  I<index>  : Preset index (if material presets are defined)
45
  *  I<index>  : Preset index (if material presets are defined)
83
  *  S<target> : The target temperature in current units. Wait for heating only.
46
  *  S<target> : The target temperature in current units. Wait for heating only.
47
+ *
48
+ * M190 Parameters
84
  *  R<target> : The target temperature in current units. Wait for heating and cooling.
49
  *  R<target> : The target temperature in current units. Wait for heating and cooling.
85
  *
50
  *
86
- * Examples:
87
- *  M190 S60 : Set target to 60°. Wait until the bed is at or above 60°.
51
+ * Examples
52
+ *  M140 S60 : Set target to 60° and return right away.
88
  *  M190 R40 : Set target to 40°. Wait until the bed gets close to 40°.
53
  *  M190 R40 : Set target to 40°. Wait until the bed gets close to 40°.
89
  *
54
  *
90
  * With PRINTJOB_TIMER_AUTOSTART turning on heaters will start the print job timer
55
  * With PRINTJOB_TIMER_AUTOSTART turning on heaters will start the print job timer
91
  *  (used by printingIsActive, etc.) and turning off heaters will stop the timer.
56
  *  (used by printingIsActive, etc.) and turning off heaters will stop the timer.
92
  */
57
  */
93
-void GcodeSuite::M190() {
58
+void GcodeSuite::M140_M190(const bool isM190) {
59
+
94
   if (DEBUGGING(DRYRUN)) return;
60
   if (DEBUGGING(DRYRUN)) return;
95
 
61
 
96
   bool got_temp = false;
62
   bool got_temp = false;
109
   bool no_wait_for_cooling = false;
75
   bool no_wait_for_cooling = false;
110
   if (!got_temp) {
76
   if (!got_temp) {
111
     no_wait_for_cooling = parser.seenval('S');
77
     no_wait_for_cooling = parser.seenval('S');
112
-    got_temp = no_wait_for_cooling || parser.seenval('R');
78
+    got_temp = no_wait_for_cooling || (isM190 && parser.seenval('R'));
113
     if (got_temp) temp = parser.value_celsius();
79
     if (got_temp) temp = parser.value_celsius();
114
   }
80
   }
115
 
81
 
121
 
87
 
122
   ui.set_status_P(thermalManager.isHeatingBed() ? GET_TEXT(MSG_BED_HEATING) : GET_TEXT(MSG_BED_COOLING));
88
   ui.set_status_P(thermalManager.isHeatingBed() ? GET_TEXT(MSG_BED_HEATING) : GET_TEXT(MSG_BED_COOLING));
123
 
89
 
124
-  thermalManager.wait_for_bed(no_wait_for_cooling);
90
+  if (isM190)
91
+    thermalManager.wait_for_bed(no_wait_for_cooling);
125
 }
92
 }
126
 
93
 
127
 #endif // HAS_HEATED_BED
94
 #endif // HAS_HEATED_BED

Загрузка…
Отмена
Сохранить