소스 검색

preprocessor magic to have a single source principle

Bernhard Kubicek 13 년 전
부모
커밋
0b43761c3a
1개의 변경된 파일27개의 추가작업 그리고 74개의 파일을 삭제
  1. 27
    74
      Marlin/Marlin.pde

+ 27
- 74
Marlin/Marlin.pde 파일 보기

@@ -405,6 +405,29 @@ inline bool code_seen(char code)
405 405
   strchr_pointer = strchr(cmdbuffer[bufindr], code);
406 406
   return (strchr_pointer != NULL);  //Return True if a character was found
407 407
 }
408
+#define HOMEAXIS(LETTER) \
409
+  if ((LETTER##_MIN_PIN > -1 && LETTER##_HOME_DIR==-1) || (LETTER##_MAX_PIN > -1 && LETTER##_HOME_DIR==1))\
410
+    { \
411
+    current_position[LETTER##_AXIS] = 0; \
412
+    plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); \
413
+    destination[LETTER##_AXIS] = 1.5 * LETTER##_MAX_LENGTH * LETTER##_HOME_DIR; \
414
+    feedrate = homing_feedrate[LETTER##_AXIS]; \
415
+    prepare_move(); \
416
+    \
417
+    current_position[LETTER##_AXIS] = 0;\
418
+    plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);\
419
+    destination[LETTER##_AXIS] = -5 * LETTER##_HOME_DIR;\
420
+    prepare_move(); \
421
+    \
422
+    destination[LETTER##_AXIS] = 10 * LETTER##_HOME_DIR;\
423
+    feedrate = homing_feedrate[LETTER##_AXIS]/2 ;  \
424
+    prepare_move(); \
425
+    \
426
+    current_position[LETTER##_AXIS] = (LETTER##_HOME_DIR == -1) ? 0 : LETTER##_MAX_LENGTH;\
427
+    plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);\
428
+    destination[LETTER##_AXIS] = current_position[LETTER##_AXIS];\
429
+    feedrate = 0.0;\
430
+  }
408 431
 
409 432
 inline void process_commands()
410 433
 {
@@ -455,85 +478,15 @@ inline void process_commands()
455 478
 
456 479
       if((home_all_axis) || (code_seen(axis_codes[X_AXIS]))) 
457 480
       {
458
-        if ((X_MIN_PIN > -1 && X_HOME_DIR==-1) || (X_MAX_PIN > -1 && X_HOME_DIR==1)){
459
-//          st_synchronize();
460
-          current_position[X_AXIS] = 0;
461
-          plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
462
-          destination[X_AXIS] = 1.5 * X_MAX_LENGTH * X_HOME_DIR;
463
-          feedrate = homing_feedrate[X_AXIS];
464
-          prepare_move();
465
-          
466
-//          st_synchronize();        
467
-          current_position[X_AXIS] = 0;
468
-          plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
469
-          destination[X_AXIS] = -5 * X_HOME_DIR;
470
-          prepare_move();
471
-          
472
-//          st_synchronize();         
473
-          destination[X_AXIS] = 10 * X_HOME_DIR;
474
-          feedrate = homing_feedrate[X_AXIS]/2 ;
475
-          prepare_move();
476
-          
477
-//          st_synchronize();
478
-          current_position[X_AXIS] = (X_HOME_DIR == -1) ? 0 : X_MAX_LENGTH;
479
-          plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
480
-          destination[X_AXIS] = current_position[X_AXIS];
481
-          feedrate = 0.0;
482
-        }
481
+        HOMEAXIS(X);
483 482
       }
484 483
 
485 484
       if((home_all_axis) || (code_seen(axis_codes[Y_AXIS]))) {
486
-        if ((Y_MIN_PIN > -1 && Y_HOME_DIR==-1) || (Y_MAX_PIN > -1 && Y_HOME_DIR==1)){
487
-          current_position[Y_AXIS] = 0;
488
-          plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
489
-          destination[Y_AXIS] = 1.5 * Y_MAX_LENGTH * Y_HOME_DIR;
490
-          feedrate = homing_feedrate[Y_AXIS];
491
-          prepare_move();
492
-//          st_synchronize();
493
-
494
-          current_position[Y_AXIS] = 0;
495
-          plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
496
-          destination[Y_AXIS] = -5 * Y_HOME_DIR;
497
-          prepare_move();
498
-//          st_synchronize();
499
-
500
-          destination[Y_AXIS] = 10 * Y_HOME_DIR;
501
-          feedrate = homing_feedrate[Y_AXIS]/2;
502
-          prepare_move();
503
-//          st_synchronize();
504
-
505
-          current_position[Y_AXIS] = (Y_HOME_DIR == -1) ? 0 : Y_MAX_LENGTH;
506
-          plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
507
-          destination[Y_AXIS] = current_position[Y_AXIS];
508
-          feedrate = 0.0;
509
-        }
485
+       HOMEAXIS(Y);
510 486
       }
511 487
 
512 488
       if((home_all_axis) || (code_seen(axis_codes[Z_AXIS]))) {
513
-        if ((Z_MIN_PIN > -1 && Z_HOME_DIR==-1) || (Z_MAX_PIN > -1 && Z_HOME_DIR==1)){
514
-          current_position[Z_AXIS] = 0;
515
-          plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
516
-          destination[Z_AXIS] = 1.5 * Z_MAX_LENGTH * Z_HOME_DIR;
517
-          feedrate = homing_feedrate[Z_AXIS];
518
-          prepare_move();
519
-//          st_synchronize();
520
-
521
-          current_position[Z_AXIS] = 0;
522
-          plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
523
-          destination[Z_AXIS] = -2 * Z_HOME_DIR;
524
-          prepare_move();
525
-//          st_synchronize();
526
-
527
-          destination[Z_AXIS] = 3 * Z_HOME_DIR;
528
-          feedrate = homing_feedrate[Z_AXIS]/2;
529
-          prepare_move();
530
-//          st_synchronize();
531
-
532
-          current_position[Z_AXIS] = (Z_HOME_DIR == -1) ? 0 : Z_MAX_LENGTH;
533
-          plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
534
-          destination[Z_AXIS] = current_position[Z_AXIS];
535
-          feedrate = 0.0;         
536
-        }
489
+        HOMEAXIS(Z);
537 490
       }       
538 491
       feedrate = saved_feedrate;
539 492
       feedmultiply = saved_feedmultiply;
@@ -684,7 +637,7 @@ inline void process_commands()
684 637
             Serial.println();
685 638
           #endif //TEMP_1_PIN
686 639
         #else
687
-          Serial.println("echo: No thermistors - no temp");
640
+          SERIAL_ERRORLN("No thermistors - no temp");
688 641
       #endif
689 642
       return;
690 643
       break;

Loading…
취소
저장