Browse Source

Merge pull request #1801 from thinkyhead/fixup_probing

Minor optimizations
Scott Lahteine 9 years ago
parent
commit
a3e129e091

+ 4
- 2
Marlin/Configuration.h View File

529
   //#define MANUAL_Z_HOME_POS 402 // For delta: Distance between nozzle and print surface after homing.
529
   //#define MANUAL_Z_HOME_POS 402 // For delta: Distance between nozzle and print surface after homing.
530
 #endif
530
 #endif
531
 
531
 
532
-//// MOVEMENT SETTINGS
533
-#define NUM_AXIS 4 // The axis order in all axis related arrays is X, Y, Z, E
532
+/**
533
+ * MOVEMENT SETTINGS
534
+ */
535
+
534
 #define HOMING_FEEDRATE {50*60, 50*60, 4*60, 0}  // set the homing speeds (mm/min)
536
 #define HOMING_FEEDRATE {50*60, 50*60, 4*60, 0}  // set the homing speeds (mm/min)
535
 
537
 
536
 // default settings
538
 // default settings

+ 43
- 28
Marlin/Marlin.h View File

62
   #define MYSERIAL MSerial
62
   #define MYSERIAL MSerial
63
 #endif
63
 #endif
64
 
64
 
65
-#define SERIAL_PROTOCOL(x) (MYSERIAL.print(x))
66
-#define SERIAL_PROTOCOL_F(x,y) (MYSERIAL.print(x,y))
67
-#define SERIAL_PROTOCOLPGM(x) (serialprintPGM(PSTR(x)))
68
-#define SERIAL_PROTOCOLLN(x) (MYSERIAL.print(x),MYSERIAL.write('\n'))
69
-#define SERIAL_PROTOCOLLNPGM(x) (serialprintPGM(PSTR(x)),MYSERIAL.write('\n'))
65
+#define SERIAL_CHAR(x) MYSERIAL.write(x)
66
+#define SERIAL_EOL SERIAL_CHAR('\n')
67
+
68
+#define SERIAL_PROTOCOLCHAR(x) SERIAL_CHAR(x)
69
+#define SERIAL_PROTOCOL(x) MYSERIAL.print(x)
70
+#define SERIAL_PROTOCOL_F(x,y) MYSERIAL.print(x,y)
71
+#define SERIAL_PROTOCOLPGM(x) serialprintPGM(PSTR(x))
72
+#define SERIAL_PROTOCOLLN(x) do{ MYSERIAL.print(x),MYSERIAL.write('\n'); }while(0)
73
+#define SERIAL_PROTOCOLLNPGM(x) do{ serialprintPGM(PSTR(x)),MYSERIAL.write('\n'); }while(0)
70
 
74
 
71
 
75
 
72
 extern const char errormagic[] PROGMEM;
76
 extern const char errormagic[] PROGMEM;
73
 extern const char echomagic[] PROGMEM;
77
 extern const char echomagic[] PROGMEM;
74
 
78
 
75
-#define SERIAL_ERROR_START (serialprintPGM(errormagic))
79
+#define SERIAL_ERROR_START serialprintPGM(errormagic)
76
 #define SERIAL_ERROR(x) SERIAL_PROTOCOL(x)
80
 #define SERIAL_ERROR(x) SERIAL_PROTOCOL(x)
77
 #define SERIAL_ERRORPGM(x) SERIAL_PROTOCOLPGM(x)
81
 #define SERIAL_ERRORPGM(x) SERIAL_PROTOCOLPGM(x)
78
 #define SERIAL_ERRORLN(x) SERIAL_PROTOCOLLN(x)
82
 #define SERIAL_ERRORLN(x) SERIAL_PROTOCOLLN(x)
79
 #define SERIAL_ERRORLNPGM(x) SERIAL_PROTOCOLLNPGM(x)
83
 #define SERIAL_ERRORLNPGM(x) SERIAL_PROTOCOLLNPGM(x)
80
 
84
 
81
-#define SERIAL_ECHO_START (serialprintPGM(echomagic))
85
+#define SERIAL_ECHO_START serialprintPGM(echomagic)
82
 #define SERIAL_ECHO(x) SERIAL_PROTOCOL(x)
86
 #define SERIAL_ECHO(x) SERIAL_PROTOCOL(x)
83
 #define SERIAL_ECHOPGM(x) SERIAL_PROTOCOLPGM(x)
87
 #define SERIAL_ECHOPGM(x) SERIAL_PROTOCOLPGM(x)
84
 #define SERIAL_ECHOLN(x) SERIAL_PROTOCOLLN(x)
88
 #define SERIAL_ECHOLN(x) SERIAL_PROTOCOLLN(x)
85
 #define SERIAL_ECHOLNPGM(x) SERIAL_PROTOCOLLNPGM(x)
89
 #define SERIAL_ECHOLNPGM(x) SERIAL_PROTOCOLLNPGM(x)
86
 
90
 
87
-#define SERIAL_ECHOPAIR(name,value) (serial_echopair_P(PSTR(name),(value)))
88
-
89
-#define SERIAL_EOL MYSERIAL.write('\n')
91
+#define SERIAL_ECHOPAIR(name,value) do{ serial_echopair_P(PSTR(name),(value)); }while(0)
90
 
92
 
91
 void serial_echopair_P(const char *s_P, float v);
93
 void serial_echopair_P(const char *s_P, float v);
92
 void serial_echopair_P(const char *s_P, double v);
94
 void serial_echopair_P(const char *s_P, double v);
93
 void serial_echopair_P(const char *s_P, unsigned long v);
95
 void serial_echopair_P(const char *s_P, unsigned long v);
94
 
96
 
95
 
97
 
96
-//Things to write to serial from Program memory. Saves 400 to 2k of RAM.
97
-FORCE_INLINE void serialprintPGM(const char *str)
98
-{
99
-  char ch=pgm_read_byte(str);
100
-  while(ch)
101
-  {
98
+// Things to write to serial from Program memory. Saves 400 to 2k of RAM.
99
+FORCE_INLINE void serialprintPGM(const char *str) {
100
+  char ch;
101
+  while ((ch = pgm_read_byte(str))) {
102
     MYSERIAL.write(ch);
102
     MYSERIAL.write(ch);
103
-    ch=pgm_read_byte(++str);
103
+    str++;
104
   }
104
   }
105
 }
105
 }
106
 
106
 
107
-
108
 void get_command();
107
 void get_command();
109
 void process_commands();
108
 void process_commands();
110
 
109
 
148
 #endif
147
 #endif
149
 
148
 
150
 #if HAS_E0_ENABLE
149
 #if HAS_E0_ENABLE
151
-  #define enable_e0() E0_ENABLE_WRITE(E_ENABLE_ON)
150
+  #define enable_e0()  E0_ENABLE_WRITE( E_ENABLE_ON)
152
   #define disable_e0() E0_ENABLE_WRITE(!E_ENABLE_ON)
151
   #define disable_e0() E0_ENABLE_WRITE(!E_ENABLE_ON)
153
 #else
152
 #else
154
   #define enable_e0()  /* nothing */
153
   #define enable_e0()  /* nothing */
156
 #endif
155
 #endif
157
 
156
 
158
 #if (EXTRUDERS > 1) && HAS_E1_ENABLE
157
 #if (EXTRUDERS > 1) && HAS_E1_ENABLE
159
-  #define enable_e1() E1_ENABLE_WRITE(E_ENABLE_ON)
158
+  #define enable_e1()  E1_ENABLE_WRITE( E_ENABLE_ON)
160
   #define disable_e1() E1_ENABLE_WRITE(!E_ENABLE_ON)
159
   #define disable_e1() E1_ENABLE_WRITE(!E_ENABLE_ON)
161
 #else
160
 #else
162
   #define enable_e1()  /* nothing */
161
   #define enable_e1()  /* nothing */
164
 #endif
163
 #endif
165
 
164
 
166
 #if (EXTRUDERS > 2) && HAS_E2_ENABLE
165
 #if (EXTRUDERS > 2) && HAS_E2_ENABLE
167
-  #define enable_e2() E2_ENABLE_WRITE(E_ENABLE_ON)
166
+  #define enable_e2()  E2_ENABLE_WRITE( E_ENABLE_ON)
168
   #define disable_e2() E2_ENABLE_WRITE(!E_ENABLE_ON)
167
   #define disable_e2() E2_ENABLE_WRITE(!E_ENABLE_ON)
169
 #else
168
 #else
170
   #define enable_e2()  /* nothing */
169
   #define enable_e2()  /* nothing */
172
 #endif
171
 #endif
173
 
172
 
174
 #if (EXTRUDERS > 3) && HAS_E3_ENABLE
173
 #if (EXTRUDERS > 3) && HAS_E3_ENABLE
175
-  #define enable_e3() E3_ENABLE_WRITE(E_ENABLE_ON)
174
+  #define enable_e3()  E3_ENABLE_WRITE( E_ENABLE_ON)
176
   #define disable_e3() E3_ENABLE_WRITE(!E_ENABLE_ON)
175
   #define disable_e3() E3_ENABLE_WRITE(!E_ENABLE_ON)
177
 #else
176
 #else
178
   #define enable_e3()  /* nothing */
