Browse Source

Merge pull request #676 from IVI053/Marlin_v1

Minor improvements for encoder configuration, LCD entry for PSU controll and thermistor pins on RAMPS
ErikZalm 10 years ago
parent
commit
46d2443c7d
3 changed files with 140 additions and 131 deletions
  1. 14
    13
      Marlin/Configuration.h
  2. 95
    91
      Marlin/Marlin_main.cpp
  3. 31
    27
      Marlin/ultralcd.cpp

+ 14
- 13
Marlin/Configuration.h View File

8
 //===========================================================================
8
 //===========================================================================
9
 //============================= DELTA Printer ===============================
9
 //============================= DELTA Printer ===============================
10
 //===========================================================================
10
 //===========================================================================
11
-// For a Delta printer rplace the configuration files wilth the files in the 
11
+// For a Delta printer rplace the configuration files wilth the files in the
12
 // example_configurations/delta directory.
12
 // example_configurations/delta directory.
13
-// 
13
+//
14
 
14
 
15
 // User-specified version info of this build to display in [Pronterface, etc] terminal window during
15
 // User-specified version info of this build to display in [Pronterface, etc] terminal window during
16
 // startup. Implementation of an idea by Prof Braino to inform user that any changes made to this
16
 // startup. Implementation of an idea by Prof Braino to inform user that any changes made to this
37
 // 12 = Gen7 v1.3
37
 // 12 = Gen7 v1.3
38
 // 13 = Gen7 v1.4
38
 // 13 = Gen7 v1.4
39
 // 2  = Cheaptronic v1.0
39
 // 2  = Cheaptronic v1.0
40
-// 20 = Sethi 3D_1 
40
+// 20 = Sethi 3D_1
41
 // 3  = MEGA/RAMPS up to 1.2 = 3
41
 // 3  = MEGA/RAMPS up to 1.2 = 3
42
 // 33 = RAMPS 1.3 / 1.4 (Power outputs: Extruder, Fan, Bed)
42
 // 33 = RAMPS 1.3 / 1.4 (Power outputs: Extruder, Fan, Bed)
43
 // 34 = RAMPS 1.3 / 1.4 (Power outputs: Extruder0, Extruder1, Bed)
43
 // 34 = RAMPS 1.3 / 1.4 (Power outputs: Extruder0, Extruder1, Bed)
336
 
336
 
337
   #define Z_RAISE_BEFORE_HOMING 4       // (in mm) Raise Z before homing (G28) for Probe Clearance.
337
   #define Z_RAISE_BEFORE_HOMING 4       // (in mm) Raise Z before homing (G28) for Probe Clearance.
338
                                         // Be sure you have this distance over your Z_MAX_POS in case
338
                                         // Be sure you have this distance over your Z_MAX_POS in case
339
-    
339
+
340
   #define XY_TRAVEL_SPEED 8000         // X and Y axis travel speed between probes, in mm/min
340
   #define XY_TRAVEL_SPEED 8000         // X and Y axis travel speed between probes, in mm/min
341
-  
341
+
342
   #define Z_RAISE_BEFORE_PROBING 15    //How much the extruder will be raised before traveling to the first probing point.
342
   #define Z_RAISE_BEFORE_PROBING 15    //How much the extruder will be raised before traveling to the first probing point.
343
   #define Z_RAISE_BETWEEN_PROBINGS 5  //How much the extruder will be raised when traveling from between next probing points
343
   #define Z_RAISE_BETWEEN_PROBINGS 5  //How much the extruder will be raised when traveling from between next probing points
344
 
344
 
347
   //The value is the delay to turn the servo off after powered on - depends on the servo speed; 300ms is good value, but you can try lower it.
347
   //The value is the delay to turn the servo off after powered on - depends on the servo speed; 300ms is good value, but you can try lower it.
348
   // You MUST HAVE the SERVO_ENDSTOPS defined to use here a value higher than zero otherwise your code will not compile.
348
   // You MUST HAVE the SERVO_ENDSTOPS defined to use here a value higher than zero otherwise your code will not compile.
349
 
349
 
350
-//  #define PROBE_SERVO_DEACTIVATION_DELAY 300  
350
+//  #define PROBE_SERVO_DEACTIVATION_DELAY 300
351
 
351
 
352
 
352
 
353
-//If you have enabled the Bed Auto Levelling and are using the same Z Probe for Z Homing, 
353
+//If you have enabled the Bed Auto Levelling and are using the same Z Probe for Z Homing,
354
 //it is highly recommended you let this Z_SAFE_HOMING enabled!!!
354
 //it is highly recommended you let this Z_SAFE_HOMING enabled!!!
355
 
355
 
356
-  #define Z_SAFE_HOMING   // This feature is meant to avoid Z homing with probe outside the bed area. 
356
+  #define Z_SAFE_HOMING   // This feature is meant to avoid Z homing with probe outside the bed area.
357
                           // When defined, it will:
357
                           // When defined, it will:
358
                           // - Allow Z homing only after X and Y homing AND stepper drivers still enabled
358
                           // - Allow Z homing only after X and Y homing AND stepper drivers still enabled
359
                           // - If stepper drivers timeout, it will need X and Y homing again before Z homing
359
                           // - If stepper drivers timeout, it will need X and Y homing again before Z homing
360
                           // - Position the probe in a defined XY point before Z Homing when homing all axis (G28)
360
                           // - Position the probe in a defined XY point before Z Homing when homing all axis (G28)
361
                           // - Block Z homing only when the probe is outside bed area.
361
                           // - Block Z homing only when the probe is outside bed area.
362
-  
362
+
363
   #ifdef Z_SAFE_HOMING
363
   #ifdef Z_SAFE_HOMING
364
-    
364
+
365
     #define Z_SAFE_HOMING_X_POINT (X_MAX_LENGTH/2)    // X point for Z homing when homing all axis (G28)
365
     #define Z_SAFE_HOMING_X_POINT (X_MAX_LENGTH/2)    // X point for Z homing when homing all axis (G28)
366
     #define Z_SAFE_HOMING_Y_POINT (Y_MAX_LENGTH/2)    // Y point for Z homing when homing all axis (G28)
366
     #define Z_SAFE_HOMING_Y_POINT (Y_MAX_LENGTH/2)    // Y point for Z homing when homing all axis (G28)
367
-    
367
+
368
   #endif
368
   #endif
369
-  
369
+
370
 #endif
370
 #endif
371
 
371
 
372
 
372
 
435
 //#define SDSUPPORT // Enable SD Card Support in Hardware Console
435
 //#define SDSUPPORT // Enable SD Card Support in Hardware Console
436
 //#define SDSLOW // Use slower SD transfer mode (not normally needed - uncomment if you're getting volume init error)
436
 //#define SDSLOW // Use slower SD transfer mode (not normally needed - uncomment if you're getting volume init error)
437
 //#define ENCODER_PULSES_PER_STEP 1 // Increase if you have a high resolution encoder
437
 //#define ENCODER_PULSES_PER_STEP 1 // Increase if you have a high resolution encoder
438
+//#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking
438
 //#define ULTIMAKERCONTROLLER //as available from the ultimaker online store.
439
 //#define ULTIMAKERCONTROLLER //as available from the ultimaker online store.
439
 //#define ULTIPANEL  //the ultipanel as on thingiverse
440
 //#define ULTIPANEL  //the ultipanel as on thingiverse
440
 
441
 
541
 // Shift register panels
542
 // Shift register panels
542
 // ---------------------
543
 // ---------------------
543
 // 2 wire Non-latching LCD SR from:
544
 // 2 wire Non-latching LCD SR from:
544
-// https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/schematics#!shiftregister-connection 
545
+// https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/schematics#!shiftregister-connection
545
 //#define SR_LCD
546
 //#define SR_LCD
546
 #ifdef SR_LCD
547
 #ifdef SR_LCD
547
    #define SR_LCD_2W_NL    // Non latching 2 wire shiftregister
548
    #define SR_LCD_2W_NL    // Non latching 2 wire shiftregister

+ 95
- 91
Marlin/Marlin_main.cpp View File

47
 
47
 
48
 #ifdef BLINKM
48
 #ifdef BLINKM
49
 #include "BlinkM.h"
49
 #include "BlinkM.h"
50
-#include "Wire.h" 
50
+#include "Wire.h"
51
 #endif
