Browse Source

separate INVERTING for MIN and MAX endstops (6 #defines instead of 3)

hg42@gmx.net 11 years ago
parent
commit
2ca983568d
4 changed files with 189 additions and 183 deletions
  1. 16
    13
      Marlin/Configuration.h
  2. 38
    38
      Marlin/Marlin_main.cpp
  3. 16
    13
      Marlin/example_configurations/delta/Configuration.h
  4. 119
    119
      Marlin/stepper.cpp

+ 16
- 13
Marlin/Configuration.h View File

141
 #define TEMP_SENSOR_BED 0
141
 #define TEMP_SENSOR_BED 0
142
 
142
 
143
 // This makes temp sensor 1 a redundant sensor for sensor 0. If the temperatures difference between these sensors is to high the print will be aborted.
143
 // This makes temp sensor 1 a redundant sensor for sensor 0. If the temperatures difference between these sensors is to high the print will be aborted.
144
-//#define TEMP_SENSOR_1_AS_REDUNDANT 
144
+//#define TEMP_SENSOR_1_AS_REDUNDANT
145
 #define MAX_REDUNDANT_TEMP_SENSOR_DIFF 10
145
 #define MAX_REDUNDANT_TEMP_SENSOR_DIFF 10
146
 
146
 
147
 // Actual temperature must be close to target for this long before M109 returns success
147
 // Actual temperature must be close to target for this long before M109 returns success
278
 #endif
278
 #endif
279
 
279
 
280
 // The pullups are needed if you directly connect a mechanical endswitch between the signal and ground pins.
280
 // The pullups are needed if you directly connect a mechanical endswitch between the signal and ground pins.
281
-const bool X_ENDSTOPS_INVERTING = true; // set to true to invert the logic of the endstops.
282
-const bool Y_ENDSTOPS_INVERTING = true; // set to true to invert the logic of the endstops.
283
-const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of the endstops.
281
+const bool X_MIN_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop.
282
+const bool Y_MIN_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop.
283
+const bool Z_MIN_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop.
284
+const bool X_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop.
285
+const bool Y_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop.
286
+const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop.
284
 //#define DISABLE_MAX_ENDSTOPS
287
 //#define DISABLE_MAX_ENDSTOPS
285
 //#define DISABLE_MIN_ENDSTOPS
288
 //#define DISABLE_MIN_ENDSTOPS
286
 
289
 
379
 //#define EEPROM_CHITCHAT
382
 //#define EEPROM_CHITCHAT
380
 
383
 
381
 // Preheat Constants
384
 // Preheat Constants
382
-#define PLA_PREHEAT_HOTEND_TEMP 180 
385
+#define PLA_PREHEAT_HOTEND_TEMP 180
383
 #define PLA_PREHEAT_HPB_TEMP 70
386
 #define PLA_PREHEAT_HPB_TEMP 70
384
 #define PLA_PREHEAT_FAN_SPEED 255   // Insert Value between 0 and 255
387
 #define PLA_PREHEAT_FAN_SPEED 255   // Insert Value between 0 and 255
385
 
388
 
464
   #define LCD_I2C_TYPE_PCF8575
467
   #define LCD_I2C_TYPE_PCF8575
465
   #define LCD_I2C_ADDRESS 0x27   // I2C Address of the port expander
468
   #define LCD_I2C_ADDRESS 0x27   // I2C Address of the port expander
466
   #define NEWPANEL
469
   #define NEWPANEL
467
-  #define ULTIPANEL 
470
+  #define ULTIPANEL
468
 #endif
471
 #endif
469
 
472
 
470
 // PANELOLU2 LCD with status LEDs, separate encoder and click inputs
473
 // PANELOLU2 LCD with status LEDs, separate encoder and click inputs
473
   // This uses the LiquidTWI2 library v1.2.3 or later ( https://github.com/lincomatic/LiquidTWI2 )
476
   // This uses the LiquidTWI2 library v1.2.3 or later ( https://github.com/lincomatic/LiquidTWI2 )
474
   // Make sure the LiquidTWI2 directory is placed in the Arduino or Sketchbook libraries subdirectory.
477
   // Make sure the LiquidTWI2 directory is placed in the Arduino or Sketchbook libraries subdirectory.
475
   // (v1.2.3 no longer requires you to define PANELOLU in the LiquidTWI2.h library header file)
478
   // (v1.2.3 no longer requires you to define PANELOLU in the LiquidTWI2.h library header file)
476
-  // Note: The PANELOLU2 encoder click input can either be directly connected to a pin 
477
-  //       (if BTN_ENC defined to != -1) or read through I2C (when BTN_ENC == -1). 
479
+  // Note: The PANELOLU2 encoder click input can either be directly connected to a pin
480
+  //       (if BTN_ENC defined to != -1) or read through I2C (when BTN_ENC == -1).
478
   #define LCD_I2C_TYPE_MCP23017
481
   #define LCD_I2C_TYPE_MCP23017
479
   #define LCD_I2C_ADDRESS 0x20 // I2C Address of the port expander
482
   #define LCD_I2C_ADDRESS 0x20 // I2C Address of the port expander
480
   #define LCD_USE_I2C_BUZZER //comment out to disable buzzer on LCD
483
   #define LCD_USE_I2C_BUZZER //comment out to disable buzzer on LCD
481
   #define NEWPANEL
484
   #define NEWPANEL
482
-  #define ULTIPANEL 
485
+  #define ULTIPANEL
483
 #endif
486
 #endif
484
 
487
 
485
 // Panucatt VIKI LCD with status LEDs, integrated click & L/R/U/P buttons, separate encoder inputs
488
 // Panucatt VIKI LCD with status LEDs, integrated click & L/R/U/P buttons, separate encoder inputs
489
   // Make sure the LiquidTWI2 directory is placed in the Arduino or Sketchbook libraries subdirectory.
492
   // Make sure the LiquidTWI2 directory is placed in the Arduino or Sketchbook libraries subdirectory.
490
   // Note: The pause/stop/resume LCD button pin should be connected to the Arduino
493
   // Note: The pause/stop/resume LCD button pin should be connected to the Arduino
491
   //       BTN_ENC pin (or set BTN_ENC to -1 if not used)
494
   //       BTN_ENC pin (or set BTN_ENC to -1 if not used)
492
-  #define LCD_I2C_TYPE_MCP23017 
495
+  #define LCD_I2C_TYPE_MCP23017
493
   #define LCD_I2C_ADDRESS 0x20 // I2C Address of the port expander
496
   #define LCD_I2C_ADDRESS 0x20 // I2C Address of the port expander
494
   #define LCD_USE_I2C_BUZZER //comment out to disable buzzer on LCD (requires LiquidTWI2 v1.2.3 or later)
497
   #define LCD_USE_I2C_BUZZER //comment out to disable buzzer on LCD (requires LiquidTWI2 v1.2.3 or later)
495
   #define NEWPANEL
498
   #define NEWPANEL
496
-  #define ULTIPANEL 
499
+  #define ULTIPANEL
497
 #endif
500
 #endif
498
 
501
 
499
 #ifdef ULTIPANEL
502
 #ifdef ULTIPANEL
565
 //#define NUM_SERVOS 3 // Servo index starts with 0 for M280 command
568
 //#define NUM_SERVOS 3 // Servo index starts with 0 for M280 command
566
 
569
 
567
 // Servo Endstops
570
 // Servo Endstops
568
-// 
571
+//
569
 // This allows for servo actuated endstops, primary usage is for the Z Axis to eliminate calibration or bed height changes.
572
 // This allows for servo actuated endstops, primary usage is for the Z Axis to eliminate calibration or bed height changes.
570
 // Use M206 command to correct for switch height offset to actual nozzle height. Store that setting with M500.
573
 // Use M206 command to correct for switch height offset to actual nozzle height. Store that setting with M500.
571
-// 
574
+//
572
 //#define SERVO_ENDSTOPS {-1, -1, 0} // Servo index for X, Y, Z. Disable with -1
575
 //#define SERVO_ENDSTOPS {-1, -1, 0} // Servo index for X, Y, Z. Disable with -1
573
 //#define SERVO_ENDSTOP_ANGLES {0,0, 0,0, 70,0} // X,Y,Z Axis Extend and Retract angles
576
 //#define SERVO_ENDSTOP_ANGLES {0,0, 0,0, 70,0} // X,Y,Z Axis Extend and Retract angles
574
 
577
 

+ 38
- 38
Marlin/Marlin_main.cpp View File

431
 
431
 
432
   lcd_init();
432
   lcd_init();
433
   _delay_ms(1000);	// wait 1sec to display the splash screen
433
   _delay_ms(1000);	// wait 1sec to display the splash screen
434
-  
434
+
435
   #if defined(CONTROLLERFAN_PIN) && CONTROLLERFAN_PIN > -1
435
   #if defined(CONTROLLERFAN_PIN) && CONTROLLERFAN_PIN > -1
436
     SET_OUTPUT(CONTROLLERFAN_PIN); //Set pin used for driver cooling fan
436
     SET_OUTPUT(CONTROLLERFAN_PIN); //Set pin used for driver cooling fan
437
-  #endif 
437
+  #endif
438
 }
438
 }
439
 
439
 
440
 
440
 
691
   #endif
691
   #endif
692
   #if X_HOME_DIR != -1 || X2_HOME_DIR != 1
692
   #if X_HOME_DIR != -1 || X2_HOME_DIR != 1
693
     #error "Please use canonical x-carriage assignment" // the x-carriages are defined by their homing directions
693
     #error "Please use canonical x-carriage assignment" // the x-carriages are defined by their homing directions
694
-  #endif  
695
-    
694
+  #endif
695
+
696
 static float x_home_pos(int extruder) {
696
 static float x_home_pos(int extruder) {
697
   if (extruder == 0)
697
   if (extruder == 0)
698
     return base_home_pos(X_AXIS) + add_homeing[X_AXIS];
698
     return base_home_pos(X_AXIS) + add_homeing[X_AXIS];
699
   else
699
   else
700
     // In dual carriage mode the extruder offset provides an override of the
700
     // In dual carriage mode the extruder offset provides an override of the
701
     // second X-carriage offset when homed - otherwise X2_HOME_POS is used.
701
     // second X-carriage offset when homed - otherwise X2_HOME_POS is used.
702
-    // This allow soft recalibration of the second extruder offset position without firmware reflash 
702
+    // This allow soft recalibration of the second extruder offset position without firmware reflash
703
     // (through the M218 command).
703
     // (through the M218 command).
704
     return (extruder_offset[X_AXIS][1] > 0) ? extruder_offset[X_AXIS][1] : X2_HOME_POS;
704
     return (extruder_offset[X_AXIS][1] > 0) ? extruder_offset[X_AXIS][1] : X2_HOME_POS;
705
 }
705
 }