177
   #define enable_e3()  /* nothing */
179
   #define disable_e3() /* nothing */
178
   #define disable_e3() /* nothing */
180
 #endif
179
 #endif
181
 
180
 
181
+/**
182
+ * The axis order in all axis related arrays is X, Y, Z, E
183
+ */
184
+#define NUM_AXIS 4
185
+
186
+/**
187
+ * Axis indices as enumerated constants
188
+ *
189
+ * A_AXIS and B_AXIS are used by COREXY printers
190
+ * X_HEAD and Y_HEAD is used for systems that don't have a 1:1 relationship between X_AXIS and X Head movement, like CoreXY bots.
191
+ */
192
+enum AxisEnum {X_AXIS=0, Y_AXIS=1, A_AXIS=0, B_AXIS=1, Z_AXIS=2, E_AXIS=3, X_HEAD=4, Y_HEAD=5};
193
+
182
 void enable_all_steppers();
194
 void enable_all_steppers();
183
 void disable_all_steppers();
195
 void disable_all_steppers();
184
 
196
 
185
-enum AxisEnum {X_AXIS=0, Y_AXIS=1, A_AXIS=0, B_AXIS=1, Z_AXIS=2, E_AXIS=3, X_HEAD=4, Y_HEAD=5};
186
-//X_HEAD and Y_HEAD is used for systems that don't have a 1:1 relationship between X_AXIS and X Head movement, like CoreXY bots.
187
-
188
 void FlushSerialRequestResend();
197
 void FlushSerialRequestResend();
189
 void ClearToSend();
198
 void ClearToSend();
190
 
199
 
227
 #ifndef CRITICAL_SECTION_START
236
 #ifndef CRITICAL_SECTION_START
228
   #define CRITICAL_SECTION_START  unsigned char _sreg = SREG; cli();
237
   #define CRITICAL_SECTION_START  unsigned char _sreg = SREG; cli();
229
   #define CRITICAL_SECTION_END    SREG = _sreg;
238
   #define CRITICAL_SECTION_END    SREG = _sreg;
230
-#endif //CRITICAL_SECTION_START
239
+#endif
231
 
240
 
232
 extern float homing_feedrate[];
241
 extern float homing_feedrate[];
233
 extern bool axis_relative_modes[];
242
 extern bool axis_relative_modes[];
236
 extern int extruder_multiply[EXTRUDERS]; // sets extrude multiply factor (in percent) for each extruder individually
245
 extern int extruder_multiply[EXTRUDERS]; // sets extrude multiply factor (in percent) for each extruder individually
237
 extern float filament_size[EXTRUDERS]; // cross-sectional area of filament (in millimeters), typically around 1.75 or 2.85, 0 disables the volumetric calculations for the extruder.
246
 extern float filament_size[EXTRUDERS]; // cross-sectional area of filament (in millimeters), typically around 1.75 or 2.85, 0 disables the volumetric calculations for the extruder.
238
 extern float volumetric_multiplier[EXTRUDERS]; // reciprocal of cross-sectional area of filament (in square millimeters), stored this way to reduce computational burden in planner
247
 extern float volumetric_multiplier[EXTRUDERS]; // reciprocal of cross-sectional area of filament (in square millimeters), stored this way to reduce computational burden in planner
239
-extern float current_position[NUM_AXIS] ;
248
+extern float current_position[NUM_AXIS];
240
 extern float home_offset[3];
249
 extern float home_offset[3];
250
+
241
 #ifdef DELTA
251
 #ifdef DELTA
242
   extern float endstop_adj[3];
252
   extern float endstop_adj[3];
243
   extern float delta_radius;
253
   extern float delta_radius;
245
   extern float delta_segments_per_second;
255
   extern float delta_segments_per_second;
246
   void recalc_delta_settings(float radius, float diagonal_rod);
256
   void recalc_delta_settings(float radius, float diagonal_rod);
247
 #elif defined(Z_DUAL_ENDSTOPS)
257
 #elif defined(Z_DUAL_ENDSTOPS)
248
-extern float z_endstop_adj;
258
+  extern float z_endstop_adj;
249
 #endif
259
 #endif
260
+
250
 #ifdef SCARA
261
 #ifdef SCARA
251
   extern float axis_scaling[3];  // Build size scaling
262
   extern float axis_scaling[3];  // Build size scaling
252
 #endif
263
 #endif
264
+
253
 extern float min_pos[3];
265
 extern float min_pos[3];
254
 extern float max_pos[3];
266
 extern float max_pos[3];
255
 extern bool axis_known_position[3];
267
 extern bool axis_known_position[3];
268
+
256
 #ifdef ENABLE_AUTO_BED_LEVELING
269
 #ifdef ENABLE_AUTO_BED_LEVELING
257
   extern float zprobe_zoffset;
270
   extern float zprobe_zoffset;
258
 #endif
271
 #endif
272
+
259
 extern int fanSpeed;
273
 extern int fanSpeed;
274
+
260
 #ifdef BARICUDA
275
 #ifdef BARICUDA
261
   extern int ValvePressure;
276
   extern int ValvePressure;
262
   extern int EtoPPressure;
277
   extern int EtoPPressure;

+ 1
- 2
Marlin/MarlinSerial.cpp View File

268
   print(int_part);
268
   print(int_part);
269
 
269
 
270
   // Print the decimal point, but only if there are digits beyond
270
   // Print the decimal point, but only if there are digits beyond
271
-  if (digits > 0)
272
-    print("."); 
271
+  if (digits > 0) print('.');
273
 
272
 
274
   // Extract digits from the remainder one at a time
273
   // Extract digits from the remainder one at a time
275
   while (digits-- > 0) {
274
   while (digits-- > 0) {

+ 101
- 94
Marlin/Marlin_main.cpp View File

243
 static unsigned long stepper_inactive_time = DEFAULT_STEPPER_DEACTIVE_TIME*1000l;
243
 static unsigned long stepper_inactive_time = DEFAULT_STEPPER_DEACTIVE_TIME*1000l;
244
 unsigned long starttime = 0; ///< Print job start time
244
 unsigned long starttime = 0; ///< Print job start time
245
 unsigned long stoptime = 0;  ///< Print job stop time
245
 unsigned long stoptime = 0;  ///< Print job stop time
246
-static uint8_t tmp_extruder;
246
+static uint8_t target_extruder;
247
 bool Stopped = false;
247
 bool Stopped = false;
248
 bool CooldownNoWait = true;
248
 bool CooldownNoWait = true;
249
 bool target_direction;
249
 bool target_direction;
857
   return ret;
857
   return ret;
858
 }
858
 }
859
 
859
 
860
-long code_value_long() { return (strtol(strchr_pointer + 1, NULL, 10)); }
860
+long code_value_long() { return strtol(strchr_pointer + 1, NULL, 10); }
861
+
862
+int16_t code_value_short() { return (int16_t)strtol(strchr_pointer + 1, NULL, 10); }
861
 
863
 
862
 bool code_seen(char code) {
864
 bool code_seen(char code) {
863
   strchr_pointer = strchr(cmdbuffer[bufindr], code);
865
   strchr_pointer = strchr(cmdbuffer[bufindr], code);
1410
       for (int y = 0; y < AUTO_BED_LEVELING_GRID_POINTS; y++) {
1412
       for (int y = 0; y < AUTO_BED_LEVELING_GRID_POINTS; y++) {
1411
         for (int x = 0; x < AUTO_BED_LEVELING_GRID_POINTS; x++) {
1413
         for (int x = 0; x < AUTO_BED_LEVELING_GRID_POINTS; x++) {
1412
           SERIAL_PROTOCOL_F(bed_level[x][y], 2);
1414
           SERIAL_PROTOCOL_F(bed_level[x][y], 2);
1413
-          SERIAL_PROTOCOLPGM(" ");
1415
+          SERIAL_PROTOCOLCHAR(' ');
1414
         }
1416
         }
1415
-        SERIAL_ECHOLN("");
1417
+        SERIAL_EOL;
1416
       }
1418
       }
1417
     }
1419
     }
1418
 
1420
 
1685
  * G4: Dwell S<seconds> or P<milliseconds>
1687
  * G4: Dwell S<seconds> or P<milliseconds>
1686
  */
1688
  */