51
 #endif
52
 
52
 
53
 #if NUM_SERVOS > 0
53
 #if NUM_SERVOS > 0
96
 // M29  - Stop SD write
96
 // M29  - Stop SD write
97
 // M30  - Delete file from SD (M30 filename.g)
97
 // M30  - Delete file from SD (M30 filename.g)
98
 // M31  - Output time since last M109 or SD card start to serial
98
 // M31  - Output time since last M109 or SD card start to serial
99
-// M32  - Select file and start SD print (Can be used _while_ printing from SD card files): 
99
+// M32  - Select file and start SD print (Can be used _while_ printing from SD card files):
100
 //        syntax "M32 /path/filename#", or "M32 S<startpos bytes> !filename#"
100
 //        syntax "M32 /path/filename#", or "M32 S<startpos bytes> !filename#"
101
 //        Call gcode file : "M32 P !filename#" and return to caller file after finishing (simiarl to #include).
101
 //        Call gcode file : "M32 P !filename#" and return to caller file after finishing (simiarl to #include).
102
 //        The '#' is necessary when calling from within sd files, as it stops buffer prereading
102
 //        The '#' is necessary when calling from within sd files, as it stops buffer prereading
226
 #endif
226
 #endif
227
 
227
 
228
 #ifdef ULTIPANEL
228
 #ifdef ULTIPANEL
229
-	bool powersupply = true;
229
+  #ifdef PS_DEFAULT_OFF
230
+    bool powersupply = false;
231
+  #else
232
+	  bool powersupply = true;
233
+  #endif
230
 #endif
234
 #endif
231
 
235
 
232
 #ifdef DELTA
236
 #ifdef DELTA
415
 
419
 
416
   #if defined (ENABLE_AUTO_BED_LEVELING) && (PROBE_SERVO_DEACTIVATION_DELAY > 0)
420
   #if defined (ENABLE_AUTO_BED_LEVELING) && (PROBE_SERVO_DEACTIVATION_DELAY > 0)
417
   delay(PROBE_SERVO_DEACTIVATION_DELAY);
421
   delay(PROBE_SERVO_DEACTIVATION_DELAY);
418
-  servos[servo_endstops[Z_AXIS]].detach();  
422
+  servos[servo_endstops[Z_AXIS]].detach();
419
   #endif
423
   #endif
420
 }
424
 }
421
 
425
 
636
   if(!card.sdprinting || serial_count!=0){
640
   if(!card.sdprinting || serial_count!=0){
637
     return;
641
     return;
638
   }
642
   }
639
-  
643
+
640
   //'#' stops reading from sd to the buffer prematurely, so procedural macro calls are possible
644
   //'#' stops reading from sd to the buffer prematurely, so procedural macro calls are possible
641
-  // if it occures, stop_buffering is triggered and the buffer is ran dry. 
645
+  // if it occures, stop_buffering is triggered and the buffer is ran dry.
642
   // this character _can_ occure in serial com, due to checksums. however, no checksums are used in sd printing
646
   // this character _can_ occure in serial com, due to checksums. however, no checksums are used in sd printing
643
-  
647
+
644
   static bool stop_buffering=false;
648
   static bool stop_buffering=false;
645
   if(buflen==0) stop_buffering=false;
649
   if(buflen==0) stop_buffering=false;
646
-  
647
-  while( !card.eof()  && buflen < BUFSIZE && !stop_buffering) { 
650
+
651
+  while( !card.eof()  && buflen < BUFSIZE && !stop_buffering) {
648
     int16_t n=card.get();
652
     int16_t n=card.get();
649
-    serial_char = (char)n; 
653
+    serial_char = (char)n;
650
     if(serial_char == '\n' ||
654
     if(serial_char == '\n' ||
651
        serial_char == '\r' ||
655
        serial_char == '\r' ||
652
        (serial_char == '#' && comment_mode == false) ||
656
        (serial_char == '#' && comment_mode == false) ||
671
       }
675
       }
672
       if(serial_char=='#')
676
       if(serial_char=='#')
673
         stop_buffering=true;
677
         stop_buffering=true;
674
-      
678
+
675
       if(!serial_count)
679
       if(!serial_count)
676
       {
680
       {
677
         comment_mode = false; //for new command
681
         comment_mode = false; //for new command
743
   #endif
747
   #endif
744
   #if X_HOME_DIR != -1 || X2_HOME_DIR != 1
748
   #if X_HOME_DIR != -1 || X2_HOME_DIR != 1
745
     #error "Please use canonical x-carriage assignment" // the x-carriages are defined by their homing directions
749
     #error "Please use canonical x-carriage assignment" // the x-carriages are defined by their homing directions
746
-  #endif  
750
+  #endif
747
 
751
 
748
 #define DXC_FULL_CONTROL_MODE 0
752
 #define DXC_FULL_CONTROL_MODE 0
749
 #define DXC_AUTO_PARK_MODE    1
753
 #define DXC_AUTO_PARK_MODE    1
750
 #define DXC_DUPLICATION_MODE  2
754
 #define DXC_DUPLICATION_MODE  2
751
 static int dual_x_carriage_mode = DEFAULT_DUAL_X_CARRIAGE_MODE;
755
 static int dual_x_carriage_mode = DEFAULT_DUAL_X_CARRIAGE_MODE;
752
- 
756
+
753
 static float x_home_pos(int extruder) {
757
 static float x_home_pos(int extruder) {
754
   if (extruder == 0)
758
   if (extruder == 0)
755
     return base_home_pos(X_AXIS) + add_homeing[X_AXIS];
759
     return base_home_pos(X_AXIS) + add_homeing[X_AXIS];
767
 
771
 
768
 static float inactive_extruder_x_pos = X2_MAX_POS; // used in mode 0 & 1
772
 static float inactive_extruder_x_pos = X2_MAX_POS; // used in mode 0 & 1
769
 static bool active_extruder_parked = false; // used in mode 1 & 2
773
 static bool active_extruder_parked = false; // used in mode 1 & 2
770
-static float raised_parked_position[NUM_AXIS]; // used in mode 1 
771
-static unsigned long delayed_move_time = 0; // used in mode 1 
774
+static float raised_parked_position[NUM_AXIS]; // used in mode 1
775
+static unsigned long delayed_move_time = 0; // used in mode 1
772
 static float duplicate_extruder_x_offset = DEFAULT_DUPLICATION_X_OFFSET; // used in mode 2
776
 static float duplicate_extruder_x_offset = DEFAULT_DUPLICATION_X_OFFSET; // used in mode 2
773
 static float duplicate_extruder_temp_offset = 0; // used in mode 2
777
 static float duplicate_extruder_temp_offset = 0; // used in mode 2
774
 bool extruder_duplication_enabled = false; // used in mode 2
778
 bool extruder_duplication_enabled = false; // used in mode 2
775
-#endif //DUAL_X_CARRIAGE    
779
+#endif //DUAL_X_CARRIAGE
776
 
780
 
777
 static void axis_is_at_home(int axis) {
781
 static void axis_is_at_home(int axis) {
778
 #ifdef DUAL_X_CARRIAGE
782
 #ifdef DUAL_X_CARRIAGE
785
     }
789
     }
786
     else if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && active_extruder == 0) {
790
     else if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && active_extruder == 0) {
787
       current_position[X_AXIS] = base_home_pos(X_AXIS) + add_homeing[X_AXIS];
791
       current_position[X_AXIS] = base_home_pos(X_AXIS) + add_homeing[X_AXIS];
788
-      min_pos[X_AXIS] =          base_min_pos(X_AXIS) + add_homeing[X_AXIS]; 
789
-      max_pos[X_AXIS] =          min(base_max_pos(X_AXIS) + add_homeing[X_AXIS], 
792
+      min_pos[X_AXIS] =          base_min_pos(X_AXIS) + add_homeing[X_AXIS];
793
+      max_pos[X_AXIS] =          min(base_max_pos(X_AXIS) + add_homeing[X_AXIS],
790
                                   max(extruder_offset[X_AXIS][1], X2_MAX_POS) - duplicate_extruder_x_offset);
794
                                   max(extruder_offset[X_AXIS][1], X2_MAX_POS) - duplicate_extruder_x_offset);
791
       return;
795
       return;
792
     }
796
     }
853
     st_synchronize();
857
     st_synchronize();
854
 
858
 
855
     // move back down slowly to find bed
859
     // move back down slowly to find bed
856
-    feedrate = homing_feedrate[Z_AXIS]/4; 
860
+    feedrate = homing_feedrate[Z_AXIS]/4;
857
     zPosition -= home_retract_mm(Z_AXIS) * 2;
861
     zPosition -= home_retract_mm(Z_AXIS) * 2;
858
     plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], zPosition, current_position[E_AXIS], feedrate/60, active_extruder);
862
     plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], zPosition, current_position[E_AXIS], feedrate/60, active_extruder);