709
 }
709
 }
710
 
710
 
711
 static float inactive_x_carriage_pos = X2_MAX_POS;
711
 static float inactive_x_carriage_pos = X2_MAX_POS;
712
-#endif     
712
+#endif
713
 
713
 
714
 static void axis_is_at_home(int axis) {
714
 static void axis_is_at_home(int axis) {
715
 #ifdef DUAL_X_CARRIAGE
715
 #ifdef DUAL_X_CARRIAGE
719
     max_pos[X_AXIS] =          max(extruder_offset[X_AXIS][1], X2_MAX_POS);
719
     max_pos[X_AXIS] =          max(extruder_offset[X_AXIS][1], X2_MAX_POS);
720
     return;
720
     return;
721
   }
721
   }
722
-#endif  
722
+#endif
723
   current_position[axis] = base_home_pos(axis) + add_homeing[axis];
723
   current_position[axis] = base_home_pos(axis) + add_homeing[axis];
724
   min_pos[axis] =          base_min_pos(axis) + add_homeing[axis];
724
   min_pos[axis] =          base_min_pos(axis) + add_homeing[axis];
725
   max_pos[axis] =          base_max_pos(axis) + add_homeing[axis];
725
   max_pos[axis] =          base_max_pos(axis) + add_homeing[axis];
745
         servos[servo_endstops[axis]].write(servo_endstop_angles[axis * 2]);
745
         servos[servo_endstops[axis]].write(servo_endstop_angles[axis * 2]);
746
       }
746
       }
747
     #endif
747
     #endif
748
-      
748
+
749
     current_position[axis] = 0;
749
     current_position[axis] = 0;
750
     plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
750
     plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
751
     destination[axis] = 1.5 * max_length(axis) * axis_home_dir;
751
     destination[axis] = 1.5 * max_length(axis) * axis_home_dir;
879
           current_position[X_AXIS] = 0;
879
           current_position[X_AXIS] = 0;
880
           current_position[Y_AXIS] = 0;
880
           current_position[Y_AXIS] = 0;
881
           current_position[Z_AXIS] = 0;
881
           current_position[Z_AXIS] = 0;
882
-          plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); 
882
+          plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
883
 
883
 
884
           destination[X_AXIS] = 3 * Z_MAX_LENGTH;
884
           destination[X_AXIS] = 3 * Z_MAX_LENGTH;
885
           destination[Y_AXIS] = 3 * Z_MAX_LENGTH;
885
           destination[Y_AXIS] = 3 * Z_MAX_LENGTH;
892
           current_position[X_AXIS] = destination[X_AXIS];
892
           current_position[X_AXIS] = destination[X_AXIS];
893
           current_position[Y_AXIS] = destination[Y_AXIS];
893
           current_position[Y_AXIS] = destination[Y_AXIS];
894
           current_position[Z_AXIS] = destination[Z_AXIS];
894
           current_position[Z_AXIS] = destination[Z_AXIS];
895
-          
895
+
896
           // take care of back off and rehome now we are all at the top
896
           // take care of back off and rehome now we are all at the top
897
           HOMEAXIS(X);
897
           HOMEAXIS(X);
898
           HOMEAXIS(Y);
898
           HOMEAXIS(Y);
921
        #else
921
        #else
922
         int x_axis_home_dir = x_home_dir(active_extruder);
922
         int x_axis_home_dir = x_home_dir(active_extruder);
923
        #endif
923
        #endif
924
-        
924
+
925
         plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
925
         plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
926
         destination[X_AXIS] = 1.5 * max_length(X_AXIS) * x_axis_home_dir;destination[Y_AXIS] = 1.5 * max_length(Y_AXIS) * home_dir(Y_AXIS);
926
         destination[X_AXIS] = 1.5 * max_length(X_AXIS) * x_axis_home_dir;destination[Y_AXIS] = 1.5 * max_length(Y_AXIS) * home_dir(Y_AXIS);
927
         feedrate = homing_feedrate[X_AXIS];
927
         feedrate = homing_feedrate[X_AXIS];
954
         HOMEAXIS(X);
954
         HOMEAXIS(X);
955
         inactive_x_carriage_pos = current_position[X_AXIS];
955
         inactive_x_carriage_pos = current_position[X_AXIS];
956
         active_extruder = tmp_extruder;
956
         active_extruder = tmp_extruder;
957
-      #endif         
957
+      #endif
958
         HOMEAXIS(X);
958
         HOMEAXIS(X);
959
       }
959
       }
960
 
960
 
988
       }
988
       }
989
       plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
989
       plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
990
 #endif // else DELTA
990
 #endif // else DELTA
991
-          
991
+
992
       #ifdef ENDSTOPS_ONLY_FOR_HOMING
992
       #ifdef ENDSTOPS_ONLY_FOR_HOMING
993
         enable_endstops(false);
993
         enable_endstops(false);
994
       #endif
994
       #endif
1223
           SERIAL_PROTOCOLPGM(" T");
1223
           SERIAL_PROTOCOLPGM(" T");
1224
           SERIAL_PROTOCOL(cur_extruder);
1224
           SERIAL_PROTOCOL(cur_extruder);
1225
           SERIAL_PROTOCOLPGM(":");
1225
           SERIAL_PROTOCOLPGM(":");
1226
-          SERIAL_PROTOCOL_F(degHotend(cur_extruder),1); 
1226
+          SERIAL_PROTOCOL_F(degHotend(cur_extruder),1);
1227
           SERIAL_PROTOCOLPGM(" /");
1227
           SERIAL_PROTOCOLPGM(" /");
1228
-          SERIAL_PROTOCOL_F(degTargetHotend(cur_extruder),1); 
1228
+          SERIAL_PROTOCOL_F(degTargetHotend(cur_extruder),1);
1229
         }
1229
         }
1230
       #else
1230
       #else
1231
         SERIAL_ERROR_START;
1231
         SERIAL_ERROR_START;
1250
       #ifdef AUTOTEMP
1250
       #ifdef AUTOTEMP
1251
         autotemp_enabled=false;
1251
         autotemp_enabled=false;
1252
       #endif
1252
       #endif
1253
-      if (code_seen('S')) { 
1253
+      if (code_seen('S')) {
1254
         setTargetHotend(code_value(), tmp_extruder);
1254
         setTargetHotend(code_value(), tmp_extruder);
1255
         CooldownNoWait = true;
1255
         CooldownNoWait = true;
1256
       } else if (code_seen('R')) {
1256
       } else if (code_seen('R')) {
1327
     case 190: // M190 - Wait for bed heater to reach target.
1327
     case 190: // M190 - Wait for bed heater to reach target.
1328
     #if defined(TEMP_BED_PIN) && TEMP_BED_PIN > -1
1328
     #if defined(TEMP_BED_PIN) && TEMP_BED_PIN > -1
1329
         LCD_MESSAGEPGM(MSG_BED_HEATING);
1329
         LCD_MESSAGEPGM(MSG_BED_HEATING);
1330
-        if (code_seen('S')) { 
1330
+        if (code_seen('S')) {
1331
           setTargetBed(code_value());
1331
           setTargetBed(code_value());
1332
           CooldownNoWait = true;
1332
           CooldownNoWait = true;
1333
         } else if (code_seen('R')) {
1333
         } else if (code_seen('R')) {
1335
           CooldownNoWait = false;
1335
           CooldownNoWait = false;
1336
         }
1336
         }
1337
         codenum = millis();
1337
         codenum = millis();
1338
-        
1338
+
1339
         target_direction = isHeatingBed(); // true if heating, false if cooling
1339
         target_direction = isHeatingBed(); // true if heating, false if cooling
1340
-        
1340
+
1341
         while ( target_direction ? (isHeatingBed()) : (isCoolingBed()&&(CooldownNoWait==false)) )
1341
         while ( target_direction ? (isHeatingBed()) : (isCoolingBed()&&(CooldownNoWait==false)) )
1342
         {
1342
         {
1343
           if(( millis() - codenum) > 1000 ) //Print Temp Reading every 1 second while heating up.
1343
           if(( millis() - codenum) > 1000 ) //Print Temp Reading every 1 second while heating up.
1417
         #endif
1417
         #endif
1418
         break;
1418
         break;
1419
       #endif
1419
       #endif
1420
-      
1420
+
1421
       case 81: // M81 - Turn off Power Supply
1421
       case 81: // M81 - Turn off Power Supply
1422
         disable_heater();
1422
         disable_heater();
1423
         st_synchronize();
1423
         st_synchronize();
1542
     SERIAL_PROTOCOLLN(MSG_M119_REPORT);
1542
     SERIAL_PROTOCOLLN(MSG_M119_REPORT);
1543
       #if defined(X_MIN_PIN) && X_MIN_PIN > -1
1543
       #if defined(X_MIN_PIN) && X_MIN_PIN > -1
1544
         SERIAL_PROTOCOLPGM(MSG_X_MIN);
1544
         SERIAL_PROTOCOLPGM(MSG_X_MIN);
1545
-        SERIAL_PROTOCOLLN(((READ(X_MIN_PIN)^X_ENDSTOPS_INVERTING)?MSG_ENDSTOP_HIT:MSG_ENDSTOP_OPEN));
1545
+        SERIAL_PROTOCOLLN(((READ(X_MIN_PIN)^X_MIN_ENDSTOP_INVERTING)?MSG_ENDSTOP_HIT:MSG_ENDSTOP_OPEN));
1546
       #endif
1546
       #endif
1547
       #if defined(X_MAX_PIN) && X_MAX_PIN > -1
1547
       #if defined(X_MAX_PIN) && X_MAX_PIN > -1
1548
         SERIAL_PROTOCOLPGM(MSG_X_MAX);
1548
         SERIAL_PROTOCOLPGM(MSG_X_MAX);
1549
-        SERIAL_PROTOCOLLN(((READ(X_MAX_PIN)^X_ENDSTOPS_INVERTING)?MSG_ENDSTOP_HIT:MSG_ENDSTOP_OPEN));
1549
+        SERIAL_PROTOCOLLN(((READ(X_MAX_PIN)^X_MAX_ENDSTOP_INVERTING)?MSG_ENDSTOP_HIT:MSG_ENDSTOP_OPEN));
1550
       #endif
1550
       #endif
1551
       #if defined(Y_MIN_PIN) && Y_MIN_PIN > -1
1551
       #if defined(Y_MIN_PIN) && Y_MIN_PIN > -1
1552
         SERIAL_PROTOCOLPGM(MSG_Y_MIN);
1552
         SERIAL_PROTOCOLPGM(MSG_Y_MIN);
1553
-        SERIAL_PROTOCOLLN(((READ(Y_MIN_PIN)^Y_ENDSTOPS_INVERTING)?MSG_ENDSTOP_HIT:MSG_ENDSTOP_OPEN));
1553
+        SERIAL_PROTOCOLLN(((READ(Y_MIN_PIN)^Y_MIN_ENDSTOP_INVERTING)?MSG_ENDSTOP_HIT:MSG_ENDSTOP_OPEN));
1554
       #endif
1554
       #endif
1555
       #if defined(Y_MAX_PIN) && Y_MAX_PIN > -1
1555
       #if defined(Y_MAX_PIN) && Y_MAX_PIN > -1
1556
         SERIAL_PROTOCOLPGM(MSG_Y_MAX);
1556
         SERIAL_PROTOCOLPGM(MSG_Y_MAX);
1557
-        SERIAL_PROTOCOLLN(((READ(Y_MAX_PIN)^Y_ENDSTOPS_INVERTING)?MSG_ENDSTOP_HIT:MSG_ENDSTOP_OPEN));
1557
+        SERIAL_PROTOCOLLN(((READ(Y_MAX_PIN)^Y_MAX_ENDSTOP_INVERTING)?MSG_ENDSTOP_HIT:MSG_ENDSTOP_OPEN));
1558
       #endif
1558
       #endif
1559
       #if defined(Z_MIN_PIN) && Z_MIN_PIN > -1
1559
       #if defined(Z_MIN_PIN) && Z_MIN_PIN > -1
1560
         SERIAL_PROTOCOLPGM(MSG_Z_MIN);
1560
         SERIAL_PROTOCOLPGM(MSG_Z_MIN);
1561
-        SERIAL_PROTOCOLLN(((READ(Z_MIN_PIN)^Z_ENDSTOPS_INVERTING)?MSG_ENDSTOP_HIT:MSG_ENDSTOP_OPEN));
1561
+        SERIAL_PROTOCOLLN(((READ(Z_MIN_PIN)^Z_MIN_ENDSTOP_INVERTING)?MSG_ENDSTOP_HIT:MSG_ENDSTOP_OPEN));
1562
       #endif
1562
       #endif
1563
       #if defined(Z_MAX_PIN) && Z_MAX_PIN > -1
1563
       #if defined(Z_MAX_PIN) && Z_MAX_PIN > -1
1564
         SERIAL_PROTOCOLPGM(MSG_Z_MAX);
1564
         SERIAL_PROTOCOLPGM(MSG_Z_MAX);
1565
-        SERIAL_PROTOCOLLN(((READ(Z_MAX_PIN)^Z_ENDSTOPS_INVERTING)?MSG_ENDSTOP_HIT:MSG_ENDSTOP_OPEN));
1565
+        SERIAL_PROTOCOLLN(((READ(Z_MAX_PIN)^Z_MAX_ENDSTOP_INVERTING)?MSG_ENDSTOP_HIT:MSG_ENDSTOP_OPEN));
1566
       #endif
1566
       #endif
1567
       break;
1567
       break;
1568
       //TODO: update for all axis, use for loop
1568
       //TODO: update for all axis, use for loop
1699
       }
1699
       }
1700
     }
1700
     }
