Browse Source

Merge pull request #2194 from thinkyhead/reduce_strings

Redo "invalid extruder" to save 304 bytes
AnHardt 10 years ago
parent
commit
2728dc0606
3 changed files with 16 additions and 43 deletions
  1. 16
    31
      Marlin/Marlin_main.cpp
  2. 0
    6
      Marlin/configurator/config/language.h
  3. 0
    6
      Marlin/language.h

+ 16
- 31
Marlin/Marlin_main.cpp View File

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

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

121
 #define MSG_END_FILE_LIST                   "End file list"
121
 #define MSG_END_FILE_LIST                   "End file list"
122
 #define MSG_INVALID_EXTRUDER                "Invalid extruder"
122
 #define MSG_INVALID_EXTRUDER                "Invalid extruder"
123
 #define MSG_INVALID_SOLENOID                "Invalid solenoid"
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
 #define MSG_ERR_NO_THERMISTORS              "No thermistors - no temperature"
124
 #define MSG_ERR_NO_THERMISTORS              "No thermistors - no temperature"
131
 #define MSG_HEATING                         "Heating..."
125
 #define MSG_HEATING                         "Heating..."
132
 #define MSG_HEATING_COMPLETE                "Heating done."
126
 #define MSG_HEATING_COMPLETE                "Heating done."

+ 0
- 6
Marlin/language.h View File

122
 #define MSG_END_FILE_LIST                   "End file list"
122
 #define MSG_END_FILE_LIST                   "End file list"
123
 #define MSG_INVALID_EXTRUDER                "Invalid extruder"
123
 #define MSG_INVALID_EXTRUDER                "Invalid extruder"
124
 #define MSG_INVALID_SOLENOID                "Invalid solenoid"
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
 #define MSG_ERR_NO_THERMISTORS              "No thermistors - no temperature"
125
 #define MSG_ERR_NO_THERMISTORS              "No thermistors - no temperature"
132
 #define MSG_HEATING                         "Heating..."
126
 #define MSG_HEATING                         "Heating..."
133
 #define MSG_HEATING_COMPLETE                "Heating done."
127
 #define MSG_HEATING_COMPLETE                "Heating done."

Loading…
Cancel
Save