859
     st_synchronize();
863
     st_synchronize();
950
 
954
 
951
     current_position[axis] = 0;
955
     current_position[axis] = 0;
952
     plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
956
     plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
953
-	
957
+
954
 
958
 
955
     // Engage Servo endstop if enabled
959
     // Engage Servo endstop if enabled
956
     #ifdef SERVO_ENDSTOPS
960
     #ifdef SERVO_ENDSTOPS
1008
 #if defined (ENABLE_AUTO_BED_LEVELING) && (PROBE_SERVO_DEACTIVATION_DELAY > 0)
1012
 #if defined (ENABLE_AUTO_BED_LEVELING) && (PROBE_SERVO_DEACTIVATION_DELAY > 0)
1009
     if (axis==Z_AXIS) retract_z_probe();
1013
     if (axis==Z_AXIS) retract_z_probe();
1010
 #endif
1014
 #endif
1011
-    
1015
+
1012
   }
1016
   }
1013
 }
1017
 }
1014
 #define HOMEAXIS(LETTER) homeaxis(LETTER##_AXIS)
1018
 #define HOMEAXIS(LETTER) homeaxis(LETTER##_AXIS)
1082
         destination[Y_AXIS]=current_position[Y_AXIS];
1086
         destination[Y_AXIS]=current_position[Y_AXIS];
1083
         destination[Z_AXIS]=current_position[Z_AXIS];
1087
         destination[Z_AXIS]=current_position[Z_AXIS];
1084
         current_position[Z_AXIS]+=retract_zlift;
1088
         current_position[Z_AXIS]+=retract_zlift;
1085
-        destination[E_AXIS]=current_position[E_AXIS]+retract_length+retract_recover_length; 
1089
+        destination[E_AXIS]=current_position[E_AXIS]+retract_length+retract_recover_length;
1086
         feedrate=retract_recover_feedrate;
1090
         feedrate=retract_recover_feedrate;
1087
         retracted=false;
1091
         retracted=false;
1088
         prepare_move();
1092
         prepare_move();
1196
         // reset state used by the different modes
1200
         // reset state used by the different modes
1197
         memcpy(raised_parked_position, current_position, sizeof(raised_parked_position));
1201
         memcpy(raised_parked_position, current_position, sizeof(raised_parked_position));
1198
         delayed_move_time = 0;
1202
         delayed_move_time = 0;
1199
-        active_extruder_parked = true; 
1200
-      #else      
1203
+        active_extruder_parked = true;
1204
+      #else
1201
         HOMEAXIS(X);
1205
         HOMEAXIS(X);
1202
-      #endif         
1206
+      #endif
1203
       }
1207
       }
1204
 
1208
 
1205
       if((home_all_axis) || (code_seen(axis_codes[Y_AXIS]))) {
1209
       if((home_all_axis) || (code_seen(axis_codes[Y_AXIS]))) {
1218
           current_position[Y_AXIS]=code_value()+add_homeing[1];
1222
           current_position[Y_AXIS]=code_value()+add_homeing[1];
1219
         }
1223
         }
1220
       }
1224
       }
1221
-      
1225
+
1222
       #if Z_HOME_DIR < 0                      // If homing towards BED do Z last
1226
       #if Z_HOME_DIR < 0                      // If homing towards BED do Z last
1223
         #ifndef Z_SAFE_HOMING
1227
         #ifndef Z_SAFE_HOMING
1224
           if((home_all_axis) || (code_seen(axis_codes[Z_AXIS]))) {
1228
           if((home_all_axis) || (code_seen(axis_codes[Z_AXIS]))) {
1230
             #endif
1234
             #endif
1231
             HOMEAXIS(Z);
1235
             HOMEAXIS(Z);
1232
           }
1236
           }
1233
-        #else                      // Z Safe mode activated. 
1237
+        #else                      // Z Safe mode activated.
1234
           if(home_all_axis) {
1238
           if(home_all_axis) {
1235
             destination[X_AXIS] = round(Z_SAFE_HOMING_X_POINT - X_PROBE_OFFSET_FROM_EXTRUDER);
1239
             destination[X_AXIS] = round(Z_SAFE_HOMING_X_POINT - X_PROBE_OFFSET_FROM_EXTRUDER);
1236
             destination[Y_AXIS] = round(Z_SAFE_HOMING_Y_POINT - Y_PROBE_OFFSET_FROM_EXTRUDER);
1240
             destination[Y_AXIS] = round(Z_SAFE_HOMING_Y_POINT - Y_PROBE_OFFSET_FROM_EXTRUDER);
1237
             destination[Z_AXIS] = Z_RAISE_BEFORE_HOMING * home_dir(Z_AXIS) * (-1);    // Set destination away from bed
1241
             destination[Z_AXIS] = Z_RAISE_BEFORE_HOMING * home_dir(Z_AXIS) * (-1);    // Set destination away from bed
1238
             feedrate = XY_TRAVEL_SPEED;
1242
             feedrate = XY_TRAVEL_SPEED;
1239
             current_position[Z_AXIS] = 0;
1243
             current_position[Z_AXIS] = 0;
1240
-			
1244
+
1241
             plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
1245
             plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
1242
             plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate, active_extruder);
1246
             plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate, active_extruder);
1243
             st_synchronize();
1247
             st_synchronize();
1255
               && (current_position[Y_AXIS]+Y_PROBE_OFFSET_FROM_EXTRUDER <= Y_MAX_POS)) {
1259
               && (current_position[Y_AXIS]+Y_PROBE_OFFSET_FROM_EXTRUDER <= Y_MAX_POS)) {
1256
 
1260
 
1257
               current_position[Z_AXIS] = 0;
1261
               current_position[Z_AXIS] = 0;
1258
-              plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);			  
1262
+              plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
1259
               destination[Z_AXIS] = Z_RAISE_BEFORE_HOMING * home_dir(Z_AXIS) * (-1);    // Set destination away from bed
1263
               destination[Z_AXIS] = Z_RAISE_BEFORE_HOMING * home_dir(Z_AXIS) * (-1);    // Set destination away from bed
1260
               feedrate = max_feedrate[Z_AXIS];
1264
               feedrate = max_feedrate[Z_AXIS];
1261
               plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate, active_extruder);
1265
               plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate, active_extruder);
1275
         #endif
1279
         #endif
1276
       #endif
1280
       #endif
1277
 
1281
 