1701
     break;
1701
     break;
1702
-    
1702
+
1703
     #if NUM_SERVOS > 0
1703
     #if NUM_SERVOS > 0
1704
     case 280: // M280 - set servo position absolute. P: servo index, S: angle or microseconds
1704
     case 280: // M280 - set servo position absolute. P: servo index, S: angle or microseconds
1705
       {
1705
       {
1987
             delay(3);
1987
             delay(3);
1988
             WRITE(BEEPER,LOW);
1988
             WRITE(BEEPER,LOW);
1989
             delay(3);
1989
             delay(3);
1990
-          #else 
1990
+          #else
1991
             lcd_buzz(1000/6,100);
1991
             lcd_buzz(1000/6,100);
1992
           #endif
1992
           #endif
1993
           }
1993
           }
2103
         active_extruder = tmp_extruder;
2103
         active_extruder = tmp_extruder;
2104
         axis_is_at_home(X_AXIS); //this function updates X min/max values.
2104
         axis_is_at_home(X_AXIS); //this function updates X min/max values.
2105
         current_position[X_AXIS] = inactive_x_carriage_pos;
2105
         current_position[X_AXIS] = inactive_x_carriage_pos;
2106
-        inactive_x_carriage_pos = tmp_x_pos;      
2107
-      #else    
2106
+        inactive_x_carriage_pos = tmp_x_pos;
2107
+      #else
2108
         // Offset extruder (only by XY)
2108
         // Offset extruder (only by XY)
2109
         int i;
2109
         int i;
2110
         for(i = 0; i < 2; i++) {
2110
         for(i = 0; i < 2; i++) {
2340
 #if defined(CONTROLLERFAN_PIN) && CONTROLLERFAN_PIN > -1
2340
 #if defined(CONTROLLERFAN_PIN) && CONTROLLERFAN_PIN > -1
2341
 
2341
 
2342
 #if defined(FAN_PIN)
2342
 #if defined(FAN_PIN)
2343
-  #if CONTROLLERFAN_PIN == FAN_PIN 
2343
+  #if CONTROLLERFAN_PIN == FAN_PIN
2344
     #error "You cannot set CONTROLLERFAN_PIN equal to FAN_PIN"
2344
     #error "You cannot set CONTROLLERFAN_PIN equal to FAN_PIN"
2345
   #endif
2345
   #endif
2346
-#endif  
2346
+#endif
2347
 
2347
 
2348
 unsigned long lastMotor = 0; //Save the time for when a motor was turned on last
2348
 unsigned long lastMotor = 0; //Save the time for when a motor was turned on last
2349
 unsigned long lastMotorCheck = 0;
2349
 unsigned long lastMotorCheck = 0;
2368
     {
2368
     {
2369
       lastMotor = millis(); //... set time to NOW so the fan will turn on
2369
       lastMotor = millis(); //... set time to NOW so the fan will turn on
2370
     }
2370
     }
2371
-    
2372
-    if ((millis() - lastMotor) >= (CONTROLLERFAN_SECS*1000UL) || lastMotor == 0) //If the last time any driver was enabled, is longer since than CONTROLLERSEC...   
2371
+
2372
+    if ((millis() - lastMotor) >= (CONTROLLERFAN_SECS*1000UL) || lastMotor == 0) //If the last time any driver was enabled, is longer since than CONTROLLERSEC...
2373
     {
2373
     {
2374
-        digitalWrite(CONTROLLERFAN_PIN, 0); 
2375
-        analogWrite(CONTROLLERFAN_PIN, 0); 
2374
+        digitalWrite(CONTROLLERFAN_PIN, 0);
2375
+        analogWrite(CONTROLLERFAN_PIN, 0);
2376
     }
2376
     }
2377
     else
2377
     else
2378
     {
2378
     {
2379
         // allows digital or PWM fan output to be used (see M42 handling)
2379
         // allows digital or PWM fan output to be used (see M42 handling)
2380
         digitalWrite(CONTROLLERFAN_PIN, CONTROLLERFAN_SPEED);
2380
         digitalWrite(CONTROLLERFAN_PIN, CONTROLLERFAN_SPEED);
2381
-        analogWrite(CONTROLLERFAN_PIN, CONTROLLERFAN_SPEED); 
2381
+        analogWrite(CONTROLLERFAN_PIN, CONTROLLERFAN_SPEED);
2382
     }
2382
     }
2383
   }
2383
   }
2384
 }
2384
 }
2445
 
2445
 
2446
 #if defined(PS_ON_PIN) && PS_ON_PIN > -1
2446
 #if defined(PS_ON_PIN) && PS_ON_PIN > -1
2447
   pinMode(PS_ON_PIN,INPUT);
2447
   pinMode(PS_ON_PIN,INPUT);
2448
-#endif  
2448
+#endif
2449
   SERIAL_ERROR_START;
2449
   SERIAL_ERROR_START;
2450
   SERIAL_ERRORLNPGM(MSG_ERR_KILLED);
2450
   SERIAL_ERRORLNPGM(MSG_ERR_KILLED);
2451
   LCD_ALERTMESSAGEPGM(MSG_KILLED);
2451
   LCD_ALERTMESSAGEPGM(MSG_KILLED);

+ 16
- 13
Marlin/example_configurations/delta/Configuration.h View File

141
 #define TEMP_SENSOR_BED 0
141
 #define TEMP_SENSOR_BED 0
142
 
142
 
143
 // This makes temp sensor 1 a redundant sensor for sensor 0. If the temperatures difference between these sensors is to high the print will be aborted.
143
 // This makes temp sensor 1 a redundant sensor for sensor 0. If the temperatures difference between these sensors is to high the print will be aborted.
144
-//#define TEMP_SENSOR_1_AS_REDUNDANT 
144
+//#define TEMP_SENSOR_1_AS_REDUNDANT
145
 #define MAX_REDUNDANT_TEMP_SENSOR_DIFF 10
145
 #define MAX_REDUNDANT_TEMP_SENSOR_DIFF 10
146
 
146
 
147
 // Actual temperature must be close to target for this long before M109 returns success
147
 // Actual temperature must be close to target for this long before M109 returns success
278
 #endif
278
 #endif
279
 
279
 
280
 // The pullups are needed if you directly connect a mechanical endswitch between the signal and ground pins.
280
 // The pullups are needed if you directly connect a mechanical endswitch between the signal and ground pins.
281
-const bool X_ENDSTOPS_INVERTING = false; // set to true to invert the logic of the endstops.
282
-const bool Y_ENDSTOPS_INVERTING = false; // set to true to invert the logic of the endstops.
283
-const bool Z_ENDSTOPS_INVERTING = false; // set to true to invert the logic of the endstops.
281
+const bool X_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop.
282
+const bool Y_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop.
283
+const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop.
284
+const bool X_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop.
285
+const bool Y_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop.
286
+const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop.
284
 
