Browse Source

setTargetedHotend => get_target_extruder_from_command

Scott Lahteine 8 years ago
parent
commit
39ee9c526b
1 changed files with 30 additions and 29 deletions
  1. 30
    29
      Marlin/Marlin_main.cpp

+ 30
- 29
Marlin/Marlin_main.cpp View File

@@ -496,8 +496,6 @@ void process_next_command();
496 496
 
497 497
 void plan_arc(float target[NUM_AXIS], float* offset, uint8_t clockwise);
498 498
 
499
-bool setTargetedHotend(int code);
500
-
501 499
 void serial_echopair_P(const char* s_P, int v)           { serialprintPGM(s_P); SERIAL_ECHO(v); }
502 500
 void serial_echopair_P(const char* s_P, long v)          { serialprintPGM(s_P); SERIAL_ECHO(v); }
503 501
 void serial_echopair_P(const char* s_P, float v)         { serialprintPGM(s_P); SERIAL_ECHO(v); }
@@ -1161,6 +1159,30 @@ bool code_seen(char code) {
1161 1159
   return (seen_pointer != NULL); // Return TRUE if the code-letter was found
1162 1160
 }
1163 1161
 
1162
+/**
1163
+ * Set target_extruder from the T parameter or the active_extruder
1164
+ *
1165
+ * Returns TRUE if the target is invalid
1166
+ */
1167
+bool get_target_extruder_from_command(int code) {
1168
+  if (code_seen('T')) {
1169
+    short t = code_value_short();
1170
+    if (t >= EXTRUDERS) {
1171
+      SERIAL_ECHO_START;
1172
+      SERIAL_CHAR('M');
1173
+      SERIAL_ECHO(code);
1174
+      SERIAL_ECHOPAIR(" " MSG_INVALID_EXTRUDER " ", t);
1175
+      SERIAL_EOL;
1176
+      return true;
1177
+    }
1178
+    target_extruder = t;
1179
+  }
1180
+  else
1181
+    target_extruder = active_extruder;
1182
+
1183
+  return false;
1184
+}
1185
+
1164 1186
 #define DEFINE_PGM_READ_ANY(type, reader)       \
1165 1187
   static inline type pgm_read_any(const type *p)  \
1166 1188
   { return pgm_read_##reader##_near(p); }
@@ -4233,7 +4255,7 @@ inline void gcode_M77() {
4233 4255
  * M104: Set hot end temperature
4234 4256
  */
4235 4257
 inline void gcode_M104() {
4236
-  if (setTargetedHotend(104)) return;
4258
+  if (get_target_extruder_from_command(104)) return;
4237 4259
   if (DEBUGGING(DRYRUN)) return;
4238 4260
 
4239 4261
   if (code_seen('S')) {
@@ -4341,7 +4363,7 @@ inline void gcode_M104() {
4341 4363
  * M105: Read hot end and bed temperature
4342 4364
  */
4343 4365
 inline void gcode_M105() {
4344
-  if (setTargetedHotend(105)) return;
4366
+  if (get_target_extruder_from_command(105)) return;
4345 4367
 
4346 4368
   #if HAS_TEMP_HOTEND || HAS_TEMP_BED
4347 4369
     SERIAL_PROTOCOLPGM(MSG_OK);
@@ -4385,7 +4407,7 @@ inline void gcode_M105() {
4385 4407
  */
4386 4408
 inline void gcode_M109() {
4387 4409
 
4388
-  if (setTargetedHotend(109)) return;
4410
+  if (get_target_extruder_from_command(109)) return;
4389 4411
   if (DEBUGGING(DRYRUN)) return;
4390 4412
 
4391 4413
   bool no_wait_for_cooling = code_seen('S');
@@ -5052,7 +5074,7 @@ inline void gcode_M121() { enable_endstops_globally(false); }
5052 5074
  */
5053 5075
 inline void gcode_M200() {
5054 5076
 
5055
-  if (setTargetedHotend(200)) return;
5077
+  if (get_target_extruder_from_command(200)) return;
5056 5078
 
5057 5079
   if (code_seen('D')) {
5058 5080
     float diameter = code_value();
@@ -5304,7 +5326,7 @@ inline void gcode_M206() {
5304 5326
    *   Z<zoffset> - Available with DUAL_X_CARRIAGE
5305 5327
    */
5306 5328
   inline void gcode_M218() {
5307
-    if (setTargetedHotend(218)) return;
5329
+    if (get_target_extruder_from_command(218)) return;
5308 5330
 
5309 5331
     if (code_seen('X')) extruder_offset[X_AXIS][target_extruder] = code_value();
5310 5332
     if (code_seen('Y')) extruder_offset[Y_AXIS][target_extruder] = code_value();
@@ -5343,7 +5365,7 @@ inline void gcode_M220() {
5343 5365
 inline void gcode_M221() {
5344 5366
   if (code_seen('S')) {
5345 5367
     int sval = code_value();
5346
-    if (setTargetedHotend(221)) return;
5368
+    if (get_target_extruder_from_command(221)) return;
5347 5369
     extruder_multiplier[target_extruder] = sval;
5348 5370
   }
5349 5371
 }
@@ -8006,27 +8028,6 @@ void Stop() {
8006 8028
   }
8007 8029
 }
8008 8030
 
8009
-/**
8010
- * Set target_extruder from the T parameter or the active_extruder
8011
- *
8012
- * Returns TRUE if the target is invalid
8013
- */
8014
-bool setTargetedHotend(int code) {
8015
-  target_extruder = active_extruder;
8016
-  if (code_seen('T')) {
8017
-    target_extruder = code_value_short();
8018
-    if (target_extruder >= EXTRUDERS) {
8019
-      SERIAL_ECHO_START;
8020
-      SERIAL_CHAR('M');
8021
-      SERIAL_ECHO(code);
8022
-      SERIAL_ECHOPGM(" " MSG_INVALID_EXTRUDER " ");
8023
-      SERIAL_ECHOLN((int)target_extruder);
8024
-      return true;
8025
-    }
8026
-  }
8027
-  return false;
8028
-}
8029
-
8030 8031
 float calculate_volumetric_multiplier(float diameter) {
8031 8032
   if (!volumetric_enabled || diameter == 0) return 1.0;
8032 8033
   float d2 = diameter * 0.5;

Loading…
Cancel
Save