1278
-      
1279
-     
1282
+
1283
+
1280
       if(code_seen(axis_codes[Z_AXIS])) {
1284
       if(code_seen(axis_codes[Z_AXIS])) {
1281
         if(code_value_long() != 0) {
1285
         if(code_value_long() != 0) {
1282
           current_position[Z_AXIS]=code_value()+add_homeing[2];
1286
           current_position[Z_AXIS]=code_value()+add_homeing[2];
1347
             run_z_probe();
1351
             run_z_probe();
1348
             float z_at_xLeft_yFront = current_position[Z_AXIS];
1352
             float z_at_xLeft_yFront = current_position[Z_AXIS];
1349
             retract_z_probe();
1353
             retract_z_probe();
1350
-            
1354
+
1351
             SERIAL_PROTOCOLPGM("Bed x: ");
1355
             SERIAL_PROTOCOLPGM("Bed x: ");
1352
             SERIAL_PROTOCOL(LEFT_PROBE_BED_POSITION);
1356
             SERIAL_PROTOCOL(LEFT_PROBE_BED_POSITION);
1353
             SERIAL_PROTOCOLPGM(" y: ");
1357
             SERIAL_PROTOCOLPGM(" y: ");
1365
             run_z_probe();
1369
             run_z_probe();
1366
             float z_at_xRight_yFront = current_position[Z_AXIS];
1370
             float z_at_xRight_yFront = current_position[Z_AXIS];
1367
             retract_z_probe(); // Retract Z Servo endstop if available
1371
             retract_z_probe(); // Retract Z Servo endstop if available
1368
-            
1372
+
1369
             SERIAL_PROTOCOLPGM("Bed x: ");
1373
             SERIAL_PROTOCOLPGM("Bed x: ");
1370
             SERIAL_PROTOCOL(RIGHT_PROBE_BED_POSITION);
1374
             SERIAL_PROTOCOL(RIGHT_PROBE_BED_POSITION);
1371
             SERIAL_PROTOCOLPGM(" y: ");
1375
             SERIAL_PROTOCOLPGM(" y: ");
1378
 
1382
 
1379
             set_bed_level_equation(z_at_xLeft_yFront, z_at_xRight_yFront, z_at_xLeft_yBack);
1383
             set_bed_level_equation(z_at_xLeft_yFront, z_at_xRight_yFront, z_at_xLeft_yBack);
1380
 
1384
 
1381
-            st_synchronize();            
1385
+            st_synchronize();
1382
 
1386
 
1383
             // The following code correct the Z height difference from z-probe position and hotend tip position.
1387
             // The following code correct the Z height difference from z-probe position and hotend tip position.
1384
-            // The Z height on homing is measured by Z-Probe, but the probe is quite far from the hotend. 
1388
+            // The Z height on homing is measured by Z-Probe, but the probe is quite far from the hotend.
1385
             // When the bed is uneven, this height must be corrected.
1389
             // When the bed is uneven, this height must be corrected.
1386
             real_z = float(st_get_position(Z_AXIS))/axis_steps_per_unit[Z_AXIS];  //get the real Z (since the auto bed leveling is already correcting the plane)
1390
             real_z = float(st_get_position(Z_AXIS))/axis_steps_per_unit[Z_AXIS];  //get the real Z (since the auto bed leveling is already correcting the plane)
1387
             x_tmp = current_position[X_AXIS] + X_PROBE_OFFSET_FROM_EXTRUDER;
1391
             x_tmp = current_position[X_AXIS] + X_PROBE_OFFSET_FROM_EXTRUDER;
1393
             plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
1397
             plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
1394
         }
1398
         }
1395
         break;
1399
         break;
1396
-        
1400
+
1397
     case 30: // G30 Single Z Probe
1401
     case 30: // G30 Single Z Probe
1398
         {
1402
         {
1399
             engage_z_probe(); // Engage Z Servo endstop if available
1403
             engage_z_probe(); // Engage Z Servo endstop if available
1400
-            
1404
+
1401
             st_synchronize();
1405
             st_synchronize();
1402
             // TODO: make sure the bed_level_rotation_matrix is identity or the planner will get set incorectly
1406
             // TODO: make sure the bed_level_rotation_matrix is identity or the planner will get set incorectly
1403
             setup_for_endstop_move();
1407
             setup_for_endstop_move();
1548
         card.removeFile(strchr_pointer + 4);
1552
         card.removeFile(strchr_pointer + 4);
1549
       }
1553
       }
1550
       break;
1554
       break;
1551
-    case 32: //M32 - Select file and start SD print 
1555
+    case 32: //M32 - Select file and start SD print
1552
     {
1556
     {
1553
       if(card.sdprinting) {
1557
       if(card.sdprinting) {
1554
         st_synchronize();
1558
         st_synchronize();
1555
 
1559
 
1556
       }
1560
       }
1557
-      starpos = (strchr(strchr_pointer + 4,'*')); 
1558
-      
1561
+      starpos = (strchr(strchr_pointer + 4,'*'));
1562
+
1559
       char* namestartpos = (strchr(strchr_pointer + 4,'!'));   //find ! to indicate filename string start.
1563
       char* namestartpos = (strchr(strchr_pointer + 4,'!'));   //find ! to indicate filename string start.
1560
       if(namestartpos==NULL)
1564
       if(namestartpos==NULL)
1561
       {
1565
       {
1563
       }
1567
       }
1564
       else
1568
       else
1565
         namestartpos++; //to skip the '!'
1569
         namestartpos++; //to skip the '!'
1566
-        
1570
+
1567
       if(starpos!=NULL)
1571
       if(starpos!=NULL)
1568
         *(starpos-1)='\0';
1572
         *(starpos-1)='\0';
1569
-            
1573
+
1570
       bool call_procedure=(code_seen('P'));
1574
       bool call_procedure=(code_seen('P'));
1571
-      
1572
-      if(strchr_pointer>namestartpos) 
1575
+
1576
+      if(strchr_pointer>namestartpos)
1573
         call_procedure=false;  //false alert, 'P' found within filename
1577
         call_procedure=false;  //false alert, 'P' found within filename
1574
-      
1575
-      if( card.cardOK ) 
1578
+
1579
+      if( card.cardOK )
1576
       {
1580
       {
1577
         card.openFile(namestartpos,true,!call_procedure);
1581
         card.openFile(namestartpos,true,!call_procedure);
1578
         if(code_seen('S'))
1582
         if(code_seen('S'))
1645
 #ifdef DUAL_X_CARRIAGE
1649
 #ifdef DUAL_X_CARRIAGE
1646
       if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && tmp_extruder == 0)
1650
       if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && tmp_extruder == 0)
1647
         setTargetHotend1(code_value() == 0.0 ? 0.0 : code_value() + duplicate_extruder_temp_offset);
1651
         setTargetHotend1(code_value() == 0.0 ? 0.0 : code_value() + duplicate_extruder_temp_offset);
1648
-#endif          
1652
+#endif
1649
       setWatch();
1653
       setWatch();
1650
       break;
1654
       break;
1651
     case 140: // M140 set bed temp
1655
     case 140: // M140 set bed temp
1701
             SERIAL_PROTOCOL_F(rawHotendTemp(cur_extruder)/OVERSAMPLENR,0);
1705
             SERIAL_PROTOCOL_F(rawHotendTemp(cur_extruder)/OVERSAMPLENR,0);
1702
           }
1706
           }
1703
         #endif
1707
         #endif
1704
-		
1708
+
1705
         SERIAL_PROTOCOLLN("");
1709
         SERIAL_PROTOCOLLN("");
1706
       return;
1710
       return;
1707
       break;
1711
       break;
1719
 #ifdef DUAL_X_CARRIAGE
1723
 #ifdef DUAL_X_CARRIAGE
1720
         if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && tmp_extruder == 0)
1724
         if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && tmp_extruder == 0)
1721
           setTargetHotend1(code_value() == 0.0 ? 0.0 : code_value() + duplicate_extruder_temp_offset);
1725
           setTargetHotend1(code_value() == 0.0 ? 0.0 : code_value() + duplicate_extruder_temp_offset);
1722
-#endif          
1726
+#endif
1723
         CooldownNoWait = true;
1727
         CooldownNoWait = true;
1724
       } else if (code_seen('R')) {
1728
       } else if (code_seen('R')) {
1725
         setTargetHotend(code_value(), tmp_extruder);
1729
         setTargetHotend(code_value(), tmp_extruder);
1726
 #ifdef DUAL_X_CARRIAGE
1730
 #ifdef DUAL_X_CARRIAGE
1727
         if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && tmp_extruder == 0)
1731
         if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && tmp_extruder == 0)
1728
           setTargetHotend1(code_value() == 0.0 ? 0.0 : code_value() + duplicate_extruder_temp_offset);
1732
           setTargetHotend1(code_value() == 0.0 ? 0.0 : code_value() + duplicate_extruder_temp_offset);
1729
-#endif          
1733
+#endif
1730
         CooldownNoWait = false;
1734
         CooldownNoWait = false;
1731
       }
1735
       }
1732
       #ifdef AUTOTEMP
1736
       #ifdef AUTOTEMP
1890
             SET_OUTPUT(SUICIDE_PIN);
1894
             SET_OUTPUT(SUICIDE_PIN);
1891
             WRITE(SUICIDE_PIN, HIGH);
1895
             WRITE(SUICIDE_PIN, HIGH);
1892
         #endif
1896
         #endif
1893
-        
1897
+
1894
         #ifdef ULTIPANEL
1898
         #ifdef ULTIPANEL
1895
           powersupply = true;
1899
           powersupply = true;