287
 
285
 // deltas never have min endstops
288
 // deltas never have min endstops
286
 #define DISABLE_MIN_ENDSTOPS
289
 #define DISABLE_MIN_ENDSTOPS
386
 //#define EEPROM_CHITCHAT
389
 //#define EEPROM_CHITCHAT
387
 
390
 
388
 // Preheat Constants
391
 // Preheat Constants
389
-#define PLA_PREHEAT_HOTEND_TEMP 180 
392
+#define PLA_PREHEAT_HOTEND_TEMP 180
390
 #define PLA_PREHEAT_HPB_TEMP 70
393
 #define PLA_PREHEAT_HPB_TEMP 70
391
 #define PLA_PREHEAT_FAN_SPEED 255   // Insert Value between 0 and 255
394
 #define PLA_PREHEAT_FAN_SPEED 255   // Insert Value between 0 and 255
392
 
395
 
471
   #define LCD_I2C_TYPE_PCF8575
474
   #define LCD_I2C_TYPE_PCF8575
472
   #define LCD_I2C_ADDRESS 0x27   // I2C Address of the port expander
475
   #define LCD_I2C_ADDRESS 0x27   // I2C Address of the port expander
473
   #define NEWPANEL
476
   #define NEWPANEL
474
-  #define ULTIPANEL 
477
+  #define ULTIPANEL
475
 #endif
478
 #endif
476
 
479
 
477
 // PANELOLU2 LCD with status LEDs, separate encoder and click inputs
480
 // PANELOLU2 LCD with status LEDs, separate encoder and click inputs
480
   // This uses the LiquidTWI2 library v1.2.3 or later ( https://github.com/lincomatic/LiquidTWI2 )
483
   // This uses the LiquidTWI2 library v1.2.3 or later ( https://github.com/lincomatic/LiquidTWI2 )
481
   // Make sure the LiquidTWI2 directory is placed in the Arduino or Sketchbook libraries subdirectory.
484
   // Make sure the LiquidTWI2 directory is placed in the Arduino or Sketchbook libraries subdirectory.
482
   // (v1.2.3 no longer requires you to define PANELOLU in the LiquidTWI2.h library header file)
485
   // (v1.2.3 no longer requires you to define PANELOLU in the LiquidTWI2.h library header file)
483
-  // Note: The PANELOLU2 encoder click input can either be directly connected to a pin 
484
-  //       (if BTN_ENC defined to != -1) or read through I2C (when BTN_ENC == -1). 
486
+  // Note: The PANELOLU2 encoder click input can either be directly connected to a pin
487
+  //       (if BTN_ENC defined to != -1) or read through I2C (when BTN_ENC == -1).
485
   #define LCD_I2C_TYPE_MCP23017
488
   #define LCD_I2C_TYPE_MCP23017
486
   #define LCD_I2C_ADDRESS 0x20 // I2C Address of the port expander
489
   #define LCD_I2C_ADDRESS 0x20 // I2C Address of the port expander
487
   #define LCD_USE_I2C_BUZZER //comment out to disable buzzer on LCD
490
   #define LCD_USE_I2C_BUZZER //comment out to disable buzzer on LCD
488
   #define NEWPANEL
491
   #define NEWPANEL
489
-  #define ULTIPANEL 
492
+  #define ULTIPANEL
490
 #endif
493
 #endif
491
 
494
 
492
 // Panucatt VIKI LCD with status LEDs, integrated click & L/R/U/P buttons, separate encoder inputs
495
 // Panucatt VIKI LCD with status LEDs, integrated click & L/R/U/P buttons, separate encoder inputs
496
   // Make sure the LiquidTWI2 directory is placed in the Arduino or Sketchbook libraries subdirectory.
499
   // Make sure the LiquidTWI2 directory is placed in the Arduino or Sketchbook libraries subdirectory.
497
   // Note: The pause/stop/resume LCD button pin should be connected to the Arduino
500
   // Note: The pause/stop/resume LCD button pin should be connected to the Arduino
498
   //       BTN_ENC pin (or set BTN_ENC to -1 if not used)
501
   //       BTN_ENC pin (or set BTN_ENC to -1 if not used)
499
-  #define LCD_I2C_TYPE_MCP23017 
502
+  #define LCD_I2C_TYPE_MCP23017
500
   #define LCD_I2C_ADDRESS 0x20 // I2C Address of the port expander
503
   #define LCD_I2C_ADDRESS 0x20 // I2C Address of the port expander
501
   #define LCD_USE_I2C_BUZZER //comment out to disable buzzer on LCD (requires LiquidTWI2 v1.2.3 or later)
504
   #define LCD_USE_I2C_BUZZER //comment out to disable buzzer on LCD (requires LiquidTWI2 v1.2.3 or later)
502
   #define NEWPANEL
505
   #define NEWPANEL
503
-  #define ULTIPANEL 
506
+  #define ULTIPANEL
504
 #endif
507
 #endif
505
 
508
 
506
 #ifdef ULTIPANEL
509
 #ifdef ULTIPANEL
572
 //#define NUM_SERVOS 3 // Servo index starts with 0 for M280 command
575
 //#define NUM_SERVOS 3 // Servo index starts with 0 for M280 command
573
 
576
 
574
 // Servo Endstops
577
 // Servo Endstops
575
-// 
578
+//
576
 // This allows for servo actuated endstops, primary usage is for the Z Axis to eliminate calibration or bed height changes.
579
 // This allows for servo actuated endstops, primary usage is for the Z Axis to eliminate calibration or bed height changes.
577
 // Use M206 command to correct for switch height offset to actual nozzle height. Store that setting with M500.
580
 // Use M206 command to correct for switch height offset to actual nozzle height. Store that setting with M500.
578
-// 
581
+//
579
 //#define SERVO_ENDSTOPS {-1, -1, 0} // Servo index for X, Y, Z. Disable with -1
582
 //#define SERVO_ENDSTOPS {-1, -1, 0} // Servo index for X, Y, Z. Disable with -1
580
 //#define SERVO_ENDSTOP_ANGLES {0,0, 0,0, 70,0} // X,Y,Z Axis Extend and Retract angles
583
 //#define SERVO_ENDSTOP_ANGLES {0,0, 0,0, 70,0} // X,Y,Z Axis Extend and Retract angles
581
 
584
 

+ 119
- 119
Marlin/stepper.cpp View File

48
 // Variables used by The Stepper Driver Interrupt
48
 // Variables used by The Stepper Driver Interrupt
49
 static unsigned char out_bits;        // The next stepping-bits to be output
49
 static unsigned char out_bits;        // The next stepping-bits to be output
50
 static long counter_x,       // Counter variables for the bresenham line tracer
50
 static long counter_x,       // Counter variables for the bresenham line tracer
51
-            counter_y, 
52
-            counter_z,       
51
+            counter_y,
52
+            counter_z,
53
             counter_e;
53
             counter_e;
54
 volatile static unsigned long step_events_completed; // The number of step events executed in the current block
54
 volatile static unsigned long step_events_completed; // The number of step events executed in the current block
55
 #ifdef ADVANCE
55
 #ifdef ADVANCE
224
 //   |               BLOCK 1            |      BLOCK 2          |    d
224
 //   |               BLOCK 1            |      BLOCK 2          |    d
225
 //
225
 //
226
 //                           time ----->
226
 //                           time ----->
227
-// 
228
-//  The trapezoid is the shape the speed curve over time. It starts at block->initial_rate, accelerates 
229
-//  first block->accelerate_until step_events_completed, then keeps going at constant speed until 
227
+//
228
+//  The trapezoid is the shape the speed curve over time. It starts at block->initial_rate, accelerates
229
+//  first block->accelerate_until step_events_completed, then keeps going at constant speed until
230
 //  step_events_completed reaches block->decelerate_after after which it decelerates until the trapezoid generator is reset.
230
 //  step_events_completed reaches block->decelerate_after after which it decelerates until the trapezoid generator is reset.
231
 //  The slope of acceleration is calculated with the leib ramp alghorithm.
231
 //  The slope of acceleration is calculated with the leib ramp alghorithm.
232
 
232
 
233
 void st_wake_up() {
233
 void st_wake_up() {
234
   //  TCNT1 = 0;
234
   //  TCNT1 = 0;
235
-  ENABLE_STEPPER_DRIVER_INTERRUPT();  
235
+  ENABLE_STEPPER_DRIVER_INTERRUPT();
236
 }
236
 }
237
 
237
 
238
 void step_wait(){
238
 void step_wait(){
239
     for(int8_t i=0; i < 6; i++){
239
     for(int8_t i=0; i < 6; i++){
240
     }
240
     }
241
 }
241
 }
242
-  
242
+
243
 
243
 
