Browse Source

Redo "invalid extruder" to save 264 bytes

- Use `setTargetedHotend` in `M200`, as with other commands that use
`T` for the extruder
- Synthesize the "invalid extruder" message, obviating several long
strings
Scott Lahteine 10 years ago
parent
commit
06f401e7e5
3 changed files with 15 additions and 38 deletions
  1. 15
    26
      Marlin/Marlin_main.cpp
  2. 0
    6
      Marlin/configurator/config/language.h
  3. 0
    6
      Marlin/language.h

+ 15
- 26
Marlin/Marlin_main.cpp View File

@@ -3938,20 +3938,14 @@ inline void gcode_M121() { enable_endstops(false); }
3938 3938
 #endif // BLINKM
3939 3939
 
3940 3940
 /**
3941
- * M200: Set filament diameter and set E axis units to cubic millimeters (use S0 to set back to millimeters).
3942
- *       T<extruder>
3943
- *       D<millimeters>
3941
+ * M200: Set filament diameter and set E axis units to cubic millimeters
3942
+ *
3943
+ *    T<extruder> - Optional extruder number. Current extruder if omitted.
3944
+ *    D<mm> - Diameter of the filament. Use "D0" to set units back to millimeters.
3944 3945
  */
3945 3946
 inline void gcode_M200() {
3946
-  int tmp_extruder = active_extruder;
3947
-  if (code_seen('T')) {
3948
-    tmp_extruder = code_value_short();
3949
-    if (tmp_extruder >= EXTRUDERS) {
3950
-      SERIAL_ECHO_START;
3951
-      SERIAL_ECHO(MSG_M200_INVALID_EXTRUDER);
3952
-      return;
3953
-    }
3954
-  }
3947
+
3948
+  if (setTargetedHotend(200)) return;
3955 3949
 
3956 3950
   if (code_seen('D')) {
3957 3951
     float diameter = code_value();
@@ -3960,7 +3954,7 @@ inline void gcode_M200() {
3960 3954
     // for all extruders
3961 3955
     volumetric_enabled = (diameter != 0.0);
3962 3956
     if (volumetric_enabled) {
3963
-      filament_size[tmp_extruder] = diameter;
3957
+      filament_size[target_extruder] = diameter;
3964 3958
       // make sure all extruders have some sane value for the filament size
3965 3959
       for (int i=0; i<EXTRUDERS; i++)
3966 3960
         if (! filament_size[i]) filament_size[i] = DEFAULT_NOMINAL_FILAMENT_DIA;
@@ -6524,30 +6518,25 @@ void Stop() {
6524 6518
   }
6525 6519
 }
6526 6520
 
6527
-bool setTargetedHotend(int code){
6521
+bool setTargetedHotend(int code) {
6528 6522
   target_extruder = active_extruder;
6529 6523
   if (code_seen('T')) {
6530 6524
     target_extruder = code_value_short();
6531 6525
     if (target_extruder >= EXTRUDERS) {
6532
-      SERIAL_ECHO_START;
6533
-      switch(code){
6526
+      switch(code) {
6534 6527
         case 104:
6535
-          SERIAL_ECHO(MSG_M104_INVALID_EXTRUDER);
6536
-          break;
6537 6528
         case 105:
6538
-          SERIAL_ECHO(MSG_M105_INVALID_EXTRUDER);
6539
-          break;
6540 6529
         case 109:
6541
-          SERIAL_ECHO(MSG_M109_INVALID_EXTRUDER);
6542
-          break;
6543 6530
         case 218:
6544
-          SERIAL_ECHO(MSG_M218_INVALID_EXTRUDER);
6545
-          break;
6546 6531
         case 221:
6547
-          SERIAL_ECHO(MSG_M221_INVALID_EXTRUDER);
6532
+        case 200:
6533
+          SERIAL_ECHO_START;
6534
+          SERIAL_CHAR('M');
6535
+          SERIAL_ECHO(code);
6536
+          SERIAL_ECHOPGM(" " MSG_INVALID_EXTRUDER " ");
6537
+          SERIAL_ECHOLN(target_extruder);
6548 6538
           break;
6549 6539
       }
6550
-      SERIAL_ECHOLN(target_extruder);
6551 6540
       return true;
6552 6541
     }
6553 6542
   }

+ 0
- 6
Marlin/configurator/config/language.h View File

@@ -121,12 +121,6 @@
121 121
 #define MSG_END_FILE_LIST                   "End file list"
122 122
 #define MSG_INVALID_EXTRUDER                "Invalid extruder"
123 123
 #define MSG_INVALID_SOLENOID                "Invalid solenoid"
124
-#define MSG_M104_INVALID_EXTRUDER           "M104 " MSG_INVALID_EXTRUDER " "
125
-#define MSG_M105_INVALID_EXTRUDER           "M105 " MSG_INVALID_EXTRUDER " "
126
-#define MSG_M109_INVALID_EXTRUDER           "M109 " MSG_INVALID_EXTRUDER " "
127
-#define MSG_M200_INVALID_EXTRUDER           "M200 " MSG_INVALID_EXTRUDER " "
128
-#define MSG_M218_INVALID_EXTRUDER           "M218 " MSG_INVALID_EXTRUDER " "
129
-#define MSG_M221_INVALID_EXTRUDER           "M221 " MSG_INVALID_EXTRUDER " "
130 124
 #define MSG_ERR_NO_THERMISTORS              "No thermistors - no temperature"
131 125
 #define MSG_HEATING                         "Heating..."
132 126
 #define MSG_HEATING_COMPLETE                "Heating done."

+ 0
- 6
Marlin/language.h View File

@@ -122,12 +122,6 @@
122 122
 #define MSG_END_FILE_LIST                   "End file list"
123 123
 #define MSG_INVALID_EXTRUDER                "Invalid extruder"
124 124
 #define MSG_INVALID_SOLENOID                "Invalid solenoid"
125
-#define MSG_M104_INVALID_EXTRUDER           "M104 " MSG_INVALID_EXTRUDER " "
126
-#define MSG_M105_INVALID_EXTRUDER           "M105 " MSG_INVALID_EXTRUDER " "
127
-#define MSG_M109_INVALID_EXTRUDER           "M109 " MSG_INVALID_EXTRUDER " "
128
-#define MSG_M200_INVALID_EXTRUDER           "M200 " MSG_INVALID_EXTRUDER " "
129
-#define MSG_M218_INVALID_EXTRUDER           "M218 " MSG_INVALID_EXTRUDER " "
130
-#define MSG_M221_INVALID_EXTRUDER           "M221 " MSG_INVALID_EXTRUDER " "
131 125
 #define MSG_ERR_NO_THERMISTORS              "No thermistors - no temperature"
132 126
 #define MSG_HEATING                         "Heating..."
133 127
 #define MSG_HEATING_COMPLETE                "Heating done."

Loading…
Cancel
Save