1896
           LCD_MESSAGEPGM(WELCOME_MSG);
1900
           LCD_MESSAGEPGM(WELCOME_MSG);
2047
       #endif
2051
       #endif
2048
       break;
2052
       break;
2049
       //TODO: update for all axis, use for loop
2053
       //TODO: update for all axis, use for loop
2050
-    #ifdef BLINKM  
2054
+    #ifdef BLINKM
2051
     case 150: // M150
2055
     case 150: // M150
2052
       {
2056
       {
2053
         byte red;
2057
         byte red;
2054
         byte grn;
2058
         byte grn;
2055
         byte blu;
2059
         byte blu;
2056
-        
2060
+
2057
         if(code_seen('R')) red = code_value();
2061
         if(code_seen('R')) red = code_value();
2058
         if(code_seen('U')) grn = code_value();
2062
         if(code_seen('U')) grn = code_value();
2059
         if(code_seen('B')) blu = code_value();
2063
         if(code_seen('B')) blu = code_value();
2060
-        
2061
-        SendColors(red,grn,blu);        
2064
+
2065
+        SendColors(red,grn,blu);
2062
       }
2066
       }
2063
       break;
2067
       break;
2064
     #endif //BLINKM
2068
     #endif //BLINKM
2180
       {
2184
       {
2181
         extruder_offset[Z_AXIS][tmp_extruder] = code_value();
2185
         extruder_offset[Z_AXIS][tmp_extruder] = code_value();
2182
       }
2186
       }
2183
-      #endif       
2187
+      #endif
2184
       SERIAL_ECHO_START;
2188
       SERIAL_ECHO_START;
2185
       SERIAL_ECHOPGM(MSG_HOTEND_OFFSET);
2189
       SERIAL_ECHOPGM(MSG_HOTEND_OFFSET);
2186
       for(tmp_extruder = 0; tmp_extruder < EXTRUDERS; tmp_extruder++)
2190
       for(tmp_extruder = 0; tmp_extruder < EXTRUDERS; tmp_extruder++)
2213
       }
2217
       }
2214
     }
2218
     }
2215
     break;
2219
     break;
2216
-	
2220
+
2217
 	case 226: // M226 P<pin number> S<pin state>- Wait until the specified pin reaches the state required
2221
 	case 226: // M226 P<pin number> S<pin state>- Wait until the specified pin reaches the state required
2218
 	{
2222
 	{
2219
       if(code_seen('P')){
2223
       if(code_seen('P')){
2220
         int pin_number = code_value(); // pin number
2224
         int pin_number = code_value(); // pin number
2221
         int pin_state = -1; // required pin state - default is inverted
2225
         int pin_state = -1; // required pin state - default is inverted
2222
-        
2226
+
2223
         if(code_seen('S')) pin_state = code_value(); // required pin state
2227
         if(code_seen('S')) pin_state = code_value(); // required pin state
2224
-      
2228
+
2225
         if(pin_state >= -1 && pin_state <= 1){
2229
         if(pin_state >= -1 && pin_state <= 1){
2226
-        
2230
+
2227
           for(int8_t i = 0; i < (int8_t)sizeof(sensitive_pins); i++)
2231
           for(int8_t i = 0; i < (int8_t)sizeof(sensitive_pins); i++)
2228
           {
2232
           {
2229
             if (sensitive_pins[i] == pin_number)
2233
             if (sensitive_pins[i] == pin_number)
2232
               break;
2236
               break;
2233
             }
2237
             }
2234
           }
2238
           }
2235
-        
2239
+
2236
           if (pin_number > -1)
2240
           if (pin_number > -1)
2237
           {
2241
           {
2238
             st_synchronize();
2242
             st_synchronize();
2239
-            
2243
+
2240
             pinMode(pin_number, INPUT);
2244
             pinMode(pin_number, INPUT);
2241
-            
2245
+
2242
             int target;
2246
             int target;
2243
             switch(pin_state){
2247
             switch(pin_state){
2244
             case 1:
2248
             case 1:
2245
               target = HIGH;
2249
               target = HIGH;
2246
               break;
2250
               break;
2247
-            
2251
+
2248
             case 0:
2252
             case 0:
2249
               target = LOW;
2253
               target = LOW;
2250
               break;
2254
               break;
2251
-            
2255
+
2252
             case -1:
2256
             case -1:
2253
               target = !digitalRead(pin_number);
2257
               target = !digitalRead(pin_number);
2254
               break;
2258
               break;
2255
             }
2259
             }
2256
-            
2260
+
2257
             while(digitalRead(pin_number) != target){
2261
             while(digitalRead(pin_number) != target){
2258
               manage_heater();
2262
               manage_heater();
2259
               manage_inactivity();
2263
               manage_inactivity();
2263
         }
2267
         }
2264
       }
2268
       }
2265
     }
2269
     }
2266
-    break;	
2270
+    break;
2267
 
2271
 
2268
     #if NUM_SERVOS > 0
2272
     #if NUM_SERVOS > 0
2269
     case 280: // M280 - set servo position absolute. P: servo index, S: angle or microseconds
2273
     case 280: // M280 - set servo position absolute. P: servo index, S: angle or microseconds
2439
         engage_z_probe();    // Engage Z Servo endstop if available
2443
         engage_z_probe();    // Engage Z Servo endstop if available
2440
     }
2444
     }
2441
     break;
2445
     break;
2442
-    
2446
+
2443
     case 402:
2447
     case 402:
2444
     {
2448
     {
2445
         retract_z_probe();    // Retract Z Servo endstop if enabled
2449
         retract_z_probe();    // Retract Z Servo endstop if enabled
2446
     }
2450
     }
2447
     break;
2451
     break;
2448
-#endif    
2452
+#endif
2449
     case 500: // M500 Store settings in EEPROM
2453
     case 500: // M500 Store settings in EEPROM