244
 FORCE_INLINE unsigned short calc_timer(unsigned short step_rate) {
244
 FORCE_INLINE unsigned short calc_timer(unsigned short step_rate) {
245
   unsigned short timer;
245
   unsigned short timer;
246
   if(step_rate > MAX_STEP_FREQUENCY) step_rate = MAX_STEP_FREQUENCY;
246
   if(step_rate > MAX_STEP_FREQUENCY) step_rate = MAX_STEP_FREQUENCY;
247
-  
247
+
248
   if(step_rate > 20000) { // If steprate > 20kHz >> step 4 times
248
   if(step_rate > 20000) { // If steprate > 20kHz >> step 4 times
249
     step_rate = (step_rate >> 2)&0x3fff;
249
     step_rate = (step_rate >> 2)&0x3fff;
250
     step_loops = 4;
250
     step_loops = 4;
255
   }
255
   }
256
   else {
256
   else {
257
     step_loops = 1;
257
     step_loops = 1;
258
-  } 
259
-  
258
+  }
259
+
260
   if(step_rate < (F_CPU/500000)) step_rate = (F_CPU/500000);
260
   if(step_rate < (F_CPU/500000)) step_rate = (F_CPU/500000);
261
   step_rate -= (F_CPU/500000); // Correct for minimal speed
261
   step_rate -= (F_CPU/500000); // Correct for minimal speed
262
-  if(step_rate >= (8*256)){ // higher step rate 
262
+  if(step_rate >= (8*256)){ // higher step rate
263
     unsigned short table_address = (unsigned short)&speed_lookuptable_fast[(unsigned char)(step_rate>>8)][0];
263
     unsigned short table_address = (unsigned short)&speed_lookuptable_fast[(unsigned char)(step_rate>>8)][0];
264
     unsigned char tmp_step_rate = (step_rate & 0x00ff);
264
     unsigned char tmp_step_rate = (step_rate & 0x00ff);
265
     unsigned short gain = (unsigned short)pgm_read_word_near(table_address+2);
265
     unsigned short gain = (unsigned short)pgm_read_word_near(table_address+2);
276
   return timer;
276
   return timer;
277
 }
277
 }
278
 
278
 
279
-// Initializes the trapezoid generator from the current block. Called whenever a new 
279
+// Initializes the trapezoid generator from the current block. Called whenever a new
280
 // block begins.
280
 // block begins.
281
 FORCE_INLINE void trapezoid_generator_reset() {
281
 FORCE_INLINE void trapezoid_generator_reset() {
282
   #ifdef ADVANCE
282
   #ifdef ADVANCE
284
     final_advance = current_block->final_advance;
284
     final_advance = current_block->final_advance;
285
     // Do E steps + advance steps
285
     // Do E steps + advance steps
286
     e_steps[current_block->active_extruder] += ((advance >>8) - old_advance);
286
     e_steps[current_block->active_extruder] += ((advance >>8) - old_advance);
287
-    old_advance = advance >>8;  
287
+    old_advance = advance >>8;
288
   #endif
288
   #endif
289
   deceleration_time = 0;
289
   deceleration_time = 0;
290
   // step_rate to timer interval
290
   // step_rate to timer interval
294
   acc_step_rate = current_block->initial_rate;
294
   acc_step_rate = current_block->initial_rate;
295
   acceleration_time = calc_timer(acc_step_rate);
295
   acceleration_time = calc_timer(acc_step_rate);
296
   OCR1A = acceleration_time;
296
   OCR1A = acceleration_time;
297
-  
297
+
298
 //    SERIAL_ECHO_START;
298
 //    SERIAL_ECHO_START;
299
 //    SERIAL_ECHOPGM("advance :");
299
 //    SERIAL_ECHOPGM("advance :");
300
 //    SERIAL_ECHO(current_block->advance/256.0);
300
 //    SERIAL_ECHO(current_block->advance/256.0);
304
 //  SERIAL_ECHO(current_block->initial_advance/256.0);
304
 //  SERIAL_ECHO(current_block->initial_advance/256.0);
305
 //    SERIAL_ECHOPGM("final advance :");
305
 //    SERIAL_ECHOPGM("final advance :");
306
 //    SERIAL_ECHOLN(current_block->final_advance/256.0);
306
 //    SERIAL_ECHOLN(current_block->final_advance/256.0);
307
-    
307
+
308
 }
308
 }
309
 
309
 
310
-// "The Stepper Driver Interrupt" - This timer interrupt is the workhorse.  
311
-// It pops blocks from the block_buffer and executes them by pulsing the stepper pins appropriately. 
310
+// "The Stepper Driver Interrupt" - This timer interrupt is the workhorse.
311
+// It pops blocks from the block_buffer and executes them by pulsing the stepper pins appropriately.
312
 ISR(TIMER1_COMPA_vect)
312
 ISR(TIMER1_COMPA_vect)
313
-{    
313
+{
314
   // If there is no current block, attempt to pop one from the buffer
314
   // If there is no current block, attempt to pop one from the buffer
315
   if (current_block == NULL) {
315
   if (current_block == NULL) {
316
     // Anything in the buffer?
316
     // Anything in the buffer?
322
       counter_y = counter_x;
322
       counter_y = counter_x;
323
       counter_z = counter_x;
323
       counter_z = counter_x;
324
       counter_e = counter_x;
324
       counter_e = counter_x;
325
-      step_events_completed = 0; 
326
-      
327
-      #ifdef Z_LATE_ENABLE 
325
+      step_events_completed = 0;
326
+
327
+      #ifdef Z_LATE_ENABLE
328
         if(current_block->steps_z > 0) {
328
         if(current_block->steps_z > 0) {
329
           enable_z();
329
           enable_z();
330
           OCR1A = 2000; //1ms wait
330
           OCR1A = 2000; //1ms wait
331
           return;
331
           return;
332
         }
332
         }
333
       #endif
333
       #endif
334
-      
334
+
335
 //      #ifdef ADVANCE
335
 //      #ifdef ADVANCE
336
 //      e_steps[current_block->active_extruder] = 0;
336
 //      e_steps[current_block->active_extruder] = 0;
337
 //      #endif
337
 //      #endif
338
-    } 
338
+    }
339
     else {
339
     else {
340
         OCR1A=2000; // 1kHz.
340
         OCR1A=2000; // 1kHz.
341
-    }    
342
-  } 
341
+    }
342
+  }
343
 
343
 
344
   if (current_block != NULL) {
344
   if (current_block != NULL) {
345
     // Set directions TO DO This should be done once during init of trapezoid. Endstops -> interrupt
345
     // Set directions TO DO This should be done once during init of trapezoid. Endstops -> interrupt
352
       if (active_extruder != 0)
352
       if (active_extruder != 0)
353
         WRITE(X2_DIR_PIN,INVERT_X_DIR);
353
         WRITE(X2_DIR_PIN,INVERT_X_DIR);
354
       else
354
       else
355
-      #endif        
355
+      #endif
356
         WRITE(X_DIR_PIN, INVERT_X_DIR);
356
         WRITE(X_DIR_PIN, INVERT_X_DIR);
357
       count_direction[X_AXIS]=-1;
357
       count_direction[X_AXIS]=-1;
358
     }
358
     }
361
       if (active_extruder != 0)
361
       if (active_extruder != 0)
362
         WRITE(X2_DIR_PIN,!INVERT_X_DIR);
362
         WRITE(X2_DIR_PIN,!INVERT_X_DIR);
363
       else
363
       else
364
-      #endif        
364
+      #endif
365
         WRITE(X_DIR_PIN, !INVERT_X_DIR);
365
         WRITE(X_DIR_PIN, !INVERT_X_DIR);
366
       count_direction[X_AXIS]=1;
366
       count_direction[X_AXIS]=1;
367
     }
367
     }
373
       WRITE(Y_DIR_PIN, !INVERT_Y_DIR);
373
       WRITE(Y_DIR_PIN, !INVERT_Y_DIR);
374
       count_direction[Y_AXIS]=1;
374
       count_direction[Y_AXIS]=1;
375
     }
375
     }
376
-    
376
+
377
     // Set direction en check limit switches
377
     // Set direction en check limit switches
378
     #ifndef COREXY
378
     #ifndef COREXY
