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
 
496
 
497
 void plan_arc(float target[NUM_AXIS], float* offset, uint8_t clockwise);
497
 void plan_arc(float target[NUM_AXIS], float* offset, uint8_t clockwise);
498
 
498
 
499
-bool setTargetedHotend(int code);
500
-
501
 void serial_echopair_P(const char* s_P, int v)           { serialprintPGM(s_P); SERIAL_ECHO(v); }
499
 void serial_echopair_P(const char* s_P, int v)           { serialprintPGM(s_P); SERIAL_ECHO(v); }
502
 void serial_echopair_P(const char* s_P, long v)          { serialprintPGM(s_P); SERIAL_ECHO(v); }
500
 void serial_echopair_P(const char* s_P, long v)          { serialprintPGM(s_P); SERIAL_ECHO(v); }
503
 void serial_echopair_P(const char* s_P, float v)         { serialprintPGM(s_P); SERIAL_ECHO(v); }
501
 void serial_echopair_P(const char* s_P, float v)         { serialprintPGM(s_P); SERIAL_ECHO(v); }
1161
   return (seen_pointer != NULL); // Return TRUE if the code-letter was found
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
 #define DEFINE_PGM_READ_ANY(type, reader)       \
1186
 #define DEFINE_PGM_READ_ANY(type, reader)       \
1165
   static inline type pgm_read_any(const type *p)  \
1187
   static inline type pgm_read_any(const type *p)  \
1166
   { return pgm_read_##reader##_near(p); }
1188
   { return pgm_read_##reader##_near(p); }
4233
  * M104: Set hot end temperature
4255
  * M104: Set hot end temperature
4234
  */
4256
  */
4235
 inline void gcode_M104() {
4257
 inline void gcode_M104() {
4236
-  if (setTargetedHotend(104)) return;
4258
+  if (get_target_extruder_from_command(104)) return;
4237
   if (DEBUGGING(DRYRUN)) return;
4259
   if (DEBUGGING(DRYRUN)) return;
4238
 
4260
 
4239
   if (code_seen('S')) {
4261
   if (code_seen('S')) {
4341
  * M105: Read hot end and bed temperature
4363
  * M105: Read hot end and bed temperature
4342
  */
4364
  */
4343
 inline void gcode_M105() {
4365
 inline void gcode_M105() {
4344
-  if (setTargetedHotend(105)) return;
4366
+  if (get_target_extruder_from_command(105)) return;
4345
 
4367
 
4346
   #if HAS_TEMP_HOTEND || HAS_TEMP_BED
4368
   #if HAS_TEMP_HOTEND || HAS_TEMP_BED
4347
     SERIAL_PROTOCOLPGM(MSG_OK);
4369
     SERIAL_PROTOCOLPGM(MSG_OK);
4385
  */
4407
  */
4386
 inline void gcode_M109() {
4408
 inline void gcode_M109() {
4387
 
4409
 
4388
-  if (setTargetedHotend(109)) return;
4410
+  if (get_target_extruder_from_command(109)) return;
4389
   if (DEBUGGING(DRYRUN)) return;
4411
   if (DEBUGGING(DRYRUN)) return;
4390
 
4412
 
4391
   bool no_wait_for_cooling = code_seen('S');
4413
   bool no_wait_for_cooling = code_seen('S');
5052
  */
5074
  */
5053
 inline void gcode_M200() {
5075
 inline void gcode_M200() {
5054
 
5076
 
5055
-  if (setTargetedHotend(200)) return;
5077
+  if (get_target_extruder_from_command(200)) return;
5056
 
5078
 
5057
   if (code_seen('D')) {
5079
   if (code_seen('D')) {
5058
     float diameter = code_value();
5080
     float diameter = code_value();
5304
    *   Z<zoffset> - Available with DUAL_X_CARRIAGE
5326
    *   Z<zoffset> - Available with DUAL_X_CARRIAGE
5305
    */
5327
    */
5306
   inline void gcode_M218() {
5328
   inline void gcode_M218() {
5307
-    if (setTargetedHotend(218)) return;
5329
+    if (get_target_extruder_from_command(218)) return;
5308
 
5330
 
5309
     if (code_seen('X')) extruder_offset[X_AXIS][target_extruder] = code_value();
5331
     if (code_seen('X')) extruder_offset[X_AXIS][target_extruder] = code_value();
5310
     if (code_seen('Y')) extruder_offset[Y_AXIS][target_extruder] = code_value();
5332
     if (code_seen('Y')) extruder_offset[Y_AXIS][target_extruder] = code_value();
5343
 inline void gcode_M221() {
5365
 inline void gcode_M221() {
5344
   if (code_seen('S')) {
5366
   if (code_seen('S')) {
5345
     int sval = code_value();
5367
     int sval = code_value();
5346
-    if (setTargetedHotend(221)) return;
5368
+    if (get_target_extruder_from_command(221)) return;
5347
     extruder_multiplier[target_extruder] = sval;
5369
     extruder_multiplier[target_extruder] = sval;
5348
   }
5370
   }
5349
 }
5371
 }
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
 float calculate_volumetric_multiplier(float diameter) {
8031
 float calculate_volumetric_multiplier(float diameter) {
8031
   if (!volumetric_enabled || diameter == 0) return 1.0;
8032
   if (!volumetric_enabled || diameter == 0) return 1.0;
8032
   float d2 = diameter * 0.5;
8033
   float d2 = diameter * 0.5;

Loading…
Cancel
Save