2450
     {
2454
     {
2451
         Config_StoreSettings();
2455
         Config_StoreSettings();
2603
               //    M605 S0: Full control mode. The slicer has full control over x-carriage movement
2607
               //    M605 S0: Full control mode. The slicer has full control over x-carriage movement
2604
               //    M605 S1: Auto-park mode. The inactive head will auto park/unpark without slicer involvement
2608
               //    M605 S1: Auto-park mode. The inactive head will auto park/unpark without slicer involvement
2605
               //    M605 S2 [Xnnn] [Rmmm]: Duplication mode. The second extruder will duplicate the first with nnn
2609
               //    M605 S2 [Xnnn] [Rmmm]: Duplication mode. The second extruder will duplicate the first with nnn
2606
-              //                         millimeters x-offset and an optional differential hotend temperature of 
2610
+              //                         millimeters x-offset and an optional differential hotend temperature of
2607
               //                         mmm degrees. E.g., with "M605 S2 X100 R2" the second extruder will duplicate
2611
               //                         mmm degrees. E.g., with "M605 S2 X100 R2" the second extruder will duplicate
2608
               //                         the first with a spacing of 100mm in the x direction and 2 degrees hotter.
2612
               //                         the first with a spacing of 100mm in the x direction and 2 degrees hotter.
2609
               //
2613
               //
2610
               //    Note: the X axis should be homed after changing dual x-carriage mode.
2614
               //    Note: the X axis should be homed after changing dual x-carriage mode.
2611
     {
2615
     {
2612
         st_synchronize();
2616
         st_synchronize();
2613
-        
2617
+
2614
         if (code_seen('S'))
2618
         if (code_seen('S'))
2615
           dual_x_carriage_mode = code_value();
2619
           dual_x_carriage_mode = code_value();
2616
 
2620
 
2621
 
2625
 
2622
           if (code_seen('R'))
2626
           if (code_seen('R'))
2623
             duplicate_extruder_temp_offset = code_value();
2627
             duplicate_extruder_temp_offset = code_value();
2624
-            
2628
+
2625
           SERIAL_ECHO_START;
2629
           SERIAL_ECHO_START;
2626
           SERIAL_ECHOPGM(MSG_HOTEND_OFFSET);
2630
           SERIAL_ECHOPGM(MSG_HOTEND_OFFSET);
2627
           SERIAL_ECHO(" ");
2631
           SERIAL_ECHO(" ");
2637
         {
2641
         {
2638
           dual_x_carriage_mode = DEFAULT_DUAL_X_CARRIAGE_MODE;
2642
           dual_x_carriage_mode = DEFAULT_DUAL_X_CARRIAGE_MODE;
2639
         }
2643
         }
2640
-        
2644
+
2641
         active_extruder_parked = false;
2645
         active_extruder_parked = false;
2642
         extruder_duplication_enabled = false;
2646
         extruder_duplication_enabled = false;
2643
         delayed_move_time = 0;
2647
         delayed_move_time = 0;
2644
     }
2648
     }
2645
     break;
2649
     break;
2646
-    #endif //DUAL_X_CARRIAGE         
2650
+    #endif //DUAL_X_CARRIAGE
2647
 
2651
 
2648
     case 907: // M907 Set digital trimpot motor current using axis codes.
2652
     case 907: // M907 Set digital trimpot motor current using axis codes.
2649
     {
2653
     {
2724
         // Save current position to return to after applying extruder offset
2728
         // Save current position to return to after applying extruder offset
2725
         memcpy(destination, current_position, sizeof(destination));
2729
         memcpy(destination, current_position, sizeof(destination));
2726
       #ifdef DUAL_X_CARRIAGE
2730
       #ifdef DUAL_X_CARRIAGE
2727
-        if (dual_x_carriage_mode == DXC_AUTO_PARK_MODE && Stopped == false && 
2731
+        if (dual_x_carriage_mode == DXC_AUTO_PARK_MODE && Stopped == false &&
2728
             (delayed_move_time != 0 || current_position[X_AXIS] != x_home_pos(active_extruder)))
2732
             (delayed_move_time != 0 || current_position[X_AXIS] != x_home_pos(active_extruder)))
2729
         {
2733
         {
2730
           // Park old head: 1) raise 2) move to park position 3) lower
2734
           // Park old head: 1) raise 2) move to park position 3) lower
2731
-          plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] + TOOLCHANGE_PARK_ZLIFT, 
2735
+          plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] + TOOLCHANGE_PARK_ZLIFT,
2732
                 current_position[E_AXIS], max_feedrate[Z_AXIS], active_extruder);
2736
                 current_position[E_AXIS], max_feedrate[Z_AXIS], active_extruder);
2733
-          plan_buffer_line(x_home_pos(active_extruder), current_position[Y_AXIS], current_position[Z_AXIS] + TOOLCHANGE_PARK_ZLIFT, 
2737
+          plan_buffer_line(x_home_pos(active_extruder), current_position[Y_AXIS], current_position[Z_AXIS] + TOOLCHANGE_PARK_ZLIFT,
2734
                 current_position[E_AXIS], max_feedrate[X_AXIS], active_extruder);
2738
                 current_position[E_AXIS], max_feedrate[X_AXIS], active_extruder);
2735
-          plan_buffer_line(x_home_pos(active_extruder), current_position[Y_AXIS], current_position[Z_AXIS], 
2739
+          plan_buffer_line(x_home_pos(active_extruder), current_position[Y_AXIS], current_position[Z_AXIS],
2736
                 current_position[E_AXIS], max_feedrate[Z_AXIS], active_extruder);
2740
                 current_position[E_AXIS], max_feedrate[Z_AXIS], active_extruder);
2737
           st_synchronize();
2741
           st_synchronize();
2738
         }
2742
         }
2739
-        
2743
+
2740
         // apply Y & Z extruder offset (x offset is already used in determining home pos)
2744
         // apply Y & Z extruder offset (x offset is already used in determining home pos)
2741
         current_position[Y_AXIS] = current_position[Y_AXIS] -
2745
         current_position[Y_AXIS] = current_position[Y_AXIS] -
2742
                      extruder_offset[Y_AXIS][active_extruder] +
2746
                      extruder_offset[Y_AXIS][active_extruder] +
2744
         current_position[Z_AXIS] = current_position[Z_AXIS] -
2748
         current_position[Z_AXIS] = current_position[Z_AXIS] -
2745
                      extruder_offset[Z_AXIS][active_extruder] +
2749
                      extruder_offset[Z_AXIS][active_extruder] +
2746
                      extruder_offset[Z_AXIS][tmp_extruder];
2750
                      extruder_offset[Z_AXIS][tmp_extruder];
2747
-                     
2751
+
2748
         active_extruder = tmp_extruder;
2752
         active_extruder = tmp_extruder;
2749
 
2753
 
2750
         // This function resets the max/min values - the current position may be overwritten below.
2754
         // This function resets the max/min values - the current position may be overwritten below.
2752
 
2756
 
2753
         if (dual_x_carriage_mode == DXC_FULL_CONTROL_MODE)
2757
         if (dual_x_carriage_mode == DXC_FULL_CONTROL_MODE)
2754
         {
2758
         {
2755
-          current_position[X_AXIS] = inactive_extruder_x_pos; 
2759
+          current_position[X_AXIS] = inactive_extruder_x_pos;
2756
           inactive_extruder_x_pos = destination[X_AXIS];
2760
           inactive_extruder_x_pos = destination[X_AXIS];
2757
         }
2761
         }
2758
         else if (dual_x_carriage_mode == DXC_DUPLICATION_MODE)
2762
         else if (dual_x_carriage_mode == DXC_DUPLICATION_MODE)
2759
         {
2763
         {
2760
           active_extruder_parked = (active_extruder == 0); // this triggers the second extruder to move into the duplication position
2764
           active_extruder_parked = (active_extruder == 0); // this triggers the second extruder to move into the duplication position
2761
           if (active_extruder == 0 || active_extruder_parked)
2765
           if (active_extruder == 0 || active_extruder_parked)
2762
-            current_position[X_AXIS] = inactive_extruder_x_pos; 
2766
+            current_position[X_AXIS] = inactive_extruder_x_pos;
2763
           else
2767
           else
2764
-            current_position[X_AXIS] = destination[X_AXIS] + duplicate_extruder_x_offset; 
2768
+            current_position[X_AXIS] = destination[X_AXIS] + duplicate_extruder_x_offset;
2765
           inactive_extruder_x_pos = destination[X_AXIS];
2769
           inactive_extruder_x_pos = destination[X_AXIS];
2766
-          extruder_duplication_enabled = false; 
2770
+          extruder_duplication_enabled = false;
2767
         }
2771
         }
2768
         else
2772
         else
2769
         {
2773
         {
2773
           active_extruder_parked = true;
2777
           active_extruder_parked = true;
2774
           delayed_move_time = 0;
2778
           delayed_move_time = 0;
2775
         }
2779
         }
2776
-      #else    
2780
+      #else
2777
         // Offset extruder (only by XY)
2781
         // Offset extruder (only by XY)
2778
         int i;
2782
         int i;