379
     if ((out_bits & (1<<X_AXIS)) != 0) {   // stepping along -X axis
379
     if ((out_bits & (1<<X_AXIS)) != 0) {   // stepping along -X axis
385
         #ifdef DUAL_X_CARRIAGE
385
         #ifdef DUAL_X_CARRIAGE
386
         // with 2 x-carriages, endstops are only checked in the homing direction for the active extruder
386
         // with 2 x-carriages, endstops are only checked in the homing direction for the active extruder
387
         if ((active_extruder == 0 && X_HOME_DIR == -1) || (active_extruder != 0 && X2_HOME_DIR == -1))
387
         if ((active_extruder == 0 && X_HOME_DIR == -1) || (active_extruder != 0 && X2_HOME_DIR == -1))
388
-        #endif          
388
+        #endif
389
         {
389
         {
390
           #if defined(X_MIN_PIN) && X_MIN_PIN > -1
390
           #if defined(X_MIN_PIN) && X_MIN_PIN > -1
391
-            bool x_min_endstop=(READ(X_MIN_PIN) != X_ENDSTOPS_INVERTING);
391
+            bool x_min_endstop=(READ(X_MIN_PIN) != X_MIN_ENDSTOP_INVERTING);
392
             if(x_min_endstop && old_x_min_endstop && (current_block->steps_x > 0)) {
392
             if(x_min_endstop && old_x_min_endstop && (current_block->steps_x > 0)) {
393
               endstops_trigsteps[X_AXIS] = count_position[X_AXIS];
393
               endstops_trigsteps[X_AXIS] = count_position[X_AXIS];
394
               endstop_x_hit=true;
394
               endstop_x_hit=true;
400
       }
400
       }
401
     }
401
     }
402
     else { // +direction
402
     else { // +direction
403
-      CHECK_ENDSTOPS 
403
+      CHECK_ENDSTOPS
404
       {
404
       {
405
         #ifdef DUAL_X_CARRIAGE
405
         #ifdef DUAL_X_CARRIAGE
406
         // with 2 x-carriages, endstops are only checked in the homing direction for the active extruder
406
         // with 2 x-carriages, endstops are only checked in the homing direction for the active extruder
407
         if ((active_extruder == 0 && X_HOME_DIR == 1) || (active_extruder != 0 && X2_HOME_DIR == 1))
407
         if ((active_extruder == 0 && X_HOME_DIR == 1) || (active_extruder != 0 && X2_HOME_DIR == 1))
408
-        #endif          
408
+        #endif
409
         {
409
         {
410
           #if defined(X_MAX_PIN) && X_MAX_PIN > -1
410
           #if defined(X_MAX_PIN) && X_MAX_PIN > -1
411
-            bool x_max_endstop=(READ(X_MAX_PIN) != X_ENDSTOPS_INVERTING);
411
+            bool x_max_endstop=(READ(X_MAX_PIN) != X_MAX_ENDSTOP_INVERTING);
412
             if(x_max_endstop && old_x_max_endstop && (current_block->steps_x > 0)){
412
             if(x_max_endstop && old_x_max_endstop && (current_block->steps_x > 0)){
413
               endstops_trigsteps[X_AXIS] = count_position[X_AXIS];
413
               endstops_trigsteps[X_AXIS] = count_position[X_AXIS];
414
               endstop_x_hit=true;
414
               endstop_x_hit=true;
416
             }
416
             }
417
             old_x_max_endstop = x_max_endstop;
417
             old_x_max_endstop = x_max_endstop;
418
           #endif
418
           #endif
419
-        }  
419
+        }
420
       }
420
       }
421
     }
421
     }
422
 
422
 
428
       CHECK_ENDSTOPS
428
       CHECK_ENDSTOPS
429
       {
429
       {
430
         #if defined(Y_MIN_PIN) && Y_MIN_PIN > -1
430
         #if defined(Y_MIN_PIN) && Y_MIN_PIN > -1
431
-          bool y_min_endstop=(READ(Y_MIN_PIN) != Y_ENDSTOPS_INVERTING);
431
+          bool y_min_endstop=(READ(Y_MIN_PIN) != Y_MIN_ENDSTOP_INVERTING);
432
           if(y_min_endstop && old_y_min_endstop && (current_block->steps_y > 0)) {
432
           if(y_min_endstop && old_y_min_endstop && (current_block->steps_y > 0)) {
433
             endstops_trigsteps[Y_AXIS] = count_position[Y_AXIS];
433
             endstops_trigsteps[Y_AXIS] = count_position[Y_AXIS];
434
             endstop_y_hit=true;
434
             endstop_y_hit=true;
442
       CHECK_ENDSTOPS
442
       CHECK_ENDSTOPS
443
       {
443
       {
444
         #if defined(Y_MAX_PIN) && Y_MAX_PIN > -1
444
         #if defined(Y_MAX_PIN) && Y_MAX_PIN > -1
445
-          bool y_max_endstop=(READ(Y_MAX_PIN) != Y_ENDSTOPS_INVERTING);
445
+          bool y_max_endstop=(READ(Y_MAX_PIN) != Y_MAX_ENDSTOP_INVERTING);
446
           if(y_max_endstop && old_y_max_endstop && (current_block->steps_y > 0)){
446
           if(y_max_endstop && old_y_max_endstop && (current_block->steps_y > 0)){
447
             endstops_trigsteps[Y_AXIS] = count_position[Y_AXIS];
447
             endstops_trigsteps[Y_AXIS] = count_position[Y_AXIS];
448
             endstop_y_hit=true;
448
             endstop_y_hit=true;
455
 
455
 
456
     if ((out_bits & (1<<Z_AXIS)) != 0) {   // -direction
456
     if ((out_bits & (1<<Z_AXIS)) != 0) {   // -direction
457
       WRITE(Z_DIR_PIN,INVERT_Z_DIR);
457
       WRITE(Z_DIR_PIN,INVERT_Z_DIR);
458
-      
458
+
459
 	  #ifdef Z_DUAL_STEPPER_DRIVERS
459
 	  #ifdef Z_DUAL_STEPPER_DRIVERS
460
         WRITE(Z2_DIR_PIN,INVERT_Z_DIR);
460
         WRITE(Z2_DIR_PIN,INVERT_Z_DIR);
461
       #endif
461
       #endif
462
-      
462
+
463
       count_direction[Z_AXIS]=-1;
463
       count_direction[Z_AXIS]=-1;
464
       CHECK_ENDSTOPS
464
       CHECK_ENDSTOPS
465
       {
465
       {
466
         #if defined(Z_MIN_PIN) && Z_MIN_PIN > -1
466
         #if defined(Z_MIN_PIN) && Z_MIN_PIN > -1
467
-          bool z_min_endstop=(READ(Z_MIN_PIN) != Z_ENDSTOPS_INVERTING);
467
+          bool z_min_endstop=(READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING);
468
           if(z_min_endstop && old_z_min_endstop && (current_block->steps_z > 0)) {
468
           if(z_min_endstop && old_z_min_endstop && (current_block->steps_z > 0)) {
469
             endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS];
469
             endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS];
470
             endstop_z_hit=true;
470
             endstop_z_hit=true;
485
       CHECK_ENDSTOPS
485
       CHECK_ENDSTOPS
486
       {
486
       {
487
         #if defined(Z_MAX_PIN) && Z_MAX_PIN > -1
487
         #if defined(Z_MAX_PIN) && Z_MAX_PIN > -1
488
-          bool z_max_endstop=(READ(Z_MAX_PIN) != Z_ENDSTOPS_INVERTING);
488
+          bool z_max_endstop=(READ(Z_MAX_PIN) != Z_MAX_ENDSTOP_INVERTING);
489
           if(z_max_endstop && old_z_max_endstop && (current_block->steps_z > 0)) {
489
           if(z_max_endstop && old_z_max_endstop && (current_block->steps_z > 0)) {
490
             endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS];
490
             endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS];
491
             endstop_z_hit=true;
491
             endstop_z_hit=true;
506
         count_direction[E_AXIS]=1;
506
         count_direction[E_AXIS]=1;
507
       }
507
       }
508
     #endif //!ADVANCE
508
     #endif //!ADVANCE
509
-    
510
 
509
 
511
-    
512
-    for(int8_t i=0; i < step_loops; i++) { // Take multiple steps per interrupt (For high speed moves) 
510
+
511
+
512
+    for(int8_t i=0; i < step_loops; i++) { // Take multiple steps per interrupt (For high speed moves)
513
       #ifndef AT90USB
513
       #ifndef AT90USB
514
       MSerial.checkRx(); // Check for serial chars.
514
       MSerial.checkRx(); // Check for serial chars.
515
       #endif
515
       #endif
524
         else {
524
         else {
525
           e_steps[current_block->active_extruder]++;
525
           e_steps[current_block->active_extruder]++;
526
         }
526
         }
527
-      }    
527
+      }
528
       #endif //ADVANCE
528
       #endif //ADVANCE
529
 
529
 
530
         counter_x += current_block->steps_x;
530
         counter_x += current_block->steps_x;
533
           if (active_extruder != 0)
533
           if (active_extruder != 0)
534
             WRITE(X2_STEP_PIN,!INVERT_X_STEP_PIN);
534
             WRITE(X2_STEP_PIN,!INVERT_X_STEP_PIN);
535
           else
535
           else
536
-          #endif        
536
+          #endif
537
             WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN);
537
             WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN);
538
           counter_x -= current_block->step_event_count;
538
           counter_x -= current_block->step_event_count;
539
-          count_position[X_AXIS]+=count_direction[X_AXIS];   
539
+          count_position[X_AXIS]+=count_direction[X_AXIS];
540
           #ifdef DUAL_X_CARRIAGE
540
           #ifdef DUAL_X_CARRIAGE
541
           if (active_extruder != 0)
541
           if (active_extruder != 0)
542
             WRITE(X2_STEP_PIN,INVERT_X_STEP_PIN);
542
             WRITE(X2_STEP_PIN,INVERT_X_STEP_PIN);
543
           else
543
           else
544
-          #endif        
544
+          #endif
545
             WRITE(X_STEP_PIN, INVERT_X_STEP_PIN);
545
             WRITE(X_STEP_PIN, INVERT_X_STEP_PIN);
546
         }
546
         }
547
-  
547
+
548
         counter_y += current_block->steps_y;
548
         counter_y += current_block->steps_y;
549
         if (counter_y > 0) {
549
         if (counter_y > 0) {
550
           WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN);
550
           WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN);
551
-          counter_y -= current_block->step_event_count; 
552
-          count_position[Y_AXIS]+=count_direction[Y_AXIS]; 
551
+          counter_y -= current_block->step_event_count;
552
+          count_position[Y_AXIS]+=count_direction[Y_AXIS];
553
           WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN);
553
           WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN);
554
         }
554
         }
555
-  
555
+
556
       counter_z += current_block->steps_z;
556
       counter_z += current_block->steps_z;
557
       if (counter_z > 0) {
557
       if (counter_z > 0) {
558
         WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN);
558
         WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN);
559
-        
559
+
560
 		#ifdef Z_DUAL_STEPPER_DRIVERS
560
 		#ifdef Z_DUAL_STEPPER_DRIVERS
561
           WRITE(Z2_STEP_PIN, !INVERT_Z_STEP_PIN);
561
           WRITE(Z2_STEP_PIN, !INVERT_Z_STEP_PIN);
562
         #endif
562
         #endif
563
-        
563
+
564
         counter_z -= current_block->step_event_count;
564
         counter_z -= current_block->step_event_count;
565
         count_position[Z_AXIS]+=count_direction[Z_AXIS];
565
         count_position[Z_AXIS]+=count_direction[Z_AXIS];
566
         WRITE(Z_STEP_PIN, INVERT_Z_STEP_PIN);
566
         WRITE(Z_STEP_PIN, INVERT_Z_STEP_PIN);
567
-        
567
+
568
 		#ifdef Z_DUAL_STEPPER_DRIVERS
568
 		#ifdef Z_DUAL_STEPPER_DRIVERS
569
           WRITE(Z2_STEP_PIN, INVERT_Z_STEP_PIN);
569
           WRITE(Z2_STEP_PIN, INVERT_Z_STEP_PIN);
570
         #endif
570
         #endif
579
           WRITE_E_STEP(INVERT_E_STEP_PIN);
579
           WRITE_E_STEP(INVERT_E_STEP_PIN);
580
         }
580
         }
581
       #endif //!ADVANCE
581
       #endif //!ADVANCE
582
-      step_events_completed += 1;  
582
+      step_events_completed += 1;
583
       if(step_events_completed >= current_block->step_event_count) break;
583
       if(step_events_completed >= current_block->step_event_count) break;
584
     }
584
     }
585
     // Calculare new timer value
585
     // Calculare new timer value
586
     unsigned short timer;
586
     unsigned short timer;
587
     unsigned short step_rate;
587
     unsigned short step_rate;
588
     if (step_events_completed <= (unsigned long int)current_block->accelerate_until) {
588
     if (step_events_completed <= (unsigned long int)current_block->accelerate_until) {
589
-      
589
+
590
       MultiU24X24toH16(acc_step_rate, acceleration_time, current_block->acceleration_rate);
590
       MultiU24X24toH16(acc_step_rate, acceleration_time, current_block->acceleration_rate);
591
       acc_step_rate += current_block->initial_rate;
591
       acc_step_rate += current_block->initial_rate;
592
-      
592
+
593
       // upper limit
593
       // upper limit
594
       if(acc_step_rate > current_block->nominal_rate)
594
       if(acc_step_rate > current_block->nominal_rate)
595
         acc_step_rate = current_block->nominal_rate;
595
         acc_step_rate = current_block->nominal_rate;
605
         //if(advance > current_block->advance) advance = current_block->advance;
605
         //if(advance > current_block->advance) advance = current_block->advance;
606
         // Do E steps + advance steps
606
         // Do E steps + advance steps
607
         e_steps[current_block->active_extruder] += ((advance >>8) - old_advance);
607
         e_steps[current_block->active_extruder] += ((advance >>8) - old_advance);
608
-        old_advance = advance >>8;  
609
-        
608
+        old_advance = advance >>8;
609
+
610
       #endif
610
       #endif
611
-    } 
612
-    else if (step_events_completed > (unsigned long int)current_block->decelerate_after) {   
611
+    }
612
+    else if (step_events_completed > (unsigned long int)current_block->decelerate_after) {
613
       MultiU24X24toH16(step_rate, deceleration_time, current_block->acceleration_rate);
613
       MultiU24X24toH16(step_rate, deceleration_time, current_block->acceleration_rate);
614
-      
614
+
615
       if(step_rate > acc_step_rate) { // Check step_rate stays positive
615
       if(step_rate > acc_step_rate) { // Check step_rate stays positive
616
         step_rate = current_block->final_rate;
616
         step_rate = current_block->final_rate;
617
       }
617
       }
634
         if(advance < final_advance) advance = final_advance;
634
         if(advance < final_advance) advance = final_advance;
635
         // Do E steps + advance steps
635
         // Do E steps + advance steps
636
         e_steps[current_block->active_extruder] += ((advance >>8) - old_advance);
636
         e_steps[current_block->active_extruder] += ((advance >>8) - old_advance);
637
-        old_advance = advance >>8;  
637
+        old_advance = advance >>8;
638
       #endif //ADVANCE
638
       #endif //ADVANCE
639
     }
639
     }
640
     else {
640
     else {
643
       step_loops = step_loops_nominal;
643
       step_loops = step_loops_nominal;
644
     }
644
     }
645
 
645
 
646
-    // If current block is finished, reset pointer 
646
+    // If current block is finished, reset pointer
647
     if (step_events_completed >= current_block->step_event_count) {
647
     if (step_events_completed >= current_block->step_event_count) {
648
       current_block = NULL;
648
       current_block = NULL;
649
       plan_discard_current_block();
649
       plan_discard_current_block();
650
-    }   
651
-  } 
650
+    }
651
+  }
652
 }