1687
 inline void gcode_G4() {
1689
 inline void gcode_G4() {
1688
-  unsigned long codenum=0;
1690
+  unsigned long codenum = 0;
1689
 
1691
 
1690
   LCD_MESSAGEPGM(MSG_DWELL);
1692
   LCD_MESSAGEPGM(MSG_DWELL);
1691
 
1693
 
1711
   inline void gcode_G10_G11(bool doRetract=false) {
1713
   inline void gcode_G10_G11(bool doRetract=false) {
1712
     #if EXTRUDERS > 1
1714
     #if EXTRUDERS > 1
1713
       if (doRetract) {
1715
       if (doRetract) {
1714
-        retracted_swap[active_extruder] = (code_seen('S') && code_value_long() == 1); // checks for swap retract argument
1716
+        retracted_swap[active_extruder] = (code_seen('S') && code_value_short() == 1); // checks for swap retract argument
1715
       }
1717
       }
1716
     #endif
1718
     #endif
1717
     retract(doRetract
1719
     retract(doRetract
2029
   inline void gcode_G29() {
2031
   inline void gcode_G29() {
2030
 
2032
 
2031
     static int probe_point = -1;
2033
     static int probe_point = -1;
2032
-    MeshLevelingState state = code_seen('S') || code_seen('s') ? (MeshLevelingState)code_value_long() : MeshReport;
2034
+    MeshLevelingState state = code_seen('S') || code_seen('s') ? (MeshLevelingState)code_value_short() : MeshReport;
2033
     if (state < 0 || state > 2) {
2035
     if (state < 0 || state > 2) {
2034
       SERIAL_PROTOCOLLNPGM("S out of range (0-2).");
2036
       SERIAL_PROTOCOLLNPGM("S out of range (0-2).");
2035
       return;
2037
       return;
2040
         if (mbl.active) {
2042
         if (mbl.active) {
2041
           SERIAL_PROTOCOLPGM("Num X,Y: ");
2043
           SERIAL_PROTOCOLPGM("Num X,Y: ");
2042
           SERIAL_PROTOCOL(MESH_NUM_X_POINTS);
2044
           SERIAL_PROTOCOL(MESH_NUM_X_POINTS);
2043
-          SERIAL_PROTOCOLPGM(",");
2045
+          SERIAL_PROTOCOLCHAR(',');
2044
           SERIAL_PROTOCOL(MESH_NUM_Y_POINTS);
2046
           SERIAL_PROTOCOL(MESH_NUM_Y_POINTS);
2045
           SERIAL_PROTOCOLPGM("\nZ search height: ");
2047
           SERIAL_PROTOCOLPGM("\nZ search height: ");
2046
           SERIAL_PROTOCOL(MESH_HOME_SEARCH_Z);
2048
           SERIAL_PROTOCOL(MESH_HOME_SEARCH_Z);
2156
       return;
2158
       return;
2157
     }
2159
     }
2158
 
2160
 
2159
-    int verbose_level = code_seen('V') || code_seen('v') ? code_value_long() : 1;
2161
+    int verbose_level = code_seen('V') || code_seen('v') ? code_value_short() : 1;
2160
     if (verbose_level < 0 || verbose_level > 4) {
2162
     if (verbose_level < 0 || verbose_level > 4) {
2161
       SERIAL_ECHOLNPGM("?(V)erbose Level is implausible (0-4).");
2163
       SERIAL_ECHOLNPGM("?(V)erbose Level is implausible (0-4).");
2162
       return;
2164
       return;
2178
 
2180
 
2179
       int auto_bed_leveling_grid_points = AUTO_BED_LEVELING_GRID_POINTS;
2181
       int auto_bed_leveling_grid_points = AUTO_BED_LEVELING_GRID_POINTS;
2180
       #ifndef DELTA
2182
       #ifndef DELTA
2181
-        if (code_seen('P')) auto_bed_leveling_grid_points = code_value_long();
2183
+        if (code_seen('P')) auto_bed_leveling_grid_points = code_value_short();
2182
         if (auto_bed_leveling_grid_points < 2) {
2184
         if (auto_bed_leveling_grid_points < 2) {
2183
           SERIAL_PROTOCOLPGM("?Number of probed (P)oints is implausible (2 minimum).\n");
2185
           SERIAL_PROTOCOLPGM("?Number of probed (P)oints is implausible (2 minimum).\n");
2184
           return;
2186
           return;
2185
         }
2187
         }
2186
       #endif
2188
       #endif
2187
 
2189
 
2188
-      xy_travel_speed = code_seen('S') ? code_value_long() : XY_TRAVEL_SPEED;
2190
+      xy_travel_speed = code_seen('S') ? code_value_short() : XY_TRAVEL_SPEED;
2189
 
2191
 
2190
-      int left_probe_bed_position = code_seen('L') ? code_value_long() : LEFT_PROBE_BED_POSITION,
2191
-          right_probe_bed_position = code_seen('R') ? code_value_long() : RIGHT_PROBE_BED_POSITION,
2192
-          front_probe_bed_position = code_seen('F') ? code_value_long() : FRONT_PROBE_BED_POSITION,
2193
-          back_probe_bed_position = code_seen('B') ? code_value_long() : BACK_PROBE_BED_POSITION;
2192
+      int left_probe_bed_position = code_seen('L') ? code_value_short() : LEFT_PROBE_BED_POSITION,
2193
+          right_probe_bed_position = code_seen('R') ? code_value_short() : RIGHT_PROBE_BED_POSITION,
2194
+          front_probe_bed_position = code_seen('F') ? code_value_short() : FRONT_PROBE_BED_POSITION,
2195
+          back_probe_bed_position = code_seen('B') ? code_value_short() : BACK_PROBE_BED_POSITION;
2194
 
2196
 
2195
       bool left_out_l = left_probe_bed_position < MIN_PROBE_X,
2197
       bool left_out_l = left_probe_bed_position < MIN_PROBE_X,
2196
            left_out = left_out_l || left_probe_bed_position > right_probe_bed_position - MIN_PROBE_EDGE,
2198
            left_out = left_out_l || left_probe_bed_position > right_probe_bed_position - MIN_PROBE_EDGE,
2394
               if (diff >= 0.0)
2396
               if (diff >= 0.0)
2395
                 SERIAL_PROTOCOLPGM(" +");   // Include + for column alignment
2397
                 SERIAL_PROTOCOLPGM(" +");   // Include + for column alignment
2396
               else
2398
               else
2397
-                SERIAL_PROTOCOLPGM(" ");
2399
+                SERIAL_PROTOCOLCHAR(' ');
2398
               SERIAL_PROTOCOL_F(diff, 5);
2400
               SERIAL_PROTOCOL_F(diff, 5);
2399
             } // xx
2401
             } // xx
2400
             SERIAL_EOL;
2402
             SERIAL_EOL;
2518
     unsigned long codenum = 0;
2520
     unsigned long codenum = 0;
2519
     bool hasP = false, hasS = false;
2521
     bool hasP = false, hasS = false;
2520
     if (code_seen('P')) {
2522
     if (code_seen('P')) {
2521
-      codenum = code_value(); // milliseconds to wait
2523
+      codenum = code_value_short(); // milliseconds to wait
2522
       hasP = codenum > 0;
2524
       hasP = codenum > 0;
2523
     }
2525
     }
2524
     if (code_seen('S')) {
2526
     if (code_seen('S')) {
2525
-      codenum = code_value() * 1000; // seconds to wait
2527
+      codenum = code_value_short() * 1000UL; // seconds to wait
2526
       hasS = codenum > 0;
2528
       hasS = codenum > 0;
2527
     }
2529
     }
2528
     char* starpos = strchr(src, '*');
2530
     char* starpos = strchr(src, '*');
2628
    */
2630
    */
2629
   inline void gcode_M26() {
2631
   inline void gcode_M26() {
2630
     if (card.cardOK && code_seen('S'))
2632
     if (card.cardOK && code_seen('S'))
2631
-      card.setIndex(code_value_long());
2633
+      card.setIndex(code_value_short());
2632
   }
2634
   }
2633
 
2635
 
2634
   /**
2636
   /**
2719
       card.openFile(namestartpos, true, !call_procedure);
2721
       card.openFile(namestartpos, true, !call_procedure);
2720
 
2722
 
2721
       if (code_seen('S') && strchr_pointer < namestartpos) // "S" (must occur _before_ the filename!)
2723
       if (code_seen('S') && strchr_pointer < namestartpos) // "S" (must occur _before_ the filename!)
2722
-        card.setIndex(code_value_long());
2724
+        card.setIndex(code_value_short());
2723
 
2725
 
2724
       card.startFileprint();
2726
       card.startFileprint();
2725
       if (!call_procedure)
2727
       if (!call_procedure)
2747
  */
2749
  */
2748
 inline void gcode_M42() {
2750
 inline void gcode_M42() {
2749
   if (code_seen('S')) {
2751
   if (code_seen('S')) {
2750
-    int pin_status = code_value(),
2752
+    int pin_status = code_value_short(),
2751
         pin_number = LED_PIN;
2753
         pin_number = LED_PIN;
2752
 
2754
 
2753
     if (code_seen('P') && pin_status >= 0 && pin_status <= 255)
2755
     if (code_seen('P') && pin_status >= 0 && pin_status <= 255)
2754
-      pin_number = code_value();
2756
+      pin_number = code_value_short();
2755
 
2757
 
2756
     for (int8_t i = 0; i < (int8_t)(sizeof(sensitive_pins) / sizeof(*sensitive_pins)); i++) {
2758
     for (int8_t i = 0; i < (int8_t)(sizeof(sensitive_pins) / sizeof(*sensitive_pins)); i++) {
2757
       if (sensitive_pins[i] == pin_number) {
2759
       if (sensitive_pins[i] == pin_number) {
2810
     int verbose_level = 1, n_samples = 10, n_legs = 0;
2812
     int verbose_level = 1, n_samples = 10, n_legs = 0;
2811
     
2813
     
2812
     if (code_seen('V') || code_seen('v')) {
2814
     if (code_seen('V') || code_seen('v')) {
2813
-      verbose_level = code_value();
2815
+      verbose_level = code_value_short();
2814
       if (verbose_level < 0 || verbose_level > 4 ) {
2816
       if (verbose_level < 0 || verbose_level > 4 ) {
2815
         SERIAL_PROTOCOLPGM("?Verbose Level not plausible (0-4).\n");
2817
         SERIAL_PROTOCOLPGM("?Verbose Level not plausible (0-4).\n");
2816
         return;
2818
         return;
2821
       SERIAL_PROTOCOLPGM("M48 Z-Probe Repeatability test\n");
2823
       SERIAL_PROTOCOLPGM("M48 Z-Probe Repeatability test\n");
2822
 
2824
 
2823
     if (code_seen('P') || code_seen('p') || code_seen('n')) { // `n` for legacy support only - please use `P`!
2825
     if (code_seen('P') || code_seen('p') || code_seen('n')) { // `n` for legacy support only - please use `P`!
2824
-      n_samples = code_value();
2826
+      n_samples = code_value_short();
2825
       if (n_samples < 4 || n_samples > 50) {
2827
       if (n_samples < 4 || n_samples > 50) {
2826
         SERIAL_PROTOCOLPGM("?Sample size not plausible (4-50).\n");
2828
         SERIAL_PROTOCOLPGM("?Sample size not plausible (4-50).\n");
2827
         return;
2829
         return;
2854
     }
2856
     }
2855
 
2857
 
2856
     if (code_seen('L') || code_seen('l')) {
2858
     if (code_seen('L') || code_seen('l')) {
2857
-      n_legs = code_value();
2859
+      n_legs = code_value_short();
2858
       if (n_legs == 1) n_legs = 2;
2860
       if (n_legs == 1) n_legs = 2;
2859
       if (n_legs < 0 || n_legs > 15) {
2861
       if (n_legs < 0 || n_legs > 15) {
2860
         SERIAL_PROTOCOLPGM("?Number of legs in movement not plausible (0-15).\n");
2862
         SERIAL_PROTOCOLPGM("?Number of legs in movement not plausible (0-15).\n");
3036
 inline void gcode_M104() {
3038
 inline void gcode_M104() {
3037
   if (setTargetedHotend(104)) return;
3039
   if (setTargetedHotend(104)) return;
3038
 
3040
 
3039
-  if (code_seen('S')) setTargetHotend(code_value(), tmp_extruder);
3040
-  #ifdef DUAL_X_CARRIAGE
3041
-    if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && tmp_extruder == 0)
3042
-      setTargetHotend1(code_value() == 0.0 ? 0.0 : code_value() + duplicate_extruder_temp_offset);
3043
-  #endif
3044
-  setWatch();
3041
+  if (code_seen('S')) {
3042
+    float temp = code_value();
3043
+    setTargetHotend(temp, target_extruder);
3044
+    #ifdef DUAL_X_CARRIAGE
3045
+      if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && target_extruder == 0)
3046
+        setTargetHotend1(temp == 0.0 ? 0.0 : temp + duplicate_extruder_temp_offset);
3047
+    #endif
3048
+    setWatch();
3049
+  }
3045
 }
3050
 }
3046
 
3051
 
3047
 /**
3052
 /**
3054
     SERIAL_PROTOCOLPGM("ok");
3059
     SERIAL_PROTOCOLPGM("ok");
3055
     #if HAS_TEMP_0
3060
     #if HAS_TEMP_0
3056
       SERIAL_PROTOCOLPGM(" T:");
3061
       SERIAL_PROTOCOLPGM(" T:");
3057
-      SERIAL_PROTOCOL_F(degHotend(tmp_extruder), 1);
3062
+      SERIAL_PROTOCOL_F(degHotend(target_extruder), 1);
3058
       SERIAL_PROTOCOLPGM(" /");
3063
       SERIAL_PROTOCOLPGM(" /");
3059
-      SERIAL_PROTOCOL_F(degTargetHotend(tmp_extruder), 1);
3064
+      SERIAL_PROTOCOL_F(degTargetHotend(target_extruder), 1);
3060
     #endif
3065
     #endif
3061
     #if HAS_TEMP_BED
3066
     #if HAS_TEMP_BED
3062
       SERIAL_PROTOCOLPGM(" B:");
3067
       SERIAL_PROTOCOLPGM(" B:");
3067
     for (int8_t e = 0; e < EXTRUDERS; ++e) {
3072
     for (int8_t e = 0; e < EXTRUDERS; ++e) {
3068
       SERIAL_PROTOCOLPGM(" T");
3073
       SERIAL_PROTOCOLPGM(" T");
3069
       SERIAL_PROTOCOL(e);
3074
       SERIAL_PROTOCOL(e);
3070
-      SERIAL_PROTOCOLPGM(":");
3075
+      SERIAL_PROTOCOLCHAR(':');
3071
       SERIAL_PROTOCOL_F(degHotend(e), 1);
3076
       SERIAL_PROTOCOL_F(degHotend(e), 1);
3072
       SERIAL_PROTOCOLPGM(" /");
3077
       SERIAL_PROTOCOLPGM(" /");
3073
       SERIAL_PROTOCOL_F(degTargetHotend(e), 1);
3078
       SERIAL_PROTOCOL_F(degTargetHotend(e), 1);
3079
 
3084
 
3080
   SERIAL_PROTOCOLPGM(" @:");
3085
   SERIAL_PROTOCOLPGM(" @:");
3081
   #ifdef EXTRUDER_WATTS
3086
   #ifdef EXTRUDER_WATTS
3082
-    SERIAL_PROTOCOL((EXTRUDER_WATTS * getHeaterPower(tmp_extruder))/127);
3083
-    SERIAL_PROTOCOLPGM("W");
3087
+    SERIAL_PROTOCOL((EXTRUDER_WATTS * getHeaterPower(target_extruder))/127);
3088
+    SERIAL_PROTOCOLCHAR('W');
3084
   #else
3089
   #else
3085
-    SERIAL_PROTOCOL(getHeaterPower(tmp_extruder));
3090
+    SERIAL_PROTOCOL(getHeaterPower(target_extruder));
3086
   #endif
3091
   #endif
3087
 
3092
 
3088
   SERIAL_PROTOCOLPGM(" B@:");
3093
   SERIAL_PROTOCOLPGM(" B@:");
3089
   #ifdef BED_WATTS
3094
   #ifdef BED_WATTS
3090
     SERIAL_PROTOCOL((BED_WATTS * getHeaterPower(-1))/127);
3095
     SERIAL_PROTOCOL((BED_WATTS * getHeaterPower(-1))/127);
3091
-    SERIAL_PROTOCOLPGM("W");
3096
+    SERIAL_PROTOCOLCHAR('W');
3092
   #else
3097
   #else
3093
     SERIAL_PROTOCOL(getHeaterPower(-1));
3098
     SERIAL_PROTOCOL(getHeaterPower(-1));
3094
   #endif
3099
   #endif
3103
     for (int8_t cur_extruder = 0; cur_extruder < EXTRUDERS; ++cur_extruder) {
3108
     for (int8_t cur_extruder = 0; cur_extruder < EXTRUDERS; ++cur_extruder) {
3104
       SERIAL_PROTOCOLPGM("  T");
3109
       SERIAL_PROTOCOLPGM("  T");
3105
       SERIAL_PROTOCOL(cur_extruder);
3110
       SERIAL_PROTOCOL(cur_extruder);
3106
-      SERIAL_PROTOCOLPGM(":");
3111
+      SERIAL_PROTOCOLCHAR(':');
3107
       SERIAL_PROTOCOL_F(degHotend(cur_extruder),1);
3112
       SERIAL_PROTOCOL_F(degHotend(cur_extruder),1);
3108
       SERIAL_PROTOCOLPGM("C->");
3113
       SERIAL_PROTOCOLPGM("C->");
3109
       SERIAL_PROTOCOL_F(rawHotendTemp(cur_extruder)/OVERSAMPLENR,0);
3114
       SERIAL_PROTOCOL_F(rawHotendTemp(cur_extruder)/OVERSAMPLENR,0);
3118
   /**
3123
   /**
3119
    * M106: Set Fan Speed
3124
    * M106: Set Fan Speed
3120
    */
3125
    */
3121
-  inline void gcode_M106() { fanSpeed = code_seen('S') ? constrain(code_value(), 0, 255) : 255; }
3126
+  inline void gcode_M106() { fanSpeed = code_seen('S') ? constrain(code_value_short(), 0, 255) : 255; }
3122
 
3127
 
3123
   /**
3128
   /**
3124
    * M107: Fan Off
3129
    * M107: Fan Off
3137
 
3142
 
3138
   CooldownNoWait = code_seen('S');
3143
   CooldownNoWait = code_seen('S');
3139
   if (CooldownNoWait || code_seen('R')) {
3144
   if (CooldownNoWait || code_seen('R')) {
3140
-    setTargetHotend(code_value(), tmp_extruder);
3145
+    float temp = code_value();
3146
+    setTargetHotend(temp, target_extruder);
3141
     #ifdef DUAL_X_CARRIAGE
3147
     #ifdef DUAL_X_CARRIAGE
3142
-      if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && tmp_extruder == 0)
3143
-        setTargetHotend1(code_value() == 0.0 ? 0.0 : code_value() + duplicate_extruder_temp_offset);
3148
+      if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && target_extruder == 0)
3149
+        setTargetHotend1(temp == 0.0 ? 0.0 : temp + duplicate_extruder_temp_offset);
3144
     #endif
3150
     #endif
3145
   }
3151
   }
3146
 
3152
 
3156
   unsigned long timetemp = millis();
3162
   unsigned long timetemp = millis();
3157
 
3163
 
3158
   /* See if we are heating up or cooling down */
3164
   /* See if we are heating up or cooling down */
3159
-  target_direction = isHeatingHotend(tmp_extruder); // true if heating, false if cooling
3165
+  target_direction = isHeatingHotend(target_extruder); // true if heating, false if cooling
3160
 
3166
 
3161
   cancel_heatup = false;
3167
   cancel_heatup = false;
3162
 
3168
 
3167
     while((!cancel_heatup)&&((residencyStart == -1) ||
3173
     while((!cancel_heatup)&&((residencyStart == -1) ||
3168
           (residencyStart >= 0 && (((unsigned int) (millis() - residencyStart)) < (TEMP_RESIDENCY_TIME * 1000UL)))) )
3174
           (residencyStart >= 0 && (((unsigned int) (millis() - residencyStart)) < (TEMP_RESIDENCY_TIME * 1000UL)))) )
3169
   #else
3175
   #else
3170
-    while ( target_direction ? (isHeatingHotend(tmp_extruder)) : (isCoolingHotend(tmp_extruder)&&(CooldownNoWait==false)) )
3176
+    while ( target_direction ? (isHeatingHotend(target_extruder)) : (isCoolingHotend(target_extruder)&&(CooldownNoWait==false)) )
3171
   #endif //TEMP_RESIDENCY_TIME
3177
   #endif //TEMP_RESIDENCY_TIME
3172
 
3178
 
3173
     { // while loop
3179
     { // while loop
3174
       if (millis() > timetemp + 1000UL) { //Print temp & remaining time every 1s while waiting
3180
       if (millis() > timetemp + 1000UL) { //Print temp & remaining time every 1s while waiting
3175
         SERIAL_PROTOCOLPGM("T:");
3181
         SERIAL_PROTOCOLPGM("T:");
3176
-        SERIAL_PROTOCOL_F(degHotend(tmp_extruder),1);
3182
+        SERIAL_PROTOCOL_F(degHotend(target_extruder),1);
3177
         SERIAL_PROTOCOLPGM(" E:");
3183
         SERIAL_PROTOCOLPGM(" E:");
3178
-        SERIAL_PROTOCOL((int)tmp_extruder);
3184
+        SERIAL_PROTOCOL((int)target_extruder);
3179
         #ifdef TEMP_RESIDENCY_TIME
3185
         #ifdef TEMP_RESIDENCY_TIME
3180
           SERIAL_PROTOCOLPGM(" W:");
3186
           SERIAL_PROTOCOLPGM(" W:");
3181
           if (residencyStart > -1) {
3187
           if (residencyStart > -1) {
3196
       #ifdef TEMP_RESIDENCY_TIME
3202
       #ifdef TEMP_RESIDENCY_TIME
3197
         // start/restart the TEMP_RESIDENCY_TIME timer whenever we reach target temp for the first time
3203
         // start/restart the TEMP_RESIDENCY_TIME timer whenever we reach target temp for the first time
3198
         // or when current temp falls outside the hysteresis after target temp was reached
3204
         // or when current temp falls outside the hysteresis after target temp was reached
3199
-        if ((residencyStart == -1 &&  target_direction && (degHotend(tmp_extruder) >= (degTargetHotend(tmp_extruder)-TEMP_WINDOW))) ||
3200
-            (residencyStart == -1 && !target_direction && (degHotend(tmp_extruder) <= (degTargetHotend(tmp_extruder)+TEMP_WINDOW))) ||
3201
-            (residencyStart > -1 && labs(degHotend(tmp_extruder) - degTargetHotend(tmp_extruder)) > TEMP_HYSTERESIS) )
3205
+        if ((residencyStart == -1 &&  target_direction && (degHotend(target_extruder) >= (degTargetHotend(target_extruder)-TEMP_WINDOW))) ||
3206
+            (residencyStart == -1 && !target_direction && (degHotend(target_extruder) <= (degTargetHotend(target_extruder)+TEMP_WINDOW))) ||
3207
+            (residencyStart > -1 && labs(degHotend(target_extruder) - degTargetHotend(target_extruder)) > TEMP_HYSTERESIS) )
3202
         {
3208
         {
3203
           residencyStart = millis();
3209
           residencyStart = millis();
3204
         }
3210
         }
3535
    */
3541
    */
3536
   inline void gcode_M150() {
3542
   inline void gcode_M150() {
3537
     SendColors(
3543
     SendColors(
3538
-      code_seen('R') ? (byte)code_value() : 0,
3539
-      code_seen('U') ? (byte)code_value() : 0,
3540
-      code_seen('B') ? (byte)code_value() : 0
3544
+      code_seen('R') ? (byte)code_value_short() : 0,
3545
+      code_seen('U') ? (byte)code_value_short() : 0,
3546
+      code_seen('B') ? (byte)code_value_short() : 0
3541
     );
3547
     );
3542
   }
3548
   }
3543
 
3549
 
3549
  *       D<millimeters>
3555
  *       D<millimeters>
3550
  */
3556
  */
3551
 inline void gcode_M200() {
3557
 inline void gcode_M200() {
3552
-  tmp_extruder = active_extruder;
3558
+  int tmp_extruder = active_extruder;
3553
   if (code_seen('T')) {
3559
   if (code_seen('T')) {
3554
-    tmp_extruder = code_value();
3560
+    tmp_extruder = code_value_short();
3555
     if (tmp_extruder >= EXTRUDERS) {
3561
     if (tmp_extruder >= EXTRUDERS) {
3556
       SERIAL_ECHO_START;
3562
       SERIAL_ECHO_START;
3557
       SERIAL_ECHO(MSG_M200_INVALID_EXTRUDER);
3563
       SERIAL_ECHO(MSG_M200_INVALID_EXTRUDER);
3622
  *  Also sets minimum segment time in ms (B20000) to prevent buffer under-runs and M20 minimum feedrate
3628
  *  Also sets minimum segment time in ms (B20000) to prevent buffer under-runs and M20 minimum feedrate
3623
  */
3629
  */
3624
 inline void gcode_M204() {
3630
 inline void gcode_M204() {
3625
-  if (code_seen('S'))   // Kept for legacy compatibility. Should NOT BE USED for new developments.
3626
-  {
3631
+  if (code_seen('S')) {  // Kept for legacy compatibility. Should NOT BE USED for new developments.
3627
     acceleration = code_value();
3632
     acceleration = code_value();
3628
     travel_acceleration = acceleration;
3633
     travel_acceleration = acceleration;
3629
-    SERIAL_ECHOPAIR("Setting Printing and Travelling Acceleration: ", acceleration );
3634
+    SERIAL_ECHOPAIR("Setting Print and Travel Acceleration: ", acceleration );
3630
     SERIAL_EOL;
3635
     SERIAL_EOL;
3631
   }
3636
   }
3632
-  if (code_seen('P'))
3633
-  {
3637
+  if (code_seen('P')) {
3634
     acceleration = code_value();
3638
     acceleration = code_value();
3635
-    SERIAL_ECHOPAIR("Setting Printing Acceleration: ", acceleration );
3639
+    SERIAL_ECHOPAIR("Setting Print Acceleration: ", acceleration );
3636
     SERIAL_EOL;
3640
     SERIAL_EOL;
3637
   }
3641
   }
3638
-  if (code_seen('R'))
3639
-  {
3642
+  if (code_seen('R')) {
3640
     retract_acceleration = code_value();
3643
     retract_acceleration = code_value();
3641
     SERIAL_ECHOPAIR("Setting Retract Acceleration: ", retract_acceleration );
3644
     SERIAL_ECHOPAIR("Setting Retract Acceleration: ", retract_acceleration );
3642
     SERIAL_EOL;
3645
     SERIAL_EOL;
3643
   }
3646
   }
3644
-  if (code_seen('T'))
3645
-  {
3647
+  if (code_seen('T')) {
3646
     travel_acceleration = code_value();
3648
     travel_acceleration = code_value();
3647
     SERIAL_ECHOPAIR("Setting Travel Acceleration: ", travel_acceleration );
3649
     SERIAL_ECHOPAIR("Setting Travel Acceleration: ", travel_acceleration );
3648
     SERIAL_EOL;
3650
     SERIAL_EOL;
3745
    */
3747
    */
3746
   inline void gcode_M209() {
3748
   inline void gcode_M209() {
3747
     if (code_seen('S')) {
3749
     if (code_seen('S')) {
3748
-      int t = code_value();
3750
+      int t = code_value_short();
3749
       switch(t) {
3751
       switch(t) {
3750
         case 0:
3752
         case 0:
3751
           autoretract_enabled = false;
3753
           autoretract_enabled = false;
3774
   inline void gcode_M218() {
3776
   inline void gcode_M218() {
3775
     if (setTargetedHotend(218)) return;
3777
     if (setTargetedHotend(218)) return;
3776
 
3778
 
3777
-    if (code_seen('X')) extruder_offset[X_AXIS][tmp_extruder] = code_value();
3778
-    if (code_seen('Y')) extruder_offset[Y_AXIS][tmp_extruder] = code_value();
3779
+    if (code_seen('X')) extruder_offset[X_AXIS][target_extruder] = code_value();
3780
+    if (code_seen('Y')) extruder_offset[Y_AXIS][target_extruder] = code_value();
3779
 
3781
 
3780
     #ifdef DUAL_X_CARRIAGE
3782
     #ifdef DUAL_X_CARRIAGE
3781
-      if (code_seen('Z')) extruder_offset[Z_AXIS][tmp_extruder] = code_value();
3783
+      if (code_seen('Z')) extruder_offset[Z_AXIS][target_extruder] = code_value();
3782
     #endif
3784
     #endif
3783
 
3785
 
3784
     SERIAL_ECHO_START;
3786
     SERIAL_ECHO_START;
3785
     SERIAL_ECHOPGM(MSG_HOTEND_OFFSET);
3787
     SERIAL_ECHOPGM(MSG_HOTEND_OFFSET);
3786
-    for (tmp_extruder = 0; tmp_extruder < EXTRUDERS; tmp_extruder++) {
3787
-      SERIAL_ECHO(" ");
3788
-      SERIAL_ECHO(extruder_offset[X_AXIS][tmp_extruder]);
3789
-      SERIAL_ECHO(",");
3790
-      SERIAL_ECHO(extruder_offset[Y_AXIS][tmp_extruder]);
3788
+    for (int e = 0; e < EXTRUDERS; e++) {
3789
+      SERIAL_CHAR(' ');
3790
+      SERIAL_ECHO(extruder_offset[X_AXIS][e]);
3791
+      SERIAL_CHAR(',');
3792
+      SERIAL_ECHO(extruder_offset[Y_AXIS][e]);
3791
       #ifdef DUAL_X_CARRIAGE
3793
       #ifdef DUAL_X_CARRIAGE
3792
-        SERIAL_ECHO(",");
3793
-        SERIAL_ECHO(extruder_offset[Z_AXIS][tmp_extruder]);
3794
+        SERIAL_CHAR(',');
3795
+        SERIAL_ECHO(extruder_offset[Z_AXIS][e]);
3794
       #endif
3796
       #endif
3795
     }
3797
     }
3796
     SERIAL_EOL;
3798
     SERIAL_EOL;
3813
     int sval = code_value();
3815
     int sval = code_value();
3814
     if (code_seen('T')) {
3816
     if (code_seen('T')) {
3815
       if (setTargetedHotend(221)) return;
3817
       if (setTargetedHotend(221)) return;
3816
-      extruder_multiply[tmp_extruder] = sval;
3818
+      extruder_multiply[target_extruder] = sval;
3817
     }
3819
     }
3818
     else {
3820
     else {
3819
       extruder_multiply[active_extruder] = sval;
3821
       extruder_multiply[active_extruder] = sval;
4044
    * M250: Read and optionally set the LCD contrast
4046
    * M250: Read and optionally set the LCD contrast
4045
    */
4047
    */
4046
   inline void gcode_M250() {
4048
   inline void gcode_M250() {
4047
-    if (code_seen('C')) lcd_setcontrast(code_value_long() & 0x3F);
4049
+    if (code_seen('C')) lcd_setcontrast(code_value_short() & 0x3F);
4048
     SERIAL_PROTOCOLPGM("lcd contrast value: ");
4050
     SERIAL_PROTOCOLPGM("lcd contrast value: ");
4049
     SERIAL_PROTOCOL(lcd_contrast);
4051
     SERIAL_PROTOCOL(lcd_contrast);
4050
     SERIAL_EOL;
4052
     SERIAL_EOL;
4070
  *       C<cycles>
4072
  *       C<cycles>
4071
  */
4073
  */
4072
 inline void gcode_M303() {
4074
 inline void gcode_M303() {
4073
-  int e = code_seen('E') ? code_value_long() : 0;
4074
-  int c = code_seen('C') ? code_value_long() : 5;
4075
+  int e = code_seen('E') ? code_value_short() : 0;
4076
+  int c = code_seen('C') ? code_value_short() : 5;
4075
   float temp = code_seen('S') ? code_value() : (e < 0 ? 70.0 : 150.0);
4077
   float temp = code_seen('S') ? code_value() : (e < 0 ? 70.0 : 150.0);
4076
   PID_autotune(temp, e, c);
4078
   PID_autotune(temp, e, c);
4077
 }
4079
 }
4480
         if (code_seen('R')) duplicate_extruder_temp_offset = code_value();
4482
         if (code_seen('R')) duplicate_extruder_temp_offset = code_value();
4481
         SERIAL_ECHO_START;
4483
         SERIAL_ECHO_START;
4482
         SERIAL_ECHOPGM(MSG_HOTEND_OFFSET);
4484
         SERIAL_ECHOPGM(MSG_HOTEND_OFFSET);
4483
-        SERIAL_ECHO(" ");
4485
+        SERIAL_CHAR(' ');
4484
         SERIAL_ECHO(extruder_offset[X_AXIS][0]);
4486
         SERIAL_ECHO(extruder_offset[X_AXIS][0]);
4485
-        SERIAL_ECHO(",");
4487
+        SERIAL_CHAR(',');
4486
         SERIAL_ECHO(extruder_offset[Y_AXIS][0]);
4488
         SERIAL_ECHO(extruder_offset[Y_AXIS][0]);
4487
-        SERIAL_ECHO(" ");
4489
+        SERIAL_CHAR(' ');
4488
         SERIAL_ECHO(duplicate_extruder_x_offset);
4490
         SERIAL_ECHO(duplicate_extruder_x_offset);
4489
-        SERIAL_ECHO(",");
4491
+        SERIAL_CHAR(',');
4490
         SERIAL_ECHOLN(extruder_offset[Y_AXIS][1]);
4492
         SERIAL_ECHOLN(extruder_offset[Y_AXIS][1]);
4491
         break;
4493
         break;
4492
       case DXC_FULL_CONTROL_MODE:
4494
       case DXC_FULL_CONTROL_MODE:
4559
    *       S# determines MS1 or MS2, X# sets the pin high/low.
4561
    *       S# determines MS1 or MS2, X# sets the pin high/low.
4560
    */
4562
    */
4561
   inline void gcode_M351() {
4563
   inline void gcode_M351() {
4562
-    if (code_seen('S')) switch(code_value_long()) {
4564
+    if (code_seen('S')) switch(code_value_short()) {
4563
       case 1:
4565
       case 1:
4564
         for(int i=0;i<NUM_AXIS;i++) if (code_seen(axis_codes[i])) microstep_ms(i, code_value(), -1);
4566
         for(int i=0;i<NUM_AXIS;i++) if (code_seen(axis_codes[i])) microstep_ms(i, code_value(), -1);
4565
         if (code_seen('B')) microstep_ms(4, code_value(), -1);
4567
         if (code_seen('B')) microstep_ms(4, code_value(), -1);
4585
 }
4587
 }
4586
 
4588
 
4587
 inline void gcode_T() {
4589
 inline void gcode_T() {
4588
-  tmp_extruder = code_value();
4590
+  int tmp_extruder = code_value();
4589
   if (tmp_extruder >= EXTRUDERS) {
4591
   if (tmp_extruder >= EXTRUDERS) {
4590
     SERIAL_ECHO_START;
4592
     SERIAL_ECHO_START;
4591
-    SERIAL_ECHO("T");
4593
+    SERIAL_CHAR('T');
4592
     SERIAL_ECHO(tmp_extruder);
4594
     SERIAL_ECHO(tmp_extruder);
4593
     SERIAL_ECHOLN(MSG_INVALID_EXTRUDER);
4595
     SERIAL_ECHOLN(MSG_INVALID_EXTRUDER);
4594
   }
4596
   }
4595
   else {
4597
   else {
4598
+    target_extruder = tmp_extruder;
4599
+
4596
     #if EXTRUDERS > 1
4600
     #if EXTRUDERS > 1
4597
       bool make_move = false;
4601
       bool make_move = false;
4598
     #endif
4602
     #endif
4603
+
4599
     if (code_seen('F')) {
4604
     if (code_seen('F')) {
4605
+
4600
       #if EXTRUDERS > 1
4606
       #if EXTRUDERS > 1
4601
         make_move = true;
4607
         make_move = true;
4602
       #endif
4608
       #endif
4609
+
4603
       next_feedrate = code_value();
4610
       next_feedrate = code_value();
4604
       if (next_feedrate > 0.0) feedrate = next_feedrate;
4611
       if (next_feedrate > 0.0) feedrate = next_feedrate;
4605
     }
4612
     }
4689
 void process_commands() {
4696
 void process_commands() {
4690
   if (code_seen('G')) {
4697
   if (code_seen('G')) {
4691
 
4698
 
4692
-    int gCode = code_value_long();
4699
+    int gCode = code_value_short();
4693
 
4700
 
4694
     switch(gCode) {
4701
     switch(gCode) {
4695
 
4702
 
4764
   }
4771
   }
4765
 
4772
 
4766
   else if (code_seen('M')) {
4773
   else if (code_seen('M')) {
4767
-    switch( code_value_long() ) {
4774
+    switch(code_value_short()) {
4768
       #ifdef ULTIPANEL
4775
       #ifdef ULTIPANEL
4769
         case 0: // M0 - Unconditional stop - Wait for user button press on LCD
4776
         case 0: // M0 - Unconditional stop - Wait for user button press on LCD
4770
         case 1: // M1 - Conditional stop - Wait for user button press on LCD
4777
         case 1: // M1 - Conditional stop - Wait for user button press on LCD
5929
 #endif //FAST_PWM_FAN
5936
 #endif //FAST_PWM_FAN
5930
 
5937
 
5931
 bool setTargetedHotend(int code){
5938
 bool setTargetedHotend(int code){
5932
-  tmp_extruder = active_extruder;
5933
-  if(code_seen('T')) {
5934
-    tmp_extruder = code_value();
5935
-    if(tmp_extruder >= EXTRUDERS) {
5939
+  target_extruder = active_extruder;
5940
+  if (code_seen('T')) {
5941
+    target_extruder = code_value_short();
5942
+    if (target_extruder >= EXTRUDERS) {
5936
       SERIAL_ECHO_START;
5943
       SERIAL_ECHO_START;
5937
       switch(code){
5944
       switch(code){
5938
         case 104:
5945
         case 104:
5951
           SERIAL_ECHO(MSG_M221_INVALID_EXTRUDER);
5958
           SERIAL_ECHO(MSG_M221_INVALID_EXTRUDER);
5952
           break;
5959
           break;
5953
       }
5960
       }
5954
-      SERIAL_ECHOLN(tmp_extruder);
5961
+      SERIAL_ECHOLN(target_extruder);
5955
       return true;
5962
       return true;
5956
     }
5963
     }
5957
   }
5964
   }

+ 6
- 6
Marlin/cardreader.cpp View File

249
         if (!myDir.open(curDir, subdirname, O_READ)) {
249
         if (!myDir.open(curDir, subdirname, O_READ)) {
250
           SERIAL_PROTOCOLPGM(MSG_SD_OPEN_FILE_FAIL);
250
           SERIAL_PROTOCOLPGM(MSG_SD_OPEN_FILE_FAIL);
251
           SERIAL_PROTOCOL(subdirname);
251
           SERIAL_PROTOCOL(subdirname);
252
-          SERIAL_PROTOCOLLNPGM(".");
252
+          SERIAL_PROTOCOLCHAR('.');
253
           return;
253
           return;
254
         }
254
         }
255
         else {
255
         else {
287
     else {
287
     else {
288
       SERIAL_PROTOCOLPGM(MSG_SD_OPEN_FILE_FAIL);
288
       SERIAL_PROTOCOLPGM(MSG_SD_OPEN_FILE_FAIL);
289
       SERIAL_PROTOCOL(fname);
289
       SERIAL_PROTOCOL(fname);
290
-      SERIAL_PROTOCOLLNPGM(".");
290
+      SERIAL_PROTOCOLCHAR('.');
291
     }
291
     }
292
   }
292
   }
293
   else { //write
293
   else { //write
294
     if (!file.open(curDir, fname, O_CREAT | O_APPEND | O_WRITE | O_TRUNC)) {
294
     if (!file.open(curDir, fname, O_CREAT | O_APPEND | O_WRITE | O_TRUNC)) {
295
       SERIAL_PROTOCOLPGM(MSG_SD_OPEN_FILE_FAIL);
295
       SERIAL_PROTOCOLPGM(MSG_SD_OPEN_FILE_FAIL);
296
       SERIAL_PROTOCOL(fname);
296
       SERIAL_PROTOCOL(fname);
297
-      SERIAL_PROTOCOLLNPGM(".");
297
+      SERIAL_PROTOCOLCHAR('.');
298
     }
298
     }
299
     else {
299
     else {
300
       saving = true;
300
       saving = true;
330
         if (!myDir.open(curDir, subdirname, O_READ)) {
330
         if (!myDir.open(curDir, subdirname, O_READ)) {
331
           SERIAL_PROTOCOLPGM("open failed, File: ");
331
           SERIAL_PROTOCOLPGM("open failed, File: ");
332
           SERIAL_PROTOCOL(subdirname);
332
           SERIAL_PROTOCOL(subdirname);
333
-          SERIAL_PROTOCOLLNPGM(".");
333
+          SERIAL_PROTOCOLCHAR('.');
334
           return;
334
           return;
335
         }
335
         }
336
         else {
336
         else {
360
   else {
360
   else {
361
     SERIAL_PROTOCOLPGM("Deletion failed, File: ");
361
     SERIAL_PROTOCOLPGM("Deletion failed, File: ");
362
     SERIAL_PROTOCOL(fname);
362
     SERIAL_PROTOCOL(fname);
363
-    SERIAL_PROTOCOLLNPGM(".");
363
+    SERIAL_PROTOCOLCHAR('.');
364
   }
364
   }
365
 }
365
 }
366
 
366
 
368
   if (cardOK) {
368
   if (cardOK) {
369
     SERIAL_PROTOCOLPGM(MSG_SD_PRINTING_BYTE);
369
     SERIAL_PROTOCOLPGM(MSG_SD_PRINTING_BYTE);
370
     SERIAL_PROTOCOL(sdpos);
370
     SERIAL_PROTOCOL(sdpos);
371
-    SERIAL_PROTOCOLPGM("/");
371
+    SERIAL_PROTOCOLCHAR('/');
372
     SERIAL_PROTOCOLLN(filesize);
372
     SERIAL_PROTOCOLLN(filesize);
373
   }
373
   }
374
   else {
374
   else {

+ 4
- 2
Marlin/configurator/config/Configuration.h View File

553
 
553
 
554
 // @section movement
554
 // @section movement
555
 
555
 
556
-//// MOVEMENT SETTINGS
557
-#define NUM_AXIS 4 // The axis order in all axis related arrays is X, Y, Z, E
556
+/**
557
+ * MOVEMENT SETTINGS
558
+ */
559
+
558
 #define HOMING_FEEDRATE {50*60, 50*60, 4*60, 0}  // set the homing speeds (mm/min)
560
 #define HOMING_FEEDRATE {50*60, 50*60, 4*60, 0}  // set the homing speeds (mm/min)
559
 
561
 
560
 // default settings
562
 // default settings

+ 4
- 2
Marlin/example_configurations/Felix/Configuration.h View File

499
   //#define MANUAL_Z_HOME_POS 402 // For delta: Distance between nozzle and print surface after homing.
499
   //#define MANUAL_Z_HOME_POS 402 // For delta: Distance between nozzle and print surface after homing.
500
 #endif
500
 #endif
501
 
501
 
502
-//// MOVEMENT SETTINGS
503
-#define NUM_AXIS 4 // The axis order in all axis related arrays is X, Y, Z, E
502
+/**
503
+ * MOVEMENT SETTINGS
504
+ */
505
+
504
 #define HOMING_FEEDRATE {50*60, 50*60, 4*60, 0}  // set the homing speeds (mm/min)
506
 #define HOMING_FEEDRATE {50*60, 50*60, 4*60, 0}  // set the homing speeds (mm/min)
505
 
507
 
506
 // default settings
508
 // default settings

+ 4
- 2
Marlin/example_configurations/Felix/Configuration_DUAL.h View File

499
   //#define MANUAL_Z_HOME_POS 402 // For delta: Distance between nozzle and print surface after homing.
499
   //#define MANUAL_Z_HOME_POS 402 // For delta: Distance between nozzle and print surface after homing.
500
 #endif
500
 #endif
501
 
501
 
502
-//// MOVEMENT SETTINGS
503
-#define NUM_AXIS 4 // The axis order in all axis related arrays is X, Y, Z, E
502
+/**
503
+ * MOVEMENT SETTINGS
504
+ */
505
+
504
 #define HOMING_FEEDRATE {50*60, 50*60, 4*60, 0}  // set the homing speeds (mm/min)
506
 #define HOMING_FEEDRATE {50*60, 50*60, 4*60, 0}  // set the homing speeds (mm/min)
505
 
507
 
506
 // default settings
508
 // default settings

+ 4
- 2
Marlin/example_configurations/Hephestos/Configuration.h View File

522
   //#define MANUAL_Z_HOME_POS 402 // For delta: Distance between nozzle and print surface after homing.
522
   //#define MANUAL_Z_HOME_POS 402 // For delta: Distance between nozzle and print surface after homing.
523
 #endif
523
 #endif
524
 
524
 
525
-//// MOVEMENT SETTINGS
526
-#define NUM_AXIS 4 // The axis order in all axis related arrays is X, Y, Z, E
525
+/**
526
+ * MOVEMENT SETTINGS
527
+ */
528
+
527
 #define HOMING_FEEDRATE {2000, 2000, 150, 0}  // set the homing speeds (mm/min)
529
 #define HOMING_FEEDRATE {2000, 2000, 150, 0}  // set the homing speeds (mm/min)
528
 
530
 
529
 // default settings
531
 // default settings

+ 4
- 2
Marlin/example_configurations/K8200/Configuration.h View File

527
   //#define MANUAL_Z_HOME_POS 402 // For delta: Distance between nozzle and print surface after homing.
527
   //#define MANUAL_Z_HOME_POS 402 // For delta: Distance between nozzle and print surface after homing.
528
 #endif
528
 #endif
529
 
529
 
530
-//// MOVEMENT SETTINGS
531
-#define NUM_AXIS 4 // The axis order in all axis related arrays is X, Y, Z, E
530
+/**
531
+ * MOVEMENT SETTINGS
532
+ */
533
+
532
 #define HOMING_FEEDRATE {50*60, 50*60, 4*60, 0}  // set the homing speeds (mm/min)
534
 #define HOMING_FEEDRATE {50*60, 50*60, 4*60, 0}  // set the homing speeds (mm/min)
533
 
535
 
534
 // default settings
536
 // default settings

+ 4
- 2
Marlin/example_configurations/SCARA/Configuration.h View File

551
   #define MANUAL_Z_HOME_POS 0.1  // Distance between nozzle and print surface after homing.
551
   #define MANUAL_Z_HOME_POS 0.1  // Distance between nozzle and print surface after homing.
552
 #endif
552
 #endif
553
 
553
 
554
-//// MOVEMENT SETTINGS
555
-#define NUM_AXIS 4 // The axis order in all axis related arrays is X, Y, Z, E
554
+/**
555
+ * MOVEMENT SETTINGS
556
+ */
557
+
556
 #define HOMING_FEEDRATE {40*60, 40*60, 10*60, 0}  // set the homing speeds (mm/min)
558
 #define HOMING_FEEDRATE {40*60, 40*60, 10*60, 0}  // set the homing speeds (mm/min)
557
 
559
 
558
 // default settings
560
 // default settings

+ 4
- 2
Marlin/example_configurations/WITBOX/Configuration.h View File

521
   //#define MANUAL_Z_HOME_POS 402 // For delta: Distance between nozzle and print surface after homing.
521
   //#define MANUAL_Z_HOME_POS 402 // For delta: Distance between nozzle and print surface after homing.
522
 #endif
522
 #endif
523
 
523
 
524
-//// MOVEMENT SETTINGS
525
-#define NUM_AXIS 4 // The axis order in all axis related arrays is X, Y, Z, E
524
+/**
525
+ * MOVEMENT SETTINGS
526
+ */
527
+
526
 #define HOMING_FEEDRATE {120*60, 120*60, 7.2*60, 0}  // set the homing speeds (mm/min)
528
 #define HOMING_FEEDRATE {120*60, 120*60, 7.2*60, 0}  // set the homing speeds (mm/min)
527
 
529
 
528
 // default settings
530
 // default settings

+ 4
- 2
Marlin/example_configurations/delta/generic/Configuration.h View File

566
   #define MANUAL_Z_HOME_POS 250 // For delta: Distance between nozzle and print surface after homing.
566
   #define MANUAL_Z_HOME_POS 250 // For delta: Distance between nozzle and print surface after homing.
567
 #endif
567
 #endif
568
 
568
 
569
-//// MOVEMENT SETTINGS
570
-#define NUM_AXIS 4 // The axis order in all axis related arrays is X, Y, Z, E
569
+/**
570
+ * MOVEMENT SETTINGS
571
+ */
572
+
571
 
573
 
572
 // delta homing speeds must be the same on xyz
574
 // delta homing speeds must be the same on xyz
573
 #define HOMING_FEEDRATE {200*60, 200*60, 200*60, 0}  // set the homing speeds (mm/min)
575
 #define HOMING_FEEDRATE {200*60, 200*60, 200*60, 0}  // set the homing speeds (mm/min)

+ 4
- 2
Marlin/example_configurations/delta/kossel_mini/Configuration.h View File

570
   #define MANUAL_Z_HOME_POS 250 // For delta: Distance between nozzle and print surface after homing.
570
   #define MANUAL_Z_HOME_POS 250 // For delta: Distance between nozzle and print surface after homing.
571
 #endif
571
 #endif
572
 
572
 
573
-//// MOVEMENT SETTINGS
574
-#define NUM_AXIS 4 // The axis order in all axis related arrays is X, Y, Z, E
573
+/**
574
+ * MOVEMENT SETTINGS
575
+ */
576
+
575
 
577
 
576
 // delta homing speeds must be the same on xyz
578
 // delta homing speeds must be the same on xyz
577
 #define HOMING_FEEDRATE {200*60, 200*60, 200*60, 0}  // set the homing speeds (mm/min)
579
 #define HOMING_FEEDRATE {200*60, 200*60, 200*60, 0}  // set the homing speeds (mm/min)

+ 4
- 2
Marlin/example_configurations/makibox/Configuration.h View File

519
   //#define MANUAL_Z_HOME_POS 402 // For delta: Distance between nozzle and print surface after homing.
519
   //#define MANUAL_Z_HOME_POS 402 // For delta: Distance between nozzle and print surface after homing.
520
 #endif
520
 #endif
521
 
521
 
522
-//// MOVEMENT SETTINGS
523
-#define NUM_AXIS 4 // The axis order in all axis related arrays is X, Y, Z, E
522
+/**
523
+ * MOVEMENT SETTINGS
524
+ */
525
+
524
 #define HOMING_FEEDRATE {1500, 1500, 120, 0}  // set the homing speeds (mm/min)   ***** MakiBox A6 *****
526
 #define HOMING_FEEDRATE {1500, 1500, 120, 0}  // set the homing speeds (mm/min)   ***** MakiBox A6 *****
525
 
527
 
526
 // default settings
528
 // default settings

+ 4
- 2
Marlin/example_configurations/tvrrug/Round2/Configuration.h View File

521
   //#define MANUAL_Z_HOME_POS 402 // For delta: Distance between nozzle and print surface after homing.
521
   //#define MANUAL_Z_HOME_POS 402 // For delta: Distance between nozzle and print surface after homing.
522
 #endif
522
 #endif
523
 
523
 
524
-//// MOVEMENT SETTINGS
525
-#define NUM_AXIS 4 // The axis order in all axis related arrays is X, Y, Z, E
524
+/**
525
+ * MOVEMENT SETTINGS
526
+ */
527
+
526
 #define HOMING_FEEDRATE {50*60, 50*60, 4*60, 0}  // set the homing speeds (mm/min)
528
 #define HOMING_FEEDRATE {50*60, 50*60, 4*60, 0}  // set the homing speeds (mm/min)
527
 
529
 
528
 // default settings
530
 // default settings

+ 1
- 1
Marlin/planner.cpp View File

67
 //===========================================================================
67
 //===========================================================================
68
 
68
 
69
 unsigned long minsegmenttime;
69
 unsigned long minsegmenttime;
70
-float max_feedrate[NUM_AXIS]; // set the max speeds
70
+float max_feedrate[NUM_AXIS]; // Max speeds in mm per minute
71
 float axis_steps_per_unit[NUM_AXIS];
71
 float axis_steps_per_unit[NUM_AXIS];
72
 unsigned long max_acceleration_units_per_sq_second[NUM_AXIS]; // Use M201 to override by software
72
 unsigned long max_acceleration_units_per_sq_second[NUM_AXIS]; // Use M201 to override by software
73
 float minimumfeedrate;
73
 float minimumfeedrate;

+ 1
- 1
Marlin/temperature.cpp View File

84
     static unsigned long thermal_runaway_timer[4]; // = {0,0,0,0};
84
     static unsigned long thermal_runaway_timer[4]; // = {0,0,0,0};
85
   #endif
85
   #endif
86
   #if HAS_BED_THERMAL_PROTECTION
86
   #if HAS_BED_THERMAL_PROTECTION
87
-    static TRState thermal_runaway_bed_state_machine = { TRInactive, TRInactive, TRInactive, TRInactive };
87
+    static TRState thermal_runaway_bed_state_machine = TRInactive;
88
     static unsigned long thermal_runaway_bed_timer;
88
     static unsigned long thermal_runaway_bed_timer;
89
   #endif
89
   #endif
90
 #endif
90
 #endif

+ 2
- 2
Marlin/vector_3.cpp View File

125
   int count = 0;
125
   int count = 0;
126
   for(int i=0; i<3; i++) {
126
   for(int i=0; i<3; i++) {
127
     for(int j=0; j<3; j++) {
127
     for(int j=0; j<3; j++) {
128
-      if (matrix[count] >= 0.0) SERIAL_PROTOCOLPGM("+");
128
+      if (matrix[count] >= 0.0) SERIAL_PROTOCOLCHAR('+');
129
       SERIAL_PROTOCOL_F(matrix[count], 6);
129
       SERIAL_PROTOCOL_F(matrix[count], 6);
130
-      SERIAL_PROTOCOLPGM(" ");
130
+      SERIAL_PROTOCOLCHAR(' ');
131
       count++;
131
       count++;
132
     }
132
     }
133
     SERIAL_EOL;
133
     SERIAL_EOL;

Loading…
Cancel
Save