2779
         for(i = 0; i < 2; i++) {
2783
         for(i = 0; i < 2; i++) {
2986
     {
2990
     {
2987
       // move duplicate extruder into correct duplication position.
2991
       // move duplicate extruder into correct duplication position.
2988
       plan_set_position(inactive_extruder_x_pos, current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
2992
       plan_set_position(inactive_extruder_x_pos, current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
2989
-      plan_buffer_line(current_position[X_AXIS] + duplicate_extruder_x_offset, current_position[Y_AXIS], current_position[Z_AXIS], 
2993
+      plan_buffer_line(current_position[X_AXIS] + duplicate_extruder_x_offset, current_position[Y_AXIS], current_position[Z_AXIS],
2990
           current_position[E_AXIS], max_feedrate[X_AXIS], 1);
2994
           current_position[E_AXIS], max_feedrate[X_AXIS], 1);
2991
       plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
2995
       plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
2992
       st_synchronize();
2996
       st_synchronize();
2993
       extruder_duplication_enabled = true;
2997
       extruder_duplication_enabled = true;
2994
       active_extruder_parked = false;
2998
       active_extruder_parked = false;
2995
-    }  
2999
+    }
2996
     else if (dual_x_carriage_mode == DXC_AUTO_PARK_MODE) // handle unparking of head
3000
     else if (dual_x_carriage_mode == DXC_AUTO_PARK_MODE) // handle unparking of head
2997
     {
3001
     {
2998
       if (current_position[E_AXIS] == destination[E_AXIS])
3002
       if (current_position[E_AXIS] == destination[E_AXIS])
3001
         // be used as start of first non-travel move)
3005
         // be used as start of first non-travel move)
3002
         if (delayed_move_time != 0xFFFFFFFFUL)
3006
         if (delayed_move_time != 0xFFFFFFFFUL)
3003
         {
3007
         {
3004
-          memcpy(current_position, destination, sizeof(current_position)); 
3008
+          memcpy(current_position, destination, sizeof(current_position));
3005
           if (destination[Z_AXIS] > raised_parked_position[Z_AXIS])
3009
           if (destination[Z_AXIS] > raised_parked_position[Z_AXIS])
3006
             raised_parked_position[Z_AXIS] = destination[Z_AXIS];
3010
             raised_parked_position[Z_AXIS] = destination[Z_AXIS];
3007
           delayed_move_time = millis();
3011
           delayed_move_time = millis();
3011
       delayed_move_time = 0;
3015
       delayed_move_time = 0;
3012
       // unpark extruder: 1) raise, 2) move into starting XY position, 3) lower
3016
       // unpark extruder: 1) raise, 2) move into starting XY position, 3) lower
3013
       plan_buffer_line(raised_parked_position[X_AXIS], raised_parked_position[Y_AXIS], raised_parked_position[Z_AXIS],    current_position[E_AXIS], max_feedrate[Z_AXIS], active_extruder);
3017
       plan_buffer_line(raised_parked_position[X_AXIS], raised_parked_position[Y_AXIS], raised_parked_position[Z_AXIS],    current_position[E_AXIS], max_feedrate[Z_AXIS], active_extruder);
3014
-      plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], raised_parked_position[Z_AXIS], 
3018
+      plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], raised_parked_position[Z_AXIS],
3015
           current_position[E_AXIS], min(max_feedrate[X_AXIS],max_feedrate[Y_AXIS]), active_extruder);
3019
           current_position[E_AXIS], min(max_feedrate[X_AXIS],max_feedrate[Y_AXIS]), active_extruder);
3016
-      plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], 
3020
+      plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS],
3017
           current_position[E_AXIS], max_feedrate[Z_AXIS], active_extruder);
3021
           current_position[E_AXIS], max_feedrate[Z_AXIS], active_extruder);
3018
       active_extruder_parked = false;
3022
       active_extruder_parked = false;
3019
     }
3023
     }
3179
       // travel moves have been received so enact them
3183
       // travel moves have been received so enact them
3180
       delayed_move_time = 0xFFFFFFFFUL; // force moves to be done
3184
       delayed_move_time = 0xFFFFFFFFUL; // force moves to be done
3181
       memcpy(destination,current_position,sizeof(destination));
3185
       memcpy(destination,current_position,sizeof(destination));
3182
-      prepare_move(); 
3186
+      prepare_move();
3183
     }
3187
     }
3184
   #endif
3188
   #endif
3185
   #ifdef TEMP_STAT_LEDS
3189
   #ifdef TEMP_STAT_LEDS

+ 31
- 27
Marlin/ultralcd.cpp View File

90
 #define ENCODER_FEEDRATE_DEADZONE 10
90
 #define ENCODER_FEEDRATE_DEADZONE 10
91
 
91
 
92
 #if !defined(LCD_I2C_VIKI)
92
 #if !defined(LCD_I2C_VIKI)
93
-  #define ENCODER_STEPS_PER_MENU_ITEM 5
93
+  #ifndef ENCODER_STEPS_PER_MENU_ITEM
94
+    #define ENCODER_STEPS_PER_MENU_ITEM 5
95
+  #endif
94
   #ifndef ENCODER_PULSES_PER_STEP
96
   #ifndef ENCODER_PULSES_PER_STEP
95
     #define ENCODER_PULSES_PER_STEP 1
97
     #define ENCODER_PULSES_PER_STEP 1
96
   #endif
98
   #endif
97
 #else
99
 #else
98
-  #define ENCODER_STEPS_PER_MENU_ITEM 2 // VIKI LCD rotary encoder uses a different number of steps per rotation
100
+  #ifndef ENCODER_STEPS_PER_MENU_ITEM
101
+    #define ENCODER_STEPS_PER_MENU_ITEM 2 // VIKI LCD rotary encoder uses a different number of steps per rotation
102
+  #endif
99
   #ifndef ENCODER_PULSES_PER_STEP
103
   #ifndef ENCODER_PULSES_PER_STEP
100
     #define ENCODER_PULSES_PER_STEP 1
104
     #define ENCODER_PULSES_PER_STEP 1
101
   #endif
105
   #endif
207
     else if (feedmultiply == 100 && int(encoderPosition) < -ENCODER_FEEDRATE_DEADZONE)
211
     else if (feedmultiply == 100 && int(encoderPosition) < -ENCODER_FEEDRATE_DEADZONE)
208
     {
212
     {
209
         feedmultiply += int(encoderPosition) + ENCODER_FEEDRATE_DEADZONE;
213
         feedmultiply += int(encoderPosition) + ENCODER_FEEDRATE_DEADZONE;
210
-        encoderPosition = 0;	
214
+        encoderPosition = 0;
211
     }
215
     }
212
     else if (feedmultiply != 100)
216
     else if (feedmultiply != 100)