652
 }
653
 
653
 
654
 #ifdef ADVANCE
654
 #ifdef ADVANCE
667
           WRITE(E0_DIR_PIN, INVERT_E0_DIR);
667
           WRITE(E0_DIR_PIN, INVERT_E0_DIR);
668
           e_steps[0]++;
668
           e_steps[0]++;
669
           WRITE(E0_STEP_PIN, !INVERT_E_STEP_PIN);
669
           WRITE(E0_STEP_PIN, !INVERT_E_STEP_PIN);
670
-        } 
670
+        }
671
         else if (e_steps[0] > 0) {
671
         else if (e_steps[0] > 0) {
672
           WRITE(E0_DIR_PIN, !INVERT_E0_DIR);
672
           WRITE(E0_DIR_PIN, !INVERT_E0_DIR);
673
           e_steps[0]--;
673
           e_steps[0]--;
681
           WRITE(E1_DIR_PIN, INVERT_E1_DIR);
681
           WRITE(E1_DIR_PIN, INVERT_E1_DIR);
682
           e_steps[1]++;
682
           e_steps[1]++;
683
           WRITE(E1_STEP_PIN, !INVERT_E_STEP_PIN);
683
           WRITE(E1_STEP_PIN, !INVERT_E_STEP_PIN);
684
-        } 
684
+        }
685
         else if (e_steps[1] > 0) {
685
         else if (e_steps[1] > 0) {
686
           WRITE(E1_DIR_PIN, !INVERT_E1_DIR);
686
           WRITE(E1_DIR_PIN, !INVERT_E1_DIR);
687
           e_steps[1]--;
687
           e_steps[1]--;
696
           WRITE(E2_DIR_PIN, INVERT_E2_DIR);
696
           WRITE(E2_DIR_PIN, INVERT_E2_DIR);
697
           e_steps[2]++;
697
           e_steps[2]++;
698
           WRITE(E2_STEP_PIN, !INVERT_E_STEP_PIN);
698
           WRITE(E2_STEP_PIN, !INVERT_E_STEP_PIN);
699
-        } 
699
+        }
700
         else if (e_steps[2] > 0) {
700
         else if (e_steps[2] > 0) {
701
           WRITE(E2_DIR_PIN, !INVERT_E2_DIR);
701
           WRITE(E2_DIR_PIN, !INVERT_E2_DIR);
702
           e_steps[2]--;
702
           e_steps[2]--;
712
 {
712
 {
713
   digipot_init(); //Initialize Digipot Motor Current
713
   digipot_init(); //Initialize Digipot Motor Current
714
   microstep_init(); //Initialize Microstepping Pins
714
   microstep_init(); //Initialize Microstepping Pins
715
-  
715
+
716
   //Initialize Dir Pins
716
   //Initialize Dir Pins
717
   #if defined(X_DIR_PIN) && X_DIR_PIN > -1
717
   #if defined(X_DIR_PIN) && X_DIR_PIN > -1
718
     SET_OUTPUT(X_DIR_PIN);
718
     SET_OUTPUT(X_DIR_PIN);
720
   #if defined(X2_DIR_PIN) && X2_DIR_PIN > -1
720
   #if defined(X2_DIR_PIN) && X2_DIR_PIN > -1
721
     SET_OUTPUT(X2_DIR_PIN);
721
     SET_OUTPUT(X2_DIR_PIN);
722
   #endif
722
   #endif
723
-  #if defined(Y_DIR_PIN) && Y_DIR_PIN > -1 
723
+  #if defined(Y_DIR_PIN) && Y_DIR_PIN > -1
724
     SET_OUTPUT(Y_DIR_PIN);
724
     SET_OUTPUT(Y_DIR_PIN);
725
   #endif
725
   #endif
726
-  #if defined(Z_DIR_PIN) && Z_DIR_PIN > -1 
726
+  #if defined(Z_DIR_PIN) && Z_DIR_PIN > -1
727
     SET_OUTPUT(Z_DIR_PIN);
727
     SET_OUTPUT(Z_DIR_PIN);
728
 
728
 
729
     #if defined(Z_DUAL_STEPPER_DRIVERS) && defined(Z2_DIR_PIN) && (Z2_DIR_PIN > -1)
729
     #if defined(Z_DUAL_STEPPER_DRIVERS) && defined(Z2_DIR_PIN) && (Z2_DIR_PIN > -1)
730
       SET_OUTPUT(Z2_DIR_PIN);
730
       SET_OUTPUT(Z2_DIR_PIN);
731
     #endif
731
     #endif
732
   #endif
732
   #endif
733
-  #if defined(E0_DIR_PIN) && E0_DIR_PIN > -1 
733
+  #if defined(E0_DIR_PIN) && E0_DIR_PIN > -1
734
     SET_OUTPUT(E0_DIR_PIN);
734
     SET_OUTPUT(E0_DIR_PIN);
735
   #endif
735
   #endif
736
   #if defined(E1_DIR_PIN) && (E1_DIR_PIN > -1)
736
   #if defined(E1_DIR_PIN) && (E1_DIR_PIN > -1)
757
   #if defined(Z_ENABLE_PIN) && Z_ENABLE_PIN > -1
757
   #if defined(Z_ENABLE_PIN) && Z_ENABLE_PIN > -1
758
     SET_OUTPUT(Z_ENABLE_PIN);
758
     SET_OUTPUT(Z_ENABLE_PIN);
759
     if(!Z_ENABLE_ON) WRITE(Z_ENABLE_PIN,HIGH);
759
     if(!Z_ENABLE_ON) WRITE(Z_ENABLE_PIN,HIGH);
760
-    
760
+
761
     #if defined(Z_DUAL_STEPPER_DRIVERS) && defined(Z2_ENABLE_PIN) && (Z2_ENABLE_PIN > -1)
761
     #if defined(Z_DUAL_STEPPER_DRIVERS) && defined(Z2_ENABLE_PIN) && (Z2_ENABLE_PIN > -1)
762
       SET_OUTPUT(Z2_ENABLE_PIN);
762
       SET_OUTPUT(Z2_ENABLE_PIN);
763
       if(!Z_ENABLE_ON) WRITE(Z2_ENABLE_PIN,HIGH);
763
       if(!Z_ENABLE_ON) WRITE(Z2_ENABLE_PIN,HIGH);
777
   #endif
777
   #endif
778
 
778
 
779
   //endstops and pullups
779
   //endstops and pullups
780
-  
780
+
781
   #if defined(X_MIN_PIN) && X_MIN_PIN > -1
781
   #if defined(X_MIN_PIN) && X_MIN_PIN > -1
782
-    SET_INPUT(X_MIN_PIN); 
782
+    SET_INPUT(X_MIN_PIN);
783
     #ifdef ENDSTOPPULLUP_XMIN
783
     #ifdef ENDSTOPPULLUP_XMIN
784
       WRITE(X_MIN_PIN,HIGH);
784
       WRITE(X_MIN_PIN,HIGH);
785
     #endif
785
     #endif
786
   #endif
786
   #endif
787
-      
787
+
788
   #if defined(Y_MIN_PIN) && Y_MIN_PIN > -1
788
   #if defined(Y_MIN_PIN) && Y_MIN_PIN > -1
789
-    SET_INPUT(Y_MIN_PIN); 
789
+    SET_INPUT(Y_MIN_PIN);
790
     #ifdef ENDSTOPPULLUP_YMIN
790
     #ifdef ENDSTOPPULLUP_YMIN
791
       WRITE(Y_MIN_PIN,HIGH);
791
       WRITE(Y_MIN_PIN,HIGH);
792
     #endif
792
     #endif
793
   #endif
793
   #endif
794
-  
794
+
795
   #if defined(Z_MIN_PIN) && Z_MIN_PIN > -1
795
   #if defined(Z_MIN_PIN) && Z_MIN_PIN > -1
796
-    SET_INPUT(Z_MIN_PIN); 
796
+    SET_INPUT(Z_MIN_PIN);
797
     #ifdef ENDSTOPPULLUP_ZMIN
797
     #ifdef ENDSTOPPULLUP_ZMIN
798
       WRITE(Z_MIN_PIN,HIGH);
798
       WRITE(Z_MIN_PIN,HIGH);
799
     #endif
799
     #endif
800
   #endif
800
   #endif
801
-      
801
+
802
   #if defined(X_MAX_PIN) && X_MAX_PIN > -1
802
   #if defined(X_MAX_PIN) && X_MAX_PIN > -1
803
-    SET_INPUT(X_MAX_PIN); 
803
+    SET_INPUT(X_MAX_PIN);
804
     #ifdef ENDSTOPPULLUP_XMAX
804
     #ifdef ENDSTOPPULLUP_XMAX
805
       WRITE(X_MAX_PIN,HIGH);
805
       WRITE(X_MAX_PIN,HIGH);
806
     #endif
806
     #endif
807
   #endif
807
   #endif
808
-      
808
+
809
   #if defined(Y_MAX_PIN) && Y_MAX_PIN > -1
809
   #if defined(Y_MAX_PIN) && Y_MAX_PIN > -1
810
-    SET_INPUT(Y_MAX_PIN); 
810
+    SET_INPUT(Y_MAX_PIN);
811
     #ifdef ENDSTOPPULLUP_YMAX
811
     #ifdef ENDSTOPPULLUP_YMAX
812
       WRITE(Y_MAX_PIN,HIGH);
812
       WRITE(Y_MAX_PIN,HIGH);
813
     #endif
813
     #endif
814
   #endif
814
   #endif
815
-  
815
+
816
   #if defined(Z_MAX_PIN) && Z_MAX_PIN > -1
816
   #if defined(Z_MAX_PIN) && Z_MAX_PIN > -1
817
-    SET_INPUT(Z_MAX_PIN); 
817
+    SET_INPUT(Z_MAX_PIN);
818
     #ifdef ENDSTOPPULLUP_ZMAX
818
     #ifdef ENDSTOPPULLUP_ZMAX
819
       WRITE(Z_MAX_PIN,HIGH);
819
       WRITE(Z_MAX_PIN,HIGH);
820
     #endif
820
     #endif
821
   #endif
821
   #endif
822
- 
822
+
823
 
823
 
824
   //Initialize Step Pins
824
   //Initialize Step Pins
825
-  #if defined(X_STEP_PIN) && (X_STEP_PIN > -1) 
825
+  #if defined(X_STEP_PIN) && (X_STEP_PIN > -1)
826
     SET_OUTPUT(X_STEP_PIN);
826
     SET_OUTPUT(X_STEP_PIN);
827
     WRITE(X_STEP_PIN,INVERT_X_STEP_PIN);
827
     WRITE(X_STEP_PIN,INVERT_X_STEP_PIN);
828
     disable_x();
828
     disable_x();
829
-  #endif  
830
-  #if defined(X2_STEP_PIN) && (X2_STEP_PIN > -1) 
829
+  #endif
830
+  #if defined(X2_STEP_PIN) && (X2_STEP_PIN > -1)
831
     SET_OUTPUT(X2_STEP_PIN);
831
     SET_OUTPUT(X2_STEP_PIN);
832
     WRITE(X2_STEP_PIN,INVERT_X_STEP_PIN);
832
     WRITE(X2_STEP_PIN,INVERT_X_STEP_PIN);
833
     disable_x();
833
     disable_x();
834
-  #endif  
835
-  #if defined(Y_STEP_PIN) && (Y_STEP_PIN > -1) 
834
+  #endif
835
+  #if defined(Y_STEP_PIN) && (Y_STEP_PIN > -1)
836
     SET_OUTPUT(Y_STEP_PIN);
836
     SET_OUTPUT(Y_STEP_PIN);
837
     WRITE(Y_STEP_PIN,INVERT_Y_STEP_PIN);
837
     WRITE(Y_STEP_PIN,INVERT_Y_STEP_PIN);
838
     disable_y();
838
     disable_y();
839
-  #endif  
840
-  #if defined(Z_STEP_PIN) && (Z_STEP_PIN > -1) 
839
+  #endif
840
+  #if defined(Z_STEP_PIN) && (Z_STEP_PIN > -1)
841
     SET_OUTPUT(Z_STEP_PIN);
841
     SET_OUTPUT(Z_STEP_PIN);
842
     WRITE(Z_STEP_PIN,INVERT_Z_STEP_PIN);
842
     WRITE(Z_STEP_PIN,INVERT_Z_STEP_PIN);
843
     #if defined(Z_DUAL_STEPPER_DRIVERS) && defined(Z2_STEP_PIN) && (Z2_STEP_PIN > -1)
843
     #if defined(Z_DUAL_STEPPER_DRIVERS) && defined(Z2_STEP_PIN) && (Z2_STEP_PIN > -1)
845
       WRITE(Z2_STEP_PIN,INVERT_Z_STEP_PIN);
845
       WRITE(Z2_STEP_PIN,INVERT_Z_STEP_PIN);
846
     #endif
846
     #endif
847
     disable_z();
847
     disable_z();
848
-  #endif  
849
-  #if defined(E0_STEP_PIN) && (E0_STEP_PIN > -1) 
848
+  #endif
849
+  #if defined(E0_STEP_PIN) && (E0_STEP_PIN > -1)
850
     SET_OUTPUT(E0_STEP_PIN);
850
     SET_OUTPUT(E0_STEP_PIN);
851
     WRITE(E0_STEP_PIN,INVERT_E_STEP_PIN);
851
     WRITE(E0_STEP_PIN,INVERT_E_STEP_PIN);
852
     disable_e0();
852
     disable_e0();
853
-  #endif  
854
-  #if defined(E1_STEP_PIN) && (E1_STEP_PIN > -1) 
853
+  #endif
854
+  #if defined(E1_STEP_PIN) && (E1_STEP_PIN > -1)
855
     SET_OUTPUT(E1_STEP_PIN);
855
     SET_OUTPUT(E1_STEP_PIN);
856
     WRITE(E1_STEP_PIN,INVERT_E_STEP_PIN);
856
     WRITE(E1_STEP_PIN,INVERT_E_STEP_PIN);
857
     disable_e1();
857
     disable_e1();
858
-  #endif  
859
-  #if defined(E2_STEP_PIN) && (E2_STEP_PIN > -1) 
858
+  #endif
859
+  #if defined(E2_STEP_PIN) && (E2_STEP_PIN > -1)
860
     SET_OUTPUT(E2_STEP_PIN);
860
     SET_OUTPUT(E2_STEP_PIN);
861
     WRITE(E2_STEP_PIN,INVERT_E_STEP_PIN);
861
     WRITE(E2_STEP_PIN,INVERT_E_STEP_PIN);
862
     disable_e2();
862
     disable_e2();
863
-  #endif  
863
+  #endif
864
 
864
 
865
   // waveform generation = 0100 = CTC
865
   // waveform generation = 0100 = CTC
866
   TCCR1B &= ~(1<<WGM13);
866
   TCCR1B &= ~(1<<WGM13);
867
   TCCR1B |=  (1<<WGM12);
867
   TCCR1B |=  (1<<WGM12);
868
-  TCCR1A &= ~(1<<WGM11); 
868
+  TCCR1A &= ~(1<<WGM11);
869
   TCCR1A &= ~(1<<WGM10);
869
   TCCR1A &= ~(1<<WGM10);
870
 
870
 
871
   // output mode = 00 (disconnected)
871
   // output mode = 00 (disconnected)
872
-  TCCR1A &= ~(3<<COM1A0); 
873
-  TCCR1A &= ~(3<<COM1B0); 
874
-  
872
+  TCCR1A &= ~(3<<COM1A0);
873
+  TCCR1A &= ~(3<<COM1B0);
874
+
875
   // Set the timer pre-scaler
875
   // Set the timer pre-scaler
876
   // Generally we use a divider of 8, resulting in a 2MHz timer
876
   // Generally we use a divider of 8, resulting in a 2MHz timer
877
   // frequency on a 16MHz MCU. If you are going to change this, be
877
   // frequency on a 16MHz MCU. If you are going to change this, be
881
 
881
 
882
   OCR1A = 0x4000;
882
   OCR1A = 0x4000;
883
   TCNT1 = 0;
883
   TCNT1 = 0;
884
-  ENABLE_STEPPER_DRIVER_INTERRUPT();  
884
+  ENABLE_STEPPER_DRIVER_INTERRUPT();
885
 
885
 
886
   #ifdef ADVANCE
886
   #ifdef ADVANCE
887
   #if defined(TCCR0A) && defined(WGM01)
887
   #if defined(TCCR0A) && defined(WGM01)
888
     TCCR0A &= ~(1<<WGM01);
888
     TCCR0A &= ~(1<<WGM01);
889
     TCCR0A &= ~(1<<WGM00);
889
     TCCR0A &= ~(1<<WGM00);
890
-  #endif  
890
+  #endif
891
     e_steps[0] = 0;
891
     e_steps[0] = 0;
892
     e_steps[1] = 0;
892
     e_steps[1] = 0;
893
     e_steps[2] = 0;
893
     e_steps[2] = 0;
894
     TIMSK0 |= (1<<OCIE0A);
894
     TIMSK0 |= (1<<OCIE0A);
895
   #endif //ADVANCE
895
   #endif //ADVANCE
896
-  
896
+
897
   enable_endstops(true); // Start with endstops active. After homing they can be disabled
897
   enable_endstops(true); // Start with endstops active. After homing they can be disabled
898
   sei();
898
   sei();
899
 }
899
 }
937
 
937
 
938
 void finishAndDisableSteppers()
938
 void finishAndDisableSteppers()
939
 {
939
 {
940
-  st_synchronize(); 
941
-  disable_x(); 
942
-  disable_y(); 
943
-  disable_z(); 
944
-  disable_e0(); 
945
-  disable_e1(); 
946
-  disable_e2(); 
940
+  st_synchronize();
941
+  disable_x();
942
+  disable_y();
943
+  disable_z();
944
+  disable_e0();
945
+  disable_e1();
946
+  disable_e2();
947
 }
947
 }
948
 
948
 
949
 void quickStop()
949
 void quickStop()
970
 {
970
 {
971
   #if defined(DIGIPOTSS_PIN) && DIGIPOTSS_PIN > -1
971
   #if defined(DIGIPOTSS_PIN) && DIGIPOTSS_PIN > -1
972
     const uint8_t digipot_motor_current[] = DIGIPOT_MOTOR_CURRENT;
972
     const uint8_t digipot_motor_current[] = DIGIPOT_MOTOR_CURRENT;
973
-    
974
-    SPI.begin(); 
975
-    pinMode(DIGIPOTSS_PIN, OUTPUT);    
976
-    for(int i=0;i<=4;i++) 
973
+
974
+    SPI.begin();
975
+    pinMode(DIGIPOTSS_PIN, OUTPUT);
976
+    for(int i=0;i<=4;i++)
977
       //digitalPotWrite(digipot_ch[i], digipot_motor_current[i]);
977
       //digitalPotWrite(digipot_ch[i], digipot_motor_current[i]);
978
       digipot_current(i,digipot_motor_current[i]);
978
       digipot_current(i,digipot_motor_current[i]);
979
   #endif
979
   #endif

Loading…
Cancel
Save