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,7 +141,7 @@
141 141
 #define TEMP_SENSOR_BED 0
142 142
 
143 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 145
 #define MAX_REDUNDANT_TEMP_SENSOR_DIFF 10
146 146
 
147 147
 // Actual temperature must be close to target for this long before M109 returns success
@@ -278,9 +278,12 @@
278 278
 #endif
279 279
 
280 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 287
 //#define DISABLE_MAX_ENDSTOPS
285 288
 //#define DISABLE_MIN_ENDSTOPS
286 289
 
@@ -379,7 +382,7 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
379 382
 //#define EEPROM_CHITCHAT
380 383
 
381 384
 // Preheat Constants
382
-#define PLA_PREHEAT_HOTEND_TEMP 180 
385
+#define PLA_PREHEAT_HOTEND_TEMP 180
383 386
 #define PLA_PREHEAT_HPB_TEMP 70
384 387
 #define PLA_PREHEAT_FAN_SPEED 255   // Insert Value between 0 and 255
385 388
 
@@ -464,7 +467,7 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
464 467
   #define LCD_I2C_TYPE_PCF8575
465 468
   #define LCD_I2C_ADDRESS 0x27   // I2C Address of the port expander
466 469
   #define NEWPANEL
467
-  #define ULTIPANEL 
470
+  #define ULTIPANEL
468 471
 #endif
469 472
 
470 473
 // PANELOLU2 LCD with status LEDs, separate encoder and click inputs
@@ -473,13 +476,13 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
473 476
   // This uses the LiquidTWI2 library v1.2.3 or later ( https://github.com/lincomatic/LiquidTWI2 )
474 477
   // Make sure the LiquidTWI2 directory is placed in the Arduino or Sketchbook libraries subdirectory.
475 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 481
   #define LCD_I2C_TYPE_MCP23017
479 482
   #define LCD_I2C_ADDRESS 0x20 // I2C Address of the port expander
480 483
   #define LCD_USE_I2C_BUZZER //comment out to disable buzzer on LCD
481 484
   #define NEWPANEL
482
-  #define ULTIPANEL 
485
+  #define ULTIPANEL
483 486
 #endif
484 487
 
485 488
 // Panucatt VIKI LCD with status LEDs, integrated click & L/R/U/P buttons, separate encoder inputs
@@ -489,11 +492,11 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
489 492
   // Make sure the LiquidTWI2 directory is placed in the Arduino or Sketchbook libraries subdirectory.
490 493
   // Note: The pause/stop/resume LCD button pin should be connected to the Arduino
491 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 496
   #define LCD_I2C_ADDRESS 0x20 // I2C Address of the port expander
494 497
   #define LCD_USE_I2C_BUZZER //comment out to disable buzzer on LCD (requires LiquidTWI2 v1.2.3 or later)
495 498
   #define NEWPANEL
496
-  #define ULTIPANEL 
499
+  #define ULTIPANEL
497 500
 #endif
498 501
 
499 502
 #ifdef ULTIPANEL
@@ -565,10 +568,10 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
565 568
 //#define NUM_SERVOS 3 // Servo index starts with 0 for M280 command
566 569
 
567 570
 // Servo Endstops
568
-// 
571
+//
569 572
 // This allows for servo actuated endstops, primary usage is for the Z Axis to eliminate calibration or bed height changes.
570 573
 // Use M206 command to correct for switch height offset to actual nozzle height. Store that setting with M500.
571
-// 
574
+//
572 575
 //#define SERVO_ENDSTOPS {-1, -1, 0} // Servo index for X, Y, Z. Disable with -1
573 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,10 +431,10 @@ void setup()
431 431
 
432 432
   lcd_init();
433 433
   _delay_ms(1000);	// wait 1sec to display the splash screen
434
-  
434
+
435 435
   #if defined(CONTROLLERFAN_PIN) && CONTROLLERFAN_PIN > -1
436 436
     SET_OUTPUT(CONTROLLERFAN_PIN); //Set pin used for driver cooling fan
437
-  #endif 
437
+  #endif
438 438
 }
439 439
 
440 440
 
@@ -691,15 +691,15 @@ XYZ_CONSTS_FROM_CONFIG(signed char, home_dir,  HOME_DIR);
691 691
   #endif
692 692
   #if X_HOME_DIR != -1 || X2_HOME_DIR != 1
693 693
     #error "Please use canonical x-carriage assignment" // the x-carriages are defined by their homing directions
694
-  #endif  
695
-    
694
+  #endif
695
+
696 696
 static float x_home_pos(int extruder) {
697 697
   if (extruder == 0)
698 698
     return base_home_pos(X_AXIS) + add_homeing[X_AXIS];
699 699
   else
700 700
     // In dual carriage mode the extruder offset provides an override of the
701 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 703
     // (through the M218 command).
704 704
     return (extruder_offset[X_AXIS][1] > 0) ? extruder_offset[X_AXIS][1] : X2_HOME_POS;
705 705
 }
@@ -709,7 +709,7 @@ static int x_home_dir(int extruder) {
709 709
 }
710 710
 
711 711
 static float inactive_x_carriage_pos = X2_MAX_POS;
712
-#endif     
712
+#endif
713 713
 
714 714
 static void axis_is_at_home(int axis) {
715 715
 #ifdef DUAL_X_CARRIAGE
@@ -719,7 +719,7 @@ static void axis_is_at_home(int axis) {
719 719
     max_pos[X_AXIS] =          max(extruder_offset[X_AXIS][1], X2_MAX_POS);
720 720
     return;
721 721
   }
722
-#endif  
722
+#endif
723 723
   current_position[axis] = base_home_pos(axis) + add_homeing[axis];
724 724
   min_pos[axis] =          base_min_pos(axis) + add_homeing[axis];
725 725
   max_pos[axis] =          base_max_pos(axis) + add_homeing[axis];
@@ -745,7 +745,7 @@ static void homeaxis(int axis) {
745 745
         servos[servo_endstops[axis]].write(servo_endstop_angles[axis * 2]);
746 746
       }
747 747
     #endif
748
-      
748
+
749 749
     current_position[axis] = 0;
750 750
     plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
751 751
     destination[axis] = 1.5 * max_length(axis) * axis_home_dir;
@@ -879,7 +879,7 @@ void process_commands()
879 879
           current_position[X_AXIS] = 0;
880 880
           current_position[Y_AXIS] = 0;
881 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 884
           destination[X_AXIS] = 3 * Z_MAX_LENGTH;
885 885
           destination[Y_AXIS] = 3 * Z_MAX_LENGTH;
@@ -892,7 +892,7 @@ void process_commands()
892 892
           current_position[X_AXIS] = destination[X_AXIS];
893 893
           current_position[Y_AXIS] = destination[Y_AXIS];
894 894
           current_position[Z_AXIS] = destination[Z_AXIS];
895
-          
895
+
896 896
           // take care of back off and rehome now we are all at the top
897 897
           HOMEAXIS(X);
898 898
           HOMEAXIS(Y);
@@ -921,7 +921,7 @@ void process_commands()
921 921
        #else
922 922
         int x_axis_home_dir = x_home_dir(active_extruder);
923 923
        #endif
924
-        
924
+
925 925
         plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
926 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 927
         feedrate = homing_feedrate[X_AXIS];
@@ -954,7 +954,7 @@ void process_commands()
954 954
         HOMEAXIS(X);
955 955
         inactive_x_carriage_pos = current_position[X_AXIS];
956 956
         active_extruder = tmp_extruder;
957
-      #endif         
957
+      #endif
958 958
         HOMEAXIS(X);
959 959
       }
960 960
 
@@ -988,7 +988,7 @@ void process_commands()
988 988
       }
989 989
       plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
990 990
 #endif // else DELTA
991
-          
991
+
992 992
       #ifdef ENDSTOPS_ONLY_FOR_HOMING
993 993
         enable_endstops(false);
994 994
       #endif
@@ -1223,9 +1223,9 @@ void process_commands()
1223 1223
           SERIAL_PROTOCOLPGM(" T");
1224 1224
           SERIAL_PROTOCOL(cur_extruder);
1225 1225
           SERIAL_PROTOCOLPGM(":");
1226
-          SERIAL_PROTOCOL_F(degHotend(cur_extruder),1); 
1226
+          SERIAL_PROTOCOL_F(degHotend(cur_extruder),1);
1227 1227
           SERIAL_PROTOCOLPGM(" /");
1228
-          SERIAL_PROTOCOL_F(degTargetHotend(cur_extruder),1); 
1228
+          SERIAL_PROTOCOL_F(degTargetHotend(cur_extruder),1);
1229 1229
         }
1230 1230
       #else
1231 1231
         SERIAL_ERROR_START;
@@ -1250,7 +1250,7 @@ void process_commands()
1250 1250
       #ifdef AUTOTEMP
1251 1251
         autotemp_enabled=false;
1252 1252
       #endif
1253
-      if (code_seen('S')) { 
1253
+      if (code_seen('S')) {
1254 1254
         setTargetHotend(code_value(), tmp_extruder);
1255 1255
         CooldownNoWait = true;
1256 1256
       } else if (code_seen('R')) {
@@ -1327,7 +1327,7 @@ void process_commands()
1327 1327
     case 190: // M190 - Wait for bed heater to reach target.
1328 1328
     #if defined(TEMP_BED_PIN) && TEMP_BED_PIN > -1
1329 1329
         LCD_MESSAGEPGM(MSG_BED_HEATING);
1330
-        if (code_seen('S')) { 
1330
+        if (code_seen('S')) {
1331 1331
           setTargetBed(code_value());
1332 1332
           CooldownNoWait = true;
1333 1333
         } else if (code_seen('R')) {
@@ -1335,9 +1335,9 @@ void process_commands()
1335 1335
           CooldownNoWait = false;
1336 1336
         }
1337 1337
         codenum = millis();
1338
-        
1338
+
1339 1339
         target_direction = isHeatingBed(); // true if heating, false if cooling
1340
-        
1340
+
1341 1341
         while ( target_direction ? (isHeatingBed()) : (isCoolingBed()&&(CooldownNoWait==false)) )
1342 1342
         {
1343 1343
           if(( millis() - codenum) > 1000 ) //Print Temp Reading every 1 second while heating up.
@@ -1417,7 +1417,7 @@ void process_commands()
1417 1417
         #endif
1418 1418
         break;
1419 1419
       #endif
1420
-      
1420
+
1421 1421
       case 81: // M81 - Turn off Power Supply
1422 1422
         disable_heater();
1423 1423
         st_synchronize();
@@ -1542,27 +1542,27 @@ void process_commands()
1542 1542
     SERIAL_PROTOCOLLN(MSG_M119_REPORT);
1543 1543
       #if defined(X_MIN_PIN) && X_MIN_PIN > -1
1544 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 1546
       #endif
1547 1547
       #if defined(X_MAX_PIN) && X_MAX_PIN > -1
1548 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 1550
       #endif
1551 1551
       #if defined(Y_MIN_PIN) && Y_MIN_PIN > -1
1552 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 1554
       #endif
1555 1555
       #if defined(Y_MAX_PIN) && Y_MAX_PIN > -1
1556 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 1558
       #endif
1559 1559
       #if defined(Z_MIN_PIN) && Z_MIN_PIN > -1
1560 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 1562
       #endif
1563 1563
       #if defined(Z_MAX_PIN) && Z_MAX_PIN > -1
1564 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 1566
       #endif
1567 1567
       break;
1568 1568
       //TODO: update for all axis, use for loop
@@ -1699,7 +1699,7 @@ void process_commands()
1699 1699
       }
1700 1700
     }
1701 1701
     break;
1702
-    
1702
+
1703 1703
     #if NUM_SERVOS > 0
1704 1704
     case 280: // M280 - set servo position absolute. P: servo index, S: angle or microseconds
1705 1705
       {
@@ -1987,7 +1987,7 @@ void process_commands()
1987 1987
             delay(3);
1988 1988
             WRITE(BEEPER,LOW);
1989 1989
             delay(3);
1990
-          #else 
1990
+          #else
1991 1991
             lcd_buzz(1000/6,100);
1992 1992
           #endif
1993 1993
           }
@@ -2103,8 +2103,8 @@ void process_commands()
2103 2103
         active_extruder = tmp_extruder;
2104 2104
         axis_is_at_home(X_AXIS); //this function updates X min/max values.
2105 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 2108
         // Offset extruder (only by XY)
2109 2109
         int i;
2110 2110
         for(i = 0; i < 2; i++) {
@@ -2340,10 +2340,10 @@ void prepare_arc_move(char isclockwise) {
2340 2340
 #if defined(CONTROLLERFAN_PIN) && CONTROLLERFAN_PIN > -1
2341 2341
 
2342 2342
 #if defined(FAN_PIN)
2343
-  #if CONTROLLERFAN_PIN == FAN_PIN 
2343
+  #if CONTROLLERFAN_PIN == FAN_PIN
2344 2344
     #error "You cannot set CONTROLLERFAN_PIN equal to FAN_PIN"
2345 2345
   #endif
2346
-#endif  
2346
+#endif
2347 2347
 
2348 2348
 unsigned long lastMotor = 0; //Save the time for when a motor was turned on last
2349 2349
 unsigned long lastMotorCheck = 0;
@@ -2368,17 +2368,17 @@ void controllerFan()
2368 2368
     {
2369 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 2377
     else
2378 2378
     {
2379 2379
         // allows digital or PWM fan output to be used (see M42 handling)
2380 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,7 +2445,7 @@ void kill()
2445 2445
 
2446 2446
 #if defined(PS_ON_PIN) && PS_ON_PIN > -1
2447 2447
   pinMode(PS_ON_PIN,INPUT);
2448
-#endif  
2448
+#endif
2449 2449
   SERIAL_ERROR_START;
2450 2450
   SERIAL_ERRORLNPGM(MSG_ERR_KILLED);
2451 2451
   LCD_ALERTMESSAGEPGM(MSG_KILLED);

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

@@ -141,7 +141,7 @@
141 141
 #define TEMP_SENSOR_BED 0
142 142
 
143 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 145
 #define MAX_REDUNDANT_TEMP_SENSOR_DIFF 10
146 146
 
147 147
 // Actual temperature must be close to target for this long before M109 returns success
@@ -278,9 +278,12 @@
278 278
 #endif
279 279
 
280 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 288
 // deltas never have min endstops
286 289
 #define DISABLE_MIN_ENDSTOPS
@@ -386,7 +389,7 @@ const bool Z_ENDSTOPS_INVERTING = false; // set to true to invert the logic of t
386 389
 //#define EEPROM_CHITCHAT
387 390
 
388 391
 // Preheat Constants
389
-#define PLA_PREHEAT_HOTEND_TEMP 180 
392
+#define PLA_PREHEAT_HOTEND_TEMP 180
390 393
 #define PLA_PREHEAT_HPB_TEMP 70
391 394
 #define PLA_PREHEAT_FAN_SPEED 255   // Insert Value between 0 and 255
392 395
 
@@ -471,7 +474,7 @@ const bool Z_ENDSTOPS_INVERTING = false; // set to true to invert the logic of t
471 474
   #define LCD_I2C_TYPE_PCF8575
472 475
   #define LCD_I2C_ADDRESS 0x27   // I2C Address of the port expander
473 476
   #define NEWPANEL
474
-  #define ULTIPANEL 
477
+  #define ULTIPANEL
475 478
 #endif
476 479
 
477 480
 // PANELOLU2 LCD with status LEDs, separate encoder and click inputs
@@ -480,13 +483,13 @@ const bool Z_ENDSTOPS_INVERTING = false; // set to true to invert the logic of t
480 483
   // This uses the LiquidTWI2 library v1.2.3 or later ( https://github.com/lincomatic/LiquidTWI2 )
481 484
   // Make sure the LiquidTWI2 directory is placed in the Arduino or Sketchbook libraries subdirectory.
482 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 488
   #define LCD_I2C_TYPE_MCP23017
486 489
   #define LCD_I2C_ADDRESS 0x20 // I2C Address of the port expander
487 490
   #define LCD_USE_I2C_BUZZER //comment out to disable buzzer on LCD
488 491
   #define NEWPANEL
489
-  #define ULTIPANEL 
492
+  #define ULTIPANEL
490 493
 #endif
491 494
 
492 495
 // Panucatt VIKI LCD with status LEDs, integrated click & L/R/U/P buttons, separate encoder inputs
@@ -496,11 +499,11 @@ const bool Z_ENDSTOPS_INVERTING = false; // set to true to invert the logic of t
496 499
   // Make sure the LiquidTWI2 directory is placed in the Arduino or Sketchbook libraries subdirectory.
497 500
   // Note: The pause/stop/resume LCD button pin should be connected to the Arduino
498 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 503
   #define LCD_I2C_ADDRESS 0x20 // I2C Address of the port expander
501 504
   #define LCD_USE_I2C_BUZZER //comment out to disable buzzer on LCD (requires LiquidTWI2 v1.2.3 or later)
502 505
   #define NEWPANEL
503
-  #define ULTIPANEL 
506
+  #define ULTIPANEL
504 507
 #endif
505 508
 
506 509
 #ifdef ULTIPANEL
@@ -572,10 +575,10 @@ const bool Z_ENDSTOPS_INVERTING = false; // set to true to invert the logic of t
572 575
 //#define NUM_SERVOS 3 // Servo index starts with 0 for M280 command
573 576
 
574 577
 // Servo Endstops
575
-// 
578
+//
576 579
 // This allows for servo actuated endstops, primary usage is for the Z Axis to eliminate calibration or bed height changes.
577 580
 // Use M206 command to correct for switch height offset to actual nozzle height. Store that setting with M500.
578
-// 
581
+//
579 582
 //#define SERVO_ENDSTOPS {-1, -1, 0} // Servo index for X, Y, Z. Disable with -1
580 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,8 +48,8 @@ block_t *current_block;  // A pointer to the block currently being traced
48 48
 // Variables used by The Stepper Driver Interrupt
49 49
 static unsigned char out_bits;        // The next stepping-bits to be output
50 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 53
             counter_e;
54 54
 volatile static unsigned long step_events_completed; // The number of step events executed in the current block
55 55
 #ifdef ADVANCE
@@ -224,27 +224,27 @@ void enable_endstops(bool check)
224 224
 //   |               BLOCK 1            |      BLOCK 2          |    d
225 225
 //
226 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 230
 //  step_events_completed reaches block->decelerate_after after which it decelerates until the trapezoid generator is reset.
231 231
 //  The slope of acceleration is calculated with the leib ramp alghorithm.
232 232
 
233 233
 void st_wake_up() {
234 234
   //  TCNT1 = 0;
235
-  ENABLE_STEPPER_DRIVER_INTERRUPT();  
235
+  ENABLE_STEPPER_DRIVER_INTERRUPT();
236 236
 }
237 237
 
238 238
 void step_wait(){
239 239
     for(int8_t i=0; i < 6; i++){
240 240
     }
241 241
 }
242
-  
242
+
243 243
 
244 244
 FORCE_INLINE unsigned short calc_timer(unsigned short step_rate) {
245 245
   unsigned short timer;
246 246
   if(step_rate > MAX_STEP_FREQUENCY) step_rate = MAX_STEP_FREQUENCY;
247
-  
247
+
248 248
   if(step_rate > 20000) { // If steprate > 20kHz >> step 4 times
249 249
     step_rate = (step_rate >> 2)&0x3fff;
250 250
     step_loops = 4;
@@ -255,11 +255,11 @@ FORCE_INLINE unsigned short calc_timer(unsigned short step_rate) {
255 255
   }
256 256
   else {
257 257
     step_loops = 1;
258
-  } 
259
-  
258
+  }
259
+
260 260
   if(step_rate < (F_CPU/500000)) step_rate = (F_CPU/500000);
261 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 263
     unsigned short table_address = (unsigned short)&speed_lookuptable_fast[(unsigned char)(step_rate>>8)][0];
264 264
     unsigned char tmp_step_rate = (step_rate & 0x00ff);
265 265
     unsigned short gain = (unsigned short)pgm_read_word_near(table_address+2);
@@ -276,7 +276,7 @@ FORCE_INLINE unsigned short calc_timer(unsigned short step_rate) {
276 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 280
 // block begins.
281 281
 FORCE_INLINE void trapezoid_generator_reset() {
282 282
   #ifdef ADVANCE
@@ -284,7 +284,7 @@ FORCE_INLINE void trapezoid_generator_reset() {
284 284
     final_advance = current_block->final_advance;
285 285
     // Do E steps + advance steps
286 286
     e_steps[current_block->active_extruder] += ((advance >>8) - old_advance);
287
-    old_advance = advance >>8;  
287
+    old_advance = advance >>8;
288 288
   #endif
289 289
   deceleration_time = 0;
290 290
   // step_rate to timer interval
@@ -294,7 +294,7 @@ FORCE_INLINE void trapezoid_generator_reset() {
294 294
   acc_step_rate = current_block->initial_rate;
295 295
   acceleration_time = calc_timer(acc_step_rate);
296 296
   OCR1A = acceleration_time;
297
-  
297
+
298 298
 //    SERIAL_ECHO_START;
299 299
 //    SERIAL_ECHOPGM("advance :");
300 300
 //    SERIAL_ECHO(current_block->advance/256.0);
@@ -304,13 +304,13 @@ FORCE_INLINE void trapezoid_generator_reset() {
304 304
 //  SERIAL_ECHO(current_block->initial_advance/256.0);
305 305
 //    SERIAL_ECHOPGM("final advance :");
306 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 312
 ISR(TIMER1_COMPA_vect)
313
-{    
313
+{
314 314
   // If there is no current block, attempt to pop one from the buffer
315 315
   if (current_block == NULL) {
316 316
     // Anything in the buffer?
@@ -322,24 +322,24 @@ ISR(TIMER1_COMPA_vect)
322 322
       counter_y = counter_x;
323 323
       counter_z = counter_x;
324 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 328
         if(current_block->steps_z > 0) {
329 329
           enable_z();
330 330
           OCR1A = 2000; //1ms wait
331 331
           return;
332 332
         }
333 333
       #endif
334
-      
334
+
335 335
 //      #ifdef ADVANCE
336 336
 //      e_steps[current_block->active_extruder] = 0;
337 337
 //      #endif
338
-    } 
338
+    }
339 339
     else {
340 340
         OCR1A=2000; // 1kHz.
341
-    }    
342
-  } 
341
+    }
342
+  }
343 343
 
344 344
   if (current_block != NULL) {
345 345
     // Set directions TO DO This should be done once during init of trapezoid. Endstops -> interrupt
@@ -352,7 +352,7 @@ ISR(TIMER1_COMPA_vect)
352 352
       if (active_extruder != 0)
353 353
         WRITE(X2_DIR_PIN,INVERT_X_DIR);
354 354
       else
355
-      #endif        
355
+      #endif
356 356
         WRITE(X_DIR_PIN, INVERT_X_DIR);
357 357
       count_direction[X_AXIS]=-1;
358 358
     }
@@ -361,7 +361,7 @@ ISR(TIMER1_COMPA_vect)
361 361
       if (active_extruder != 0)
362 362
         WRITE(X2_DIR_PIN,!INVERT_X_DIR);
363 363
       else
364
-      #endif        
364
+      #endif
365 365
         WRITE(X_DIR_PIN, !INVERT_X_DIR);
366 366
       count_direction[X_AXIS]=1;
367 367
     }
@@ -373,7 +373,7 @@ ISR(TIMER1_COMPA_vect)
373 373
       WRITE(Y_DIR_PIN, !INVERT_Y_DIR);
374 374
       count_direction[Y_AXIS]=1;
375 375
     }
376
-    
376
+
377 377
     // Set direction en check limit switches
378 378
     #ifndef COREXY
379 379
     if ((out_bits & (1<<X_AXIS)) != 0) {   // stepping along -X axis
@@ -385,10 +385,10 @@ ISR(TIMER1_COMPA_vect)
385 385
         #ifdef DUAL_X_CARRIAGE
386 386
         // with 2 x-carriages, endstops are only checked in the homing direction for the active extruder
387 387
         if ((active_extruder == 0 && X_HOME_DIR == -1) || (active_extruder != 0 && X2_HOME_DIR == -1))
388
-        #endif          
388
+        #endif
389 389
         {
390 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 392
             if(x_min_endstop && old_x_min_endstop && (current_block->steps_x > 0)) {
393 393
               endstops_trigsteps[X_AXIS] = count_position[X_AXIS];
394 394
               endstop_x_hit=true;
@@ -400,15 +400,15 @@ ISR(TIMER1_COMPA_vect)
400 400
       }
401 401
     }
402 402
     else { // +direction
403
-      CHECK_ENDSTOPS 
403
+      CHECK_ENDSTOPS
404 404
       {
405 405
         #ifdef DUAL_X_CARRIAGE
406 406
         // with 2 x-carriages, endstops are only checked in the homing direction for the active extruder
407 407
         if ((active_extruder == 0 && X_HOME_DIR == 1) || (active_extruder != 0 && X2_HOME_DIR == 1))
408
-        #endif          
408
+        #endif
409 409
         {
410 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 412
             if(x_max_endstop && old_x_max_endstop && (current_block->steps_x > 0)){
413 413
               endstops_trigsteps[X_AXIS] = count_position[X_AXIS];
414 414
               endstop_x_hit=true;
@@ -416,7 +416,7 @@ ISR(TIMER1_COMPA_vect)
416 416
             }
417 417
             old_x_max_endstop = x_max_endstop;
418 418
           #endif
419
-        }  
419
+        }
420 420
       }
421 421
     }
422 422
 
@@ -428,7 +428,7 @@ ISR(TIMER1_COMPA_vect)
428 428
       CHECK_ENDSTOPS
429 429
       {
430 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 432
           if(y_min_endstop && old_y_min_endstop && (current_block->steps_y > 0)) {
433 433
             endstops_trigsteps[Y_AXIS] = count_position[Y_AXIS];
434 434
             endstop_y_hit=true;
@@ -442,7 +442,7 @@ ISR(TIMER1_COMPA_vect)
442 442
       CHECK_ENDSTOPS
443 443
       {
444 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 446
           if(y_max_endstop && old_y_max_endstop && (current_block->steps_y > 0)){
447 447
             endstops_trigsteps[Y_AXIS] = count_position[Y_AXIS];
448 448
             endstop_y_hit=true;
@@ -455,16 +455,16 @@ ISR(TIMER1_COMPA_vect)
455 455
 
456 456
     if ((out_bits & (1<<Z_AXIS)) != 0) {   // -direction
457 457
       WRITE(Z_DIR_PIN,INVERT_Z_DIR);
458
-      
458
+
459 459
 	  #ifdef Z_DUAL_STEPPER_DRIVERS
460 460
         WRITE(Z2_DIR_PIN,INVERT_Z_DIR);
461 461
       #endif
462
-      
462
+
463 463
       count_direction[Z_AXIS]=-1;
464 464
       CHECK_ENDSTOPS
465 465
       {
466 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 468
           if(z_min_endstop && old_z_min_endstop && (current_block->steps_z > 0)) {
469 469
             endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS];
470 470
             endstop_z_hit=true;
@@ -485,7 +485,7 @@ ISR(TIMER1_COMPA_vect)
485 485
       CHECK_ENDSTOPS
486 486
       {
487 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 489
           if(z_max_endstop && old_z_max_endstop && (current_block->steps_z > 0)) {
490 490
             endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS];
491 491
             endstop_z_hit=true;
@@ -506,10 +506,10 @@ ISR(TIMER1_COMPA_vect)
506 506
         count_direction[E_AXIS]=1;
507 507
       }
508 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 513
       #ifndef AT90USB
514 514
       MSerial.checkRx(); // Check for serial chars.
515 515
       #endif
@@ -524,7 +524,7 @@ ISR(TIMER1_COMPA_vect)
524 524
         else {
525 525
           e_steps[current_block->active_extruder]++;
526 526
         }
527
-      }    
527
+      }
528 528
       #endif //ADVANCE
529 529
 
530 530
         counter_x += current_block->steps_x;
@@ -533,38 +533,38 @@ ISR(TIMER1_COMPA_vect)
533 533
           if (active_extruder != 0)
534 534
             WRITE(X2_STEP_PIN,!INVERT_X_STEP_PIN);
535 535
           else
536
-          #endif        
536
+          #endif
537 537
             WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN);
538 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 540
           #ifdef DUAL_X_CARRIAGE
541 541
           if (active_extruder != 0)
542 542
             WRITE(X2_STEP_PIN,INVERT_X_STEP_PIN);
543 543
           else
544
-          #endif        
544
+          #endif
545 545
             WRITE(X_STEP_PIN, INVERT_X_STEP_PIN);
546 546
         }
547
-  
547
+
548 548
         counter_y += current_block->steps_y;
549 549
         if (counter_y > 0) {
550 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 553
           WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN);
554 554
         }
555
-  
555
+
556 556
       counter_z += current_block->steps_z;
557 557
       if (counter_z > 0) {
558 558
         WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN);
559
-        
559
+
560 560
 		#ifdef Z_DUAL_STEPPER_DRIVERS
561 561
           WRITE(Z2_STEP_PIN, !INVERT_Z_STEP_PIN);
562 562
         #endif
563
-        
563
+
564 564
         counter_z -= current_block->step_event_count;
565 565
         count_position[Z_AXIS]+=count_direction[Z_AXIS];
566 566
         WRITE(Z_STEP_PIN, INVERT_Z_STEP_PIN);
567
-        
567
+
568 568
 		#ifdef Z_DUAL_STEPPER_DRIVERS
569 569
           WRITE(Z2_STEP_PIN, INVERT_Z_STEP_PIN);
570 570
         #endif
@@ -579,17 +579,17 @@ ISR(TIMER1_COMPA_vect)
579 579
           WRITE_E_STEP(INVERT_E_STEP_PIN);
580 580
         }
581 581
       #endif //!ADVANCE
582
-      step_events_completed += 1;  
582
+      step_events_completed += 1;
583 583
       if(step_events_completed >= current_block->step_event_count) break;
584 584
     }
585 585
     // Calculare new timer value
586 586
     unsigned short timer;
587 587
     unsigned short step_rate;
588 588
     if (step_events_completed <= (unsigned long int)current_block->accelerate_until) {
589
-      
589
+
590 590
       MultiU24X24toH16(acc_step_rate, acceleration_time, current_block->acceleration_rate);
591 591
       acc_step_rate += current_block->initial_rate;
592
-      
592
+
593 593
       // upper limit
594 594
       if(acc_step_rate > current_block->nominal_rate)
595 595
         acc_step_rate = current_block->nominal_rate;
@@ -605,13 +605,13 @@ ISR(TIMER1_COMPA_vect)
605 605
         //if(advance > current_block->advance) advance = current_block->advance;
606 606
         // Do E steps + advance steps
607 607
         e_steps[current_block->active_extruder] += ((advance >>8) - old_advance);
608
-        old_advance = advance >>8;  
609
-        
608
+        old_advance = advance >>8;
609
+
610 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 613
       MultiU24X24toH16(step_rate, deceleration_time, current_block->acceleration_rate);
614
-      
614
+
615 615
       if(step_rate > acc_step_rate) { // Check step_rate stays positive
616 616
         step_rate = current_block->final_rate;
617 617
       }
@@ -634,7 +634,7 @@ ISR(TIMER1_COMPA_vect)
634 634
         if(advance < final_advance) advance = final_advance;
635 635
         // Do E steps + advance steps
636 636
         e_steps[current_block->active_extruder] += ((advance >>8) - old_advance);
637
-        old_advance = advance >>8;  
637
+        old_advance = advance >>8;
638 638
       #endif //ADVANCE
639 639
     }
640 640
     else {
@@ -643,12 +643,12 @@ ISR(TIMER1_COMPA_vect)
643 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 647
     if (step_events_completed >= current_block->step_event_count) {
648 648
       current_block = NULL;
649 649
       plan_discard_current_block();
650
-    }   
651
-  } 
650
+    }
651
+  }
652 652
 }
653 653
 
654 654
 #ifdef ADVANCE
@@ -667,7 +667,7 @@ ISR(TIMER1_COMPA_vect)
667 667
           WRITE(E0_DIR_PIN, INVERT_E0_DIR);
668 668
           e_steps[0]++;
669 669
           WRITE(E0_STEP_PIN, !INVERT_E_STEP_PIN);
670
-        } 
670
+        }
671 671
         else if (e_steps[0] > 0) {
672 672
           WRITE(E0_DIR_PIN, !INVERT_E0_DIR);
673 673
           e_steps[0]--;
@@ -681,7 +681,7 @@ ISR(TIMER1_COMPA_vect)
681 681
           WRITE(E1_DIR_PIN, INVERT_E1_DIR);
682 682
           e_steps[1]++;
683 683
           WRITE(E1_STEP_PIN, !INVERT_E_STEP_PIN);
684
-        } 
684
+        }
685 685
         else if (e_steps[1] > 0) {
686 686
           WRITE(E1_DIR_PIN, !INVERT_E1_DIR);
687 687
           e_steps[1]--;
@@ -696,7 +696,7 @@ ISR(TIMER1_COMPA_vect)
696 696
           WRITE(E2_DIR_PIN, INVERT_E2_DIR);
697 697
           e_steps[2]++;
698 698
           WRITE(E2_STEP_PIN, !INVERT_E_STEP_PIN);
699
-        } 
699
+        }
700 700
         else if (e_steps[2] > 0) {
701 701
           WRITE(E2_DIR_PIN, !INVERT_E2_DIR);
702 702
           e_steps[2]--;
@@ -712,7 +712,7 @@ void st_init()
712 712
 {
713 713
   digipot_init(); //Initialize Digipot Motor Current
714 714
   microstep_init(); //Initialize Microstepping Pins
715
-  
715
+
716 716
   //Initialize Dir Pins
717 717
   #if defined(X_DIR_PIN) && X_DIR_PIN > -1
718 718
     SET_OUTPUT(X_DIR_PIN);
@@ -720,17 +720,17 @@ void st_init()
720 720
   #if defined(X2_DIR_PIN) && X2_DIR_PIN > -1
721 721
     SET_OUTPUT(X2_DIR_PIN);
722 722
   #endif
723
-  #if defined(Y_DIR_PIN) && Y_DIR_PIN > -1 
723
+  #if defined(Y_DIR_PIN) && Y_DIR_PIN > -1
724 724
     SET_OUTPUT(Y_DIR_PIN);
725 725
   #endif
726
-  #if defined(Z_DIR_PIN) && Z_DIR_PIN > -1 
726
+  #if defined(Z_DIR_PIN) && Z_DIR_PIN > -1
727 727
     SET_OUTPUT(Z_DIR_PIN);
728 728
 
729 729
     #if defined(Z_DUAL_STEPPER_DRIVERS) && defined(Z2_DIR_PIN) && (Z2_DIR_PIN > -1)
730 730
       SET_OUTPUT(Z2_DIR_PIN);
731 731
     #endif
732 732
   #endif
733
-  #if defined(E0_DIR_PIN) && E0_DIR_PIN > -1 
733
+  #if defined(E0_DIR_PIN) && E0_DIR_PIN > -1
734 734
     SET_OUTPUT(E0_DIR_PIN);
735 735
   #endif
736 736
   #if defined(E1_DIR_PIN) && (E1_DIR_PIN > -1)
@@ -757,7 +757,7 @@ void st_init()
757 757
   #if defined(Z_ENABLE_PIN) && Z_ENABLE_PIN > -1
758 758
     SET_OUTPUT(Z_ENABLE_PIN);
759 759
     if(!Z_ENABLE_ON) WRITE(Z_ENABLE_PIN,HIGH);
760
-    
760
+
761 761
     #if defined(Z_DUAL_STEPPER_DRIVERS) && defined(Z2_ENABLE_PIN) && (Z2_ENABLE_PIN > -1)
762 762
       SET_OUTPUT(Z2_ENABLE_PIN);
763 763
       if(!Z_ENABLE_ON) WRITE(Z2_ENABLE_PIN,HIGH);
@@ -777,67 +777,67 @@ void st_init()
777 777
   #endif
778 778
 
779 779
   //endstops and pullups
780
-  
780
+
781 781
   #if defined(X_MIN_PIN) && X_MIN_PIN > -1
782
-    SET_INPUT(X_MIN_PIN); 
782
+    SET_INPUT(X_MIN_PIN);
783 783
     #ifdef ENDSTOPPULLUP_XMIN
784 784
       WRITE(X_MIN_PIN,HIGH);
785 785
     #endif
786 786
   #endif
787
-      
787
+
788 788
   #if defined(Y_MIN_PIN) && Y_MIN_PIN > -1
789
-    SET_INPUT(Y_MIN_PIN); 
789
+    SET_INPUT(Y_MIN_PIN);
790 790
     #ifdef ENDSTOPPULLUP_YMIN
791 791
       WRITE(Y_MIN_PIN,HIGH);
792 792
     #endif
793 793
   #endif
794
-  
794
+
795 795
   #if defined(Z_MIN_PIN) && Z_MIN_PIN > -1
796
-    SET_INPUT(Z_MIN_PIN); 
796
+    SET_INPUT(Z_MIN_PIN);
797 797
     #ifdef ENDSTOPPULLUP_ZMIN
798 798
       WRITE(Z_MIN_PIN,HIGH);
799 799
     #endif
800 800
   #endif
801
-      
801
+
802 802
   #if defined(X_MAX_PIN) && X_MAX_PIN > -1
803
-    SET_INPUT(X_MAX_PIN); 
803
+    SET_INPUT(X_MAX_PIN);
804 804
     #ifdef ENDSTOPPULLUP_XMAX
805 805
       WRITE(X_MAX_PIN,HIGH);
806 806
     #endif
807 807
   #endif
808
-      
808
+
809 809
   #if defined(Y_MAX_PIN) && Y_MAX_PIN > -1
810
-    SET_INPUT(Y_MAX_PIN); 
810
+    SET_INPUT(Y_MAX_PIN);
811 811
     #ifdef ENDSTOPPULLUP_YMAX
812 812
       WRITE(Y_MAX_PIN,HIGH);
813 813
     #endif
814 814
   #endif
815
-  
815
+
816 816
   #if defined(Z_MAX_PIN) && Z_MAX_PIN > -1
817
-    SET_INPUT(Z_MAX_PIN); 
817
+    SET_INPUT(Z_MAX_PIN);
818 818
     #ifdef ENDSTOPPULLUP_ZMAX
819 819
       WRITE(Z_MAX_PIN,HIGH);
820 820
     #endif
821 821
   #endif
822
- 
822
+
823 823
 
824 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 826
     SET_OUTPUT(X_STEP_PIN);
827 827
     WRITE(X_STEP_PIN,INVERT_X_STEP_PIN);
828 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 831
     SET_OUTPUT(X2_STEP_PIN);
832 832
     WRITE(X2_STEP_PIN,INVERT_X_STEP_PIN);
833 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 836
     SET_OUTPUT(Y_STEP_PIN);
837 837
     WRITE(Y_STEP_PIN,INVERT_Y_STEP_PIN);
838 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 841
     SET_OUTPUT(Z_STEP_PIN);
842 842
     WRITE(Z_STEP_PIN,INVERT_Z_STEP_PIN);
843 843
     #if defined(Z_DUAL_STEPPER_DRIVERS) && defined(Z2_STEP_PIN) && (Z2_STEP_PIN > -1)
@@ -845,33 +845,33 @@ void st_init()
845 845
       WRITE(Z2_STEP_PIN,INVERT_Z_STEP_PIN);
846 846
     #endif
847 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 850
     SET_OUTPUT(E0_STEP_PIN);
851 851
     WRITE(E0_STEP_PIN,INVERT_E_STEP_PIN);
852 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 855
     SET_OUTPUT(E1_STEP_PIN);
856 856
     WRITE(E1_STEP_PIN,INVERT_E_STEP_PIN);
857 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 860
     SET_OUTPUT(E2_STEP_PIN);
861 861
     WRITE(E2_STEP_PIN,INVERT_E_STEP_PIN);
862 862
     disable_e2();
863
-  #endif  
863
+  #endif
864 864
 
865 865
   // waveform generation = 0100 = CTC
866 866
   TCCR1B &= ~(1<<WGM13);
867 867
   TCCR1B |=  (1<<WGM12);
868
-  TCCR1A &= ~(1<<WGM11); 
868
+  TCCR1A &= ~(1<<WGM11);
869 869
   TCCR1A &= ~(1<<WGM10);
870 870
 
871 871
   // output mode = 00 (disconnected)
872
-  TCCR1A &= ~(3<<COM1A0); 
873
-  TCCR1A &= ~(3<<COM1B0); 
874
-  
872
+  TCCR1A &= ~(3<<COM1A0);
873
+  TCCR1A &= ~(3<<COM1B0);
874
+
875 875
   // Set the timer pre-scaler
876 876
   // Generally we use a divider of 8, resulting in a 2MHz timer
877 877
   // frequency on a 16MHz MCU. If you are going to change this, be
@@ -881,19 +881,19 @@ void st_init()
881 881
 
882 882
   OCR1A = 0x4000;
883 883
   TCNT1 = 0;
884
-  ENABLE_STEPPER_DRIVER_INTERRUPT();  
884
+  ENABLE_STEPPER_DRIVER_INTERRUPT();
885 885
 
886 886
   #ifdef ADVANCE
887 887
   #if defined(TCCR0A) && defined(WGM01)
888 888
     TCCR0A &= ~(1<<WGM01);
889 889
     TCCR0A &= ~(1<<WGM00);
890
-  #endif  
890
+  #endif
891 891
     e_steps[0] = 0;
892 892
     e_steps[1] = 0;
893 893
     e_steps[2] = 0;
894 894
     TIMSK0 |= (1<<OCIE0A);
895 895
   #endif //ADVANCE
896
-  
896
+
897 897
   enable_endstops(true); // Start with endstops active. After homing they can be disabled
898 898
   sei();
899 899
 }
@@ -937,13 +937,13 @@ long st_get_position(uint8_t axis)
937 937
 
938 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 949
 void quickStop()
@@ -970,10 +970,10 @@ void digipot_init() //Initialize Digipot Motor Current
970 970
 {
971 971
   #if defined(DIGIPOTSS_PIN) && DIGIPOTSS_PIN > -1
972 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 977
       //digitalPotWrite(digipot_ch[i], digipot_motor_current[i]);
978 978
       digipot_current(i,digipot_motor_current[i]);
979 979
   #endif

Loading…
Cancel
Save