213
     {
217
     {
407
 #endif
411
 #endif
408
     MENU_ITEM_EDIT(int3, MSG_FAN_SPEED, &fanSpeed, 0, 255);
412
     MENU_ITEM_EDIT(int3, MSG_FAN_SPEED, &fanSpeed, 0, 255);
409
     MENU_ITEM_EDIT(int3, MSG_FLOW, &extrudemultiply, 10, 999);
413
     MENU_ITEM_EDIT(int3, MSG_FLOW, &extrudemultiply, 10, 999);
410
-    
414
+
411
 #ifdef BABYSTEPPING
415
 #ifdef BABYSTEPPING
412
     #ifdef BABYSTEP_XY
416
     #ifdef BABYSTEP_XY
413
       MENU_ITEM(submenu, "Babystep X", lcd_babystep_x);
417
       MENU_ITEM(submenu, "Babystep X", lcd_babystep_x);
719
     MENU_ITEM_EDIT(float52, MSG_XSTEPS, &axis_steps_per_unit[X_AXIS], 5, 9999);
723
     MENU_ITEM_EDIT(float52, MSG_XSTEPS, &axis_steps_per_unit[X_AXIS], 5, 9999);
720
     MENU_ITEM_EDIT(float52, MSG_YSTEPS, &axis_steps_per_unit[Y_AXIS], 5, 9999);
724
     MENU_ITEM_EDIT(float52, MSG_YSTEPS, &axis_steps_per_unit[Y_AXIS], 5, 9999);
721
     MENU_ITEM_EDIT(float51, MSG_ZSTEPS, &axis_steps_per_unit[Z_AXIS], 5, 9999);
725
     MENU_ITEM_EDIT(float51, MSG_ZSTEPS, &axis_steps_per_unit[Z_AXIS], 5, 9999);
722
-    MENU_ITEM_EDIT(float51, MSG_ESTEPS, &axis_steps_per_unit[E_AXIS], 5, 9999);    
726
+    MENU_ITEM_EDIT(float51, MSG_ESTEPS, &axis_steps_per_unit[E_AXIS], 5, 9999);
723
 #ifdef ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED
727
 #ifdef ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED
724
     MENU_ITEM_EDIT(bool, "Endstop abort", &abort_on_endstop_hit);
728
     MENU_ITEM_EDIT(bool, "Endstop abort", &abort_on_endstop_hit);
725
 #endif
729
 #endif
781
 
785
 
782
 void lcd_sdcard_menu()
786
 void lcd_sdcard_menu()
783
 {
787
 {
784
-    if (lcdDrawUpdate == 0 && LCD_CLICKED == 0) 
788
+    if (lcdDrawUpdate == 0 && LCD_CLICKED == 0)
785
         return;	// nothing to do (so don't thrash the SD card)
789
         return;	// nothing to do (so don't thrash the SD card)
786
     uint16_t fileCnt = card.getnrfilenames();
790
     uint16_t fileCnt = card.getnrfilenames();
787
     START_MENU();
791
     START_MENU();
795
     }else{
799
     }else{
796
         MENU_ITEM(function, LCD_STR_FOLDER "..", lcd_sd_updir);
800
         MENU_ITEM(function, LCD_STR_FOLDER "..", lcd_sd_updir);
797
     }
801
     }
798
-    
802
+
799
     for(uint16_t i=0;i<fileCnt;i++)
803
     for(uint16_t i=0;i<fileCnt;i++)
800
     {
804
     {
801
         if (_menuItemNr == _lineNr)
805
         if (_menuItemNr == _lineNr)
982
 
986
 
983
 #ifdef NEWPANEL
987
 #ifdef NEWPANEL
984
     pinMode(BTN_EN1,INPUT);
988
     pinMode(BTN_EN1,INPUT);
985
-    pinMode(BTN_EN2,INPUT); 
989
+    pinMode(BTN_EN2,INPUT);
986
     pinMode(SDCARDDETECT,INPUT);
990
     pinMode(SDCARDDETECT,INPUT);
987
     WRITE(BTN_EN1,HIGH);
991
     WRITE(BTN_EN1,HIGH);
988
     WRITE(BTN_EN2,HIGH);
992
     WRITE(BTN_EN2,HIGH);
989
   #if BTN_ENC > 0
993
   #if BTN_ENC > 0
990
-    pinMode(BTN_ENC,INPUT); 
994
+    pinMode(BTN_ENC,INPUT);
991
     WRITE(BTN_ENC,HIGH);
995
     WRITE(BTN_ENC,HIGH);
992
-  #endif    
996
+  #endif
993
   #ifdef REPRAPWORLD_KEYPAD
997
   #ifdef REPRAPWORLD_KEYPAD
994
     pinMode(SHIFT_CLK,OUTPUT);
998
     pinMode(SHIFT_CLK,OUTPUT);
995
     pinMode(SHIFT_LD,OUTPUT);
999
     pinMode(SHIFT_LD,OUTPUT);
1007
      pinMode(SHIFT_EN,OUTPUT);
1011
      pinMode(SHIFT_EN,OUTPUT);
1008
      pinMode(SHIFT_OUT,INPUT);
1012
      pinMode(SHIFT_OUT,INPUT);
1009
      WRITE(SHIFT_OUT,HIGH);
1013
      WRITE(SHIFT_OUT,HIGH);
1010
-     WRITE(SHIFT_LD,HIGH); 
1014
+     WRITE(SHIFT_LD,HIGH);
1011
      WRITE(SHIFT_EN,LOW);
1015
      WRITE(SHIFT_EN,LOW);
1012
-   #endif // SR_LCD_2W_NL    
1016
+   #endif // SR_LCD_2W_NL
1013
 #endif//!NEWPANEL
1017
 #endif//!NEWPANEL
1014
 
1018
 
1015
 #if (SDCARDDETECT > 0)
1019
 #if (SDCARDDETECT > 0)
1020
     slow_buttons = 0;
1024
     slow_buttons = 0;
1021
     #endif
1025
     #endif
1022
     lcd_buttons_update();
1026
     lcd_buttons_update();
1023
-#ifdef ULTIPANEL    
1027
+#ifdef ULTIPANEL
1024
     encoderDiff = 0;
1028
     encoderDiff = 0;
1025
-#endif    
1029
+#endif
1026
 }
1030
 }
1027
 
1031
 
1028
 void lcd_update()
1032
 void lcd_update()
1029
 {
1033
 {
1030
     static unsigned long timeoutToStatus = 0;
1034
     static unsigned long timeoutToStatus = 0;
1031
-    
1035
+
1032
     #ifdef LCD_HAS_SLOW_BUTTONS
1036
     #ifdef LCD_HAS_SLOW_BUTTONS
1033
     slow_buttons = lcd_implementation_read_slow_buttons(); // buttons which take too long to read in interrupt context
1037
     slow_buttons = lcd_implementation_read_slow_buttons(); // buttons which take too long to read in interrupt context
1034
     #endif
1038
     #endif
1035
-    
1039
+
1036
     lcd_buttons_update();
1040
     lcd_buttons_update();
1037
-    
1041
+
1038
     #if (SDCARDDETECT > 0)
1042
     #if (SDCARDDETECT > 0)
1039
     if((IS_SD_INSERTED != lcd_oldcardstatus))
1043
     if((IS_SD_INSERTED != lcd_oldcardstatus))
1040
     {
1044
     {
1041
         lcdDrawUpdate = 2;
1045
         lcdDrawUpdate = 2;
1042
         lcd_oldcardstatus = IS_SD_INSERTED;
1046
         lcd_oldcardstatus = IS_SD_INSERTED;
1043
         lcd_implementation_init(); // to maybe revive the lcd if static electricty killed it.
1047
         lcd_implementation_init(); // to maybe revive the lcd if static electricty killed it.
1044
-        
1048
+
1045
         if(lcd_oldcardstatus)
1049
         if(lcd_oldcardstatus)
1046
         {
1050
         {
1047
             card.initsd();
1051
             card.initsd();
1054
         }
1058
         }
1055
     }
1059
     }
1056
     #endif//CARDINSERTED
1060
     #endif//CARDINSERTED
1057
-    
1061
+
1058
     if (lcd_next_update_millis < millis())
1062
     if (lcd_next_update_millis < millis())
1059
     {
1063
     {
1060
 #ifdef ULTIPANEL
1064
 #ifdef ULTIPANEL
1095
 #ifdef DOGLCD        // Changes due to different driver architecture of the DOGM display
1099
 #ifdef DOGLCD        // Changes due to different driver architecture of the DOGM display
1096
         blink++;     // Variable for fan animation and alive dot
1100
         blink++;     // Variable for fan animation and alive dot
1097
         u8g.firstPage();
1101
         u8g.firstPage();
1098
-        do 
1102
+        do
1099
         {
1103
         {
1100
             u8g.setFont(u8g_font_6x10_marlin);
1104
             u8g.setFont(u8g_font_6x10_marlin);
1101
             u8g.setPrintPos(125,0);
1105
             u8g.setPrintPos(125,0);
1105
             (*currentMenu)();
1109
             (*currentMenu)();
1106
             if (!lcdDrawUpdate)  break; // Terminate display update, when nothing new to draw. This must be done before the last dogm.next()
1110
             if (!lcdDrawUpdate)  break; // Terminate display update, when nothing new to draw. This must be done before the last dogm.next()
1107
         } while( u8g.nextPage() );
1111
         } while( u8g.nextPage() );
1108
-#else        
1112
+#else
1109
         (*currentMenu)();
1113
         (*currentMenu)();
1110
 #endif
1114
 #endif
1111
 
1115
 
1159
 void lcd_setcontrast(uint8_t value)
1163
 void lcd_setcontrast(uint8_t value)
1160
 {
1164
 {
1161
     lcd_contrast = value & 63;
1165
     lcd_contrast = value & 63;
1162
-    u8g.setContrast(lcd_contrast);	
1166
+    u8g.setContrast(lcd_contrast);
1163
 }
1167
 }
1164
 #endif
1168
 #endif
1165
 
1169
 
1199
     WRITE(SHIFT_LD,HIGH);
1203
     WRITE(SHIFT_LD,HIGH);
1200
     unsigned char tmp_buttons=0;
1204
     unsigned char tmp_buttons=0;
1201
     for(int8_t i=0;i<8;i++)
1205
     for(int8_t i=0;i<8;i++)
1202
-    { 
1206
+    {
1203
         newbutton = newbutton>>1;
1207
         newbutton = newbutton>>1;
1204
         if(READ(SHIFT_OUT))
1208
         if(READ(SHIFT_OUT))
1205
             newbutton|=(1<<7);
1209
             newbutton|=(1<<7);
1249
 }
1253
 }
1250
 
1254
 
1251
 void lcd_buzz(long duration, uint16_t freq)
1255
 void lcd_buzz(long duration, uint16_t freq)
1252
-{ 
1256
+{
1253
 #ifdef LCD_USE_I2C_BUZZER
1257
 #ifdef LCD_USE_I2C_BUZZER
1254
   lcd.buzz(duration,freq);
1258
   lcd.buzz(duration,freq);
1255
-#endif   
1259
+#endif
1256
 }
1260
 }
1257
 
1261
 
1258
-bool lcd_clicked() 
1259
-{ 
1262
+bool lcd_clicked()
1263
+{
1260
   return LCD_CLICKED;
1264
   return LCD_CLICKED;
1261
 }
1265
 }
1262
 #endif//ULTIPANEL
1266
 #endif//ULTIPANEL

Loading…
Cancel
Save