Browse Source

UBL no longer flout's the sacred GCode standard (#6745)

Also clean up ubl_motion.cpp debug info and fix declaration of cx & cy
Roxy-3D 8 years ago
parent
commit
1fbcbc05f6
4 changed files with 63 additions and 133 deletions
  1. 12
    14
      Marlin/G26_Mesh_Validation_Tool.cpp
  2. 1
    1
      Marlin/Marlin_main.cpp
  3. 44
    87
      Marlin/ubl_G29.cpp
  4. 6
    31
      Marlin/ubl_motion.cpp

+ 12
- 14
Marlin/G26_Mesh_Validation_Tool.cpp View File

88
    *
88
    *
89
    *   L #  Layer       Layer height.  (Height of nozzle above bed)  If not specified .20mm will be used.
89
    *   L #  Layer       Layer height.  (Height of nozzle above bed)  If not specified .20mm will be used.
90
    *
90
    *
91
-   *   Q #  Multiplier  Retraction Multiplier.  Normally not needed.  Retraction defaults to 1.0mm and
92
-   *                    un-retraction is at 1.2mm   These numbers will be scaled by the specified amount
93
-   *
94
-   *   M #  Random      Randomize the order that the circles are drawn on the bed.  The search for the closest
95
-   *                    undrawn cicle is still done.  But the distance to the location for each circle has a
96
-   *                    random number of the size specified added to it.  Specifying R50 will give an interesting
97
-   *                    deviation from the normal behaviour on a 10 x 10 Mesh.
98
-
99
-   *   N #  Nozzle      Used to control the size of nozzle diameter.  If not specified, a .4mm nozzle is assumed.
100
-   *                    'n' can be used instead if your host program does not appreciate you using 'N'.
101
-   *
102
    *   O #  Ooooze      How much your nozzle will Ooooze filament while getting in position to print.  This
91
    *   O #  Ooooze      How much your nozzle will Ooooze filament while getting in position to print.  This
103
    *                    is over kill, but using this parameter will let you get the very first 'circle' perfect
92
    *                    is over kill, but using this parameter will let you get the very first 'circle' perfect
104
    *                    so you have a trophy to peel off of the bed and hang up to show how perfectly you have your
93
    *                    so you have a trophy to peel off of the bed and hang up to show how perfectly you have your
111
    *                    printing the Mesh.  You can carefully remove the spent filament with a needle nose
100
    *                    printing the Mesh.  You can carefully remove the spent filament with a needle nose
112
    *                    pliers while holding the LCD Click wheel in a depressed state.
101
    *                    pliers while holding the LCD Click wheel in a depressed state.
113
    *
102
    *
103
+   *   Q #  Multiplier  Retraction Multiplier.  Normally not needed.  Retraction defaults to 1.0mm and
104
+   *                    un-retraction is at 1.2mm   These numbers will be scaled by the specified amount
105
+   *
114
    *   R #  Repeat      Prints the number of patterns given as a parameter, starting at the current location.
106
    *   R #  Repeat      Prints the number of patterns given as a parameter, starting at the current location.
115
    *                    If a parameter isn't given, every point will be printed unless G26 is interrupted.
107
    *                    If a parameter isn't given, every point will be printed unless G26 is interrupted.
116
    *                    This works the same way that the UBL G29 P4 R parameter works.
108
    *                    This works the same way that the UBL G29 P4 R parameter works.
117
    *
109
    *
110
+   *   S #  Nozzle      Used to control the size of nozzle diameter.  If not specified, a .4mm nozzle is assumed.
111
+   *
112
+   *   U #  Random      Randomize the order that the circles are drawn on the bed.  The search for the closest
113
+   *                    undrawn cicle is still done.  But the distance to the location for each circle has a
114
+   *                    random number of the size specified added to it.  Specifying S50 will give an interesting
115
+   *                    deviation from the normal behaviour on a 10 x 10 Mesh.
116
+   *
118
    *   X #  X Coord.    Specify the starting location of the drawing activity.
117
    *   X #  X Coord.    Specify the starting location of the drawing activity.
119
    *
118
    *
120
    *   Y #  Y Coord.    Specify the starting location of the drawing activity.
119
    *   Y #  Y Coord.    Specify the starting location of the drawing activity.
686
       }
685
       }
687
     }
686
     }
688
 
687
 
689
-    if (code_seen('N') || code_seen('n')) { // Warning! Use of 'N' / lowercase flouts established standards.
688
+    if (code_seen('S')) { 
690
       nozzle = code_value_float();
689
       nozzle = code_value_float();
691
       if (!WITHIN(nozzle, 0.1, 1.0)) {
690
       if (!WITHIN(nozzle, 0.1, 1.0)) {
692
         SERIAL_PROTOCOLLNPGM("?Specified nozzle size not plausible.");
691
         SERIAL_PROTOCOLLNPGM("?Specified nozzle size not plausible.");
728
       }
727
       }
729
     }
728
     }
730
 
729
 
731
-    if (code_seen('M')) { // Warning! Use of 'M' flouts established standards.
730
+    if (code_seen('U')) { 
732
       randomSeed(millis());
731
       randomSeed(millis());
733
-      // This setting will persist for the next G26
734
       random_deviation = code_has_value() ? code_value_float() : 50.0;
732
       random_deviation = code_has_value() ? code_value_float() : 50.0;
735
     }
733
     }
736
 
734
 

+ 1
- 1
Marlin/Marlin_main.cpp View File

5761
   /**
5761
   /**
5762
    * M32: Select file and start SD Print
5762
    * M32: Select file and start SD Print
5763
    */
5763
    */
5764
-  inline void gcode_M32() {
5764
+  inline void gcode_M32() {  // Why is M32 allowed to flout the sacred GCode standard?
5765
     if (card.sdprinting)
5765
     if (card.sdprinting)
5766
       stepper.synchronize();
5766
       stepper.synchronize();
5767
 
5767
 

+ 44
- 87
Marlin/ubl_G29.cpp View File

116
    *                    invalidate.
116
    *                    invalidate.
117
    *
117
    *
118
    *   J #   Grid   *   Perform a Grid Based Leveling of the current Mesh using a grid with n points on a side.
118
    *   J #   Grid   *   Perform a Grid Based Leveling of the current Mesh using a grid with n points on a side.
119
-   *
120
-   *   j  EEPROM Dump   This function probably goes away after debug is complete.
119
+   *                    Not specifying a grid size will invoke the 3-Point leveling function.
121
    *
120
    *
122
    *   K #   Kompare    Kompare current Mesh with stored Mesh # replacing current Mesh with the result. This
121
    *   K #   Kompare    Kompare current Mesh with stored Mesh # replacing current Mesh with the result. This
123
    *                    command literally performs a diff between two Meshes.
122
    *                    command literally performs a diff between two Meshes.
264
    *                    at a later date. The GCode output can be saved and later replayed by the host software
263
    *                    at a later date. The GCode output can be saved and later replayed by the host software
265
    *                    to reconstruct the current mesh on another machine.
264
    *                    to reconstruct the current mesh on another machine.
266
    *
265
    *
267
-   *   T     3-Point    Perform a 3 Point Bed Leveling on the current Mesh
268
-   *
269
    *   U     Unlevel    Perform a probe of the outer perimeter to assist in physically leveling unlevel beds.
266
    *   U     Unlevel    Perform a probe of the outer perimeter to assist in physically leveling unlevel beds.
270
    *                    Only used for G29 P1 O U   It will speed up the probing of the edge of the bed.  This
267
    *                    Only used for G29 P1 O U   It will speed up the probing of the edge of the bed.  This
271
    *                    is useful when the entire bed does not need to be probed because it will be adjusted.
268
    *                    is useful when the entire bed does not need to be probed because it will be adjusted.
276
    *
273
    *
277
    *   Y #   *      *   Y Location for this line of commands
274
    *   Y #   *      *   Y Location for this line of commands
278
    *
275
    *
279
-   *   Z     Zero   *   Probes to set the Z Height of the nozzle. The entire Mesh can be raised or lowered
280
-   *                    by just doing a G29 Z
281
-   *
282
-   *   Z #   Zero   *   The entire Mesh can be raised or lowered to conform with the specified difference.
283
-   *                    zprobe_zoffset is added to the calculation.
284
-   *
285
    *
276
    *
286
    *   Release Notes:
277
    *   Release Notes:
287
    *   You MUST do M502, M500 to initialize the storage. Failure to do this will cause all
278
    *   You MUST do M502, M500 to initialize the storage. Failure to do this will cause all
329
     }
320
     }
330
 
321
 
331
     // Don't allow auto-leveling without homing first
322
     // Don't allow auto-leveling without homing first
332
-    if (!(code_seen('N') && code_value_bool()) && axis_unhomed_error()) // Warning! Use of 'N' flouts established standards.
323
+    if (axis_unhomed_error()) 
333
       home_all_axes();
324
       home_all_axes();
334
 
325
 
335
     if (g29_parameter_parsing()) return; // abort if parsing the simple parameters causes a problem,
326
     if (g29_parameter_parsing()) return; // abort if parsing the simple parameters causes a problem,
353
     }
344
     }
354
 
345
 
355
     if (code_seen('Q')) {
346
     if (code_seen('Q')) {
356
-      const int test_pattern = code_has_value() ? code_value_int() : -1;
357
-      if (!WITHIN(test_pattern, 0, 2)) {
347
+      const int test_pattern = code_has_value() ? code_value_int() : -99;
348
+      if (!WITHIN(test_pattern, -1, 2)) {
358
         SERIAL_PROTOCOLLNPGM("Invalid test_pattern value. (0-2)\n");
349
         SERIAL_PROTOCOLLNPGM("Invalid test_pattern value. (0-2)\n");
359
         return;
350
         return;
360
       }
351
       }
361
       SERIAL_PROTOCOLLNPGM("Loading test_pattern values.\n");
352
       SERIAL_PROTOCOLLNPGM("Loading test_pattern values.\n");
362
       switch (test_pattern) {
353
       switch (test_pattern) {
354
+        case -1:
355
+          g29_eeprom_dump();
356
+          break;
363
         case 0:
357
         case 0:
364
           for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++) {   // Create a bowl shape - similar to
358
           for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++) {   // Create a bowl shape - similar to
365
             for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++) { // a poorly calibrated Delta.
359
             for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++) { // a poorly calibrated Delta.
385
     }
379
     }
386
 
380
 
387
     if (code_seen('J')) {
381
     if (code_seen('J')) {
388
-      ubl.save_ubl_active_state_and_disable();
389
-      ubl.tilt_mesh_based_on_probed_grid(code_seen('O') || code_seen('M')); // Warning! Use of 'M' flouts established standards.
390
-      ubl.restore_ubl_active_state_and_leave();
382
+      if (grid_size!=0) {  // if not 0 it is a normal n x n grid being probed
383
+        ubl.save_ubl_active_state_and_disable();
384
+        ubl.tilt_mesh_based_on_probed_grid(code_seen('O')); 
385
+        ubl.restore_ubl_active_state_and_leave();
386
+      } else { // grid_size==0 which means a 3-Point leveling has been requested
387
+        float z1 = probe_pt(LOGICAL_X_POSITION(UBL_PROBE_PT_1_X), LOGICAL_Y_POSITION(UBL_PROBE_PT_1_Y), false, g29_verbose_level),
388
+              z2 = probe_pt(LOGICAL_X_POSITION(UBL_PROBE_PT_2_X), LOGICAL_Y_POSITION(UBL_PROBE_PT_2_Y), false, g29_verbose_level),
389
+              z3 = probe_pt(LOGICAL_X_POSITION(UBL_PROBE_PT_3_X), LOGICAL_Y_POSITION(UBL_PROBE_PT_3_Y), true, g29_verbose_level);
390
+
391
+        if ( isnan(z1) || isnan(z2) || isnan(z3)) {   // probe_pt will return NAN if unreachable
392
+          SERIAL_ERROR_START;
393
+          SERIAL_ERRORLNPGM("Attempt to probe off the bed.");
394
+          goto LEAVE;
395
+        }
396
+
397
+      //  We need to adjust z1, z2, z3 by the Mesh Height at these points. Just because they are non-zero doesn't mean
398
+      //  the Mesh is tilted!  (We need to compensate each probe point by what the Mesh says that location's height is)
399
+
400
+        ubl.save_ubl_active_state_and_disable();
401
+        z1 -= ubl.get_z_correction(LOGICAL_X_POSITION(UBL_PROBE_PT_1_X), LOGICAL_Y_POSITION(UBL_PROBE_PT_1_Y)) /* + zprobe_zoffset */ ;
402
+        z2 -= ubl.get_z_correction(LOGICAL_X_POSITION(UBL_PROBE_PT_2_X), LOGICAL_Y_POSITION(UBL_PROBE_PT_2_Y)) /* + zprobe_zoffset */ ;
403
+        z3 -= ubl.get_z_correction(LOGICAL_X_POSITION(UBL_PROBE_PT_3_X), LOGICAL_Y_POSITION(UBL_PROBE_PT_3_Y)) /* + zprobe_zoffset */ ;
404
+
405
+        do_blocking_move_to_xy(0.5 * (UBL_MESH_MAX_X - (UBL_MESH_MIN_X)), 0.5 * (UBL_MESH_MAX_Y - (UBL_MESH_MIN_Y)));
406
+        ubl.tilt_mesh_based_on_3pts(z1, z2, z3);
407
+        ubl.restore_ubl_active_state_and_leave();
408
+      }
391
     }
409
     }
392
 
410
 
393
     if (code_seen('P')) {
411
     if (code_seen('P')) {
420
             SERIAL_PROTOCOLLNPGM(").\n");
438
             SERIAL_PROTOCOLLNPGM(").\n");
421
           }
439
           }
422
           ubl.probe_entire_mesh(x_pos + X_PROBE_OFFSET_FROM_EXTRUDER, y_pos + Y_PROBE_OFFSET_FROM_EXTRUDER,
440
           ubl.probe_entire_mesh(x_pos + X_PROBE_OFFSET_FROM_EXTRUDER, y_pos + Y_PROBE_OFFSET_FROM_EXTRUDER,
423
-                            code_seen('O') || code_seen('M'), code_seen('E'), code_seen('U')); // Warning! Use of 'M' flouts established standards.
441
+                            code_seen('O'), code_seen('E'), code_seen('U')); 
424
           break;
442
           break;
425
 
443
 
426
         case 2: {
444
         case 2: {
469
             return;
487
             return;
470
           }
488
           }
471
 
489
 
472
-          manually_probe_remaining_mesh(x_pos, y_pos, height, card_thickness, code_seen('O') || code_seen('M')); // Warning! Use of 'M' flouts established standards.
490
+          manually_probe_remaining_mesh(x_pos, y_pos, height, card_thickness, code_seen('O'));
473
           SERIAL_PROTOCOLLNPGM("G29 P2 finished.");
491
           SERIAL_PROTOCOLLNPGM("G29 P2 finished.");
474
         } break;
492
         } break;
475
 
493
 
505
           //
523
           //
506
           // Fine Tune (i.e., Edit) the Mesh
524
           // Fine Tune (i.e., Edit) the Mesh
507
           //
525
           //
508
-          fine_tune_mesh(x_pos, y_pos, code_seen('O') || code_seen('M')); // Warning! Use of 'M' flouts established standards.
526
+          fine_tune_mesh(x_pos, y_pos, code_seen('O')); 
509
           break;
527
           break;
510
 
528
 
511
         case 5: ubl.find_mean_mesh_height(); break;
529
         case 5: ubl.find_mean_mesh_height(); break;
515
 
533
 
516
     }
534
     }
517
 
535
 
518
-    if (code_seen('T')) {
519
-
520
-      float z1 = probe_pt(LOGICAL_X_POSITION(UBL_PROBE_PT_1_X), LOGICAL_Y_POSITION(UBL_PROBE_PT_1_Y), false, g29_verbose_level),
521
-            z2 = probe_pt(LOGICAL_X_POSITION(UBL_PROBE_PT_2_X), LOGICAL_Y_POSITION(UBL_PROBE_PT_2_Y), false, g29_verbose_level),
522
-            z3 = probe_pt(LOGICAL_X_POSITION(UBL_PROBE_PT_3_X), LOGICAL_Y_POSITION(UBL_PROBE_PT_3_Y), true, g29_verbose_level);
523
-
524
-      if ( isnan(z1) || isnan(z2) || isnan(z3)) {   // probe_pt will return NAN if unreachable
525
-          SERIAL_ERROR_START;
526
-          SERIAL_ERRORLNPGM("Attempt to probe off the bed.");
527
-          goto LEAVE;
528
-      }
529
-
530
-      //  We need to adjust z1, z2, z3 by the Mesh Height at these points. Just because they are non-zero doesn't mean
531
-      //  the Mesh is tilted!  (We need to compensate each probe point by what the Mesh says that location's height is)
532
-
533
-      ubl.save_ubl_active_state_and_disable();
534
-      z1 -= ubl.get_z_correction(LOGICAL_X_POSITION(UBL_PROBE_PT_1_X), LOGICAL_Y_POSITION(UBL_PROBE_PT_1_Y)) /* + zprobe_zoffset */ ;
535
-      z2 -= ubl.get_z_correction(LOGICAL_X_POSITION(UBL_PROBE_PT_2_X), LOGICAL_Y_POSITION(UBL_PROBE_PT_2_Y)) /* + zprobe_zoffset */ ;
536
-      z3 -= ubl.get_z_correction(LOGICAL_X_POSITION(UBL_PROBE_PT_3_X), LOGICAL_Y_POSITION(UBL_PROBE_PT_3_Y)) /* + zprobe_zoffset */ ;
537
-
538
-      do_blocking_move_to_xy(0.5 * (UBL_MESH_MAX_X - (UBL_MESH_MIN_X)), 0.5 * (UBL_MESH_MAX_Y - (UBL_MESH_MIN_Y)));
539
-      ubl.tilt_mesh_based_on_3pts(z1, z2, z3);
540
-      ubl.restore_ubl_active_state_and_leave();
541
-    }
542
-
543
     //
536
     //
544
     // Much of the 'What?' command can be eliminated. But until we are fully debugged, it is
537
     // Much of the 'What?' command can be eliminated. But until we are fully debugged, it is
545
     // good to have the extra information. Soon... we prune this to just a few items
538
     // good to have the extra information. Soon... we prune this to just a few items
547
     if (code_seen('W')) ubl.g29_what_command();
540
     if (code_seen('W')) ubl.g29_what_command();
548
  
541
  
549
     //
542
     //
550
-    // When we are fully debugged, the EEPROM dump command will get deleted also. But
551
-    // right now, it is good to have the extra information. Soon... we prune this.
552
-    //
553
-    if (code_seen('j')) g29_eeprom_dump(); // Warning! Use of lowercase flouts established standards.
554
-
555
-    //
556
     // When we are fully debugged, this may go away. But there are some valid
543
     // When we are fully debugged, this may go away. But there are some valid
557
     // use cases for the users. So we can wait and see what to do with it.
544
     // use cases for the users. So we can wait and see what to do with it.
558
     //
545
     //
614
       SERIAL_PROTOCOLLNPGM("Done.\n");
601
       SERIAL_PROTOCOLLNPGM("Done.\n");
615
     }
602
     }
616
 
603
 
617
-    if (code_seen('O') || code_seen('M')) // Warning! Use of 'M' flouts established standards.
604
+    if (code_seen('O'))
618
       ubl.display_map(code_has_value() ? code_value_int() : 0);
605
       ubl.display_map(code_has_value() ? code_value_int() : 0);
619
 
606
 
607
+    /*
608
+     * This code may not be needed...   Prepare for its removal...
609
+     *
620
     if (code_seen('Z')) {
610
     if (code_seen('Z')) {
621
       if (code_has_value())
611
       if (code_has_value())
622
         ubl.state.z_offset = code_value_float();   // do the simple case. Just lock in the specified value
612
         ubl.state.z_offset = code_value_float();   // do the simple case. Just lock in the specified value
669
         ubl.restore_ubl_active_state_and_leave();
659
         ubl.restore_ubl_active_state_and_leave();
670
       }
660
       }
671
     }
661
     }
662
+    */
672
 
663
 
673
     LEAVE:
664
     LEAVE:
674
 
665
 
1069
     }
1060
     }
1070
 
1061
 
1071
     if (code_seen('J')) {
1062
     if (code_seen('J')) {
1072
-      grid_size = code_has_value() ? code_value_int() : 3;
1073
-      if (!WITHIN(grid_size, 2, 9)) {
1063
+      grid_size = code_has_value() ? code_value_int() : 0;
1064
+      if (grid_size!=0 && !WITHIN(grid_size, 2, 9)) {
1074
         SERIAL_PROTOCOLLNPGM("?Invalid grid size (J) specified (2-9).\n");
1065
         SERIAL_PROTOCOLLNPGM("?Invalid grid size (J) specified (2-9).\n");
1075
         err_flag = true;
1066
         err_flag = true;
1076
       }
1067
       }
1126
       SERIAL_PROTOCOLLNPGM("Invalid map type.\n");
1117
       SERIAL_PROTOCOLLNPGM("Invalid map type.\n");
1127
       return UBL_ERR;
1118
       return UBL_ERR;
1128
     }
1119
     }
1129
-
1130
-    // Check if a map type was specified
1131
-    if (code_seen('M')) { // Warning! Use of 'M' flouts established standards.
1132
-      map_type = code_has_value() ? code_value_int() : 0;
1133
-      if (!WITHIN(map_type, 0, 1)) {
1134
-        SERIAL_PROTOCOLLNPGM("Invalid map type.\n");
1135
-        return UBL_ERR;
1136
-      }
1137
-    }
1138
-
1139
     return UBL_OK;
1120
     return UBL_OK;
1140
   }
1121
   }
1141
 
1122
 
1142
-  /**
1143
-   * This function goes away after G29 debug is complete. But for right now, it is a handy
1144
-   * routine to dump binary data structures.
1145
-   */
1146
-  /*
1147
-  void dump(char * const str, const float &f) {
1148
-    char *ptr;
1149
-
1150
-    SERIAL_PROTOCOL(str);
1151
-    SERIAL_PROTOCOL_F(f, 8);
1152
-    SERIAL_PROTOCOLPGM("  ");
1153
-    ptr = (char*)&f;
1154
-    for (uint8_t i = 0; i < 4; i++)
1155
-      SERIAL_PROTOCOLPAIR("  ", hex_byte(*ptr++));
1156
-    SERIAL_PROTOCOLPAIR("  isnan()=", isnan(f));
1157
-    SERIAL_PROTOCOLPAIR("  isinf()=", isinf(f));
1158
-
1159
-    if (f == -INFINITY)
1160
-      SERIAL_PROTOCOLPGM("  Minus Infinity detected.");
1161
-
1162
-    SERIAL_EOL;
1163
-  }
1164
-  //*/
1165
-
1166
   static int ubl_state_at_invocation = 0,
1123
   static int ubl_state_at_invocation = 0,
1167
              ubl_state_recursion_chk = 0;
1124
              ubl_state_recursion_chk = 0;
1168
 
1125
 

+ 6
- 31
Marlin/ubl_motion.cpp View File

55
                 dy = current_position[Y_AXIS] - destination[Y_AXIS],
55
                 dy = current_position[Y_AXIS] - destination[Y_AXIS],
56
                 xy_dist = HYPOT(dx, dy);
56
                 xy_dist = HYPOT(dx, dy);
57
 
57
 
58
-    if (xy_dist == 0.0) {
59
-      return;
60
-      //SERIAL_ECHOPGM("   FPMM=");
61
-      //const float fpmm = de / xy_dist;
62
-      //SERIAL_PROTOCOL_F(fpmm, 6);
63
-    }
58
+    if (xy_dist == 0.0) 
59
+	    return;
64
     else {
60
     else {
65
       SERIAL_ECHOPGM("   fpmm=");
61
       SERIAL_ECHOPGM("   fpmm=");
66
       const float fpmm = de / xy_dist;
62
       const float fpmm = de / xy_dist;
276
          */
272
          */
277
         if (y != start[Y_AXIS]) {
273
         if (y != start[Y_AXIS]) {
278
           if (!inf_normalized_flag) {
274
           if (!inf_normalized_flag) {
279
-
280
-            //on_axis_distance = y - start[Y_AXIS];
281
             on_axis_distance = use_x_dist ? x - start[X_AXIS] : y - start[Y_AXIS];
275
             on_axis_distance = use_x_dist ? x - start[X_AXIS] : y - start[Y_AXIS];
282
-
283
-            //on_axis_distance = use_x_dist ? next_mesh_line_x - start[X_AXIS] : y - start[Y_AXIS];
284
-            //on_axis_distance = use_x_dist ? x - start[X_AXIS] : next_mesh_line_y - start[Y_AXIS];
285
-
286
-            //on_axis_distance = use_x_dist ? next_mesh_line_x - start[X_AXIS] : y - start[Y_AXIS];
287
-            //on_axis_distance = use_x_dist ? x - start[X_AXIS] : next_mesh_line_y - start[Y_AXIS];
288
-
289
             e_position = start[E_AXIS] + on_axis_distance * e_normalized_dist;
276
             e_position = start[E_AXIS] + on_axis_distance * e_normalized_dist;
290
             z_position = start[Z_AXIS] + on_axis_distance * z_normalized_dist;
277
             z_position = start[Z_AXIS] + on_axis_distance * z_normalized_dist;
291
           }
278
           }
350
          */
337
          */
351
         if (x != start[X_AXIS]) {
338
         if (x != start[X_AXIS]) {
352
           if (!inf_normalized_flag) {
339
           if (!inf_normalized_flag) {
353
-
354
-            //on_axis_distance = x - start[X_AXIS];
355
             on_axis_distance = use_x_dist ? x - start[X_AXIS] : y - start[Y_AXIS];
340
             on_axis_distance = use_x_dist ? x - start[X_AXIS] : y - start[Y_AXIS];
356
-
357
-            //on_axis_distance = use_x_dist ? next_mesh_line_x - start[X_AXIS] : y - start[Y_AXIS];
358
-            //on_axis_distance = use_x_dist ? x - start[X_AXIS] : next_mesh_line_y - start[Y_AXIS];
359
-
360
             e_position = start[E_AXIS] + on_axis_distance * e_normalized_dist;  // is based on X or Y because this is a horizontal move
341
             e_position = start[E_AXIS] + on_axis_distance * e_normalized_dist;  // is based on X or Y because this is a horizontal move
361
             z_position = start[Z_AXIS] + on_axis_distance * z_normalized_dist;
342
             z_position = start[Z_AXIS] + on_axis_distance * z_normalized_dist;
362
           }
343
           }
613
         cell_xi = constrain(cell_xi, 0, (GRID_MAX_POINTS_X) - 1);
594
         cell_xi = constrain(cell_xi, 0, (GRID_MAX_POINTS_X) - 1);
614
         cell_yi = constrain(cell_yi, 0, (GRID_MAX_POINTS_Y) - 1);
595
         cell_yi = constrain(cell_yi, 0, (GRID_MAX_POINTS_Y) - 1);
615
 
596
 
616
-        // float x0 = (UBL_MESH_MIN_X) + ((MESH_X_DIST) * cell_xi );         // lower left cell corner
617
-        // float y0 = (UBL_MESH_MIN_Y) + ((MESH_Y_DIST) * cell_yi );         // lower left cell corner
618
-        // float x1 = x0 + MESH_X_DIST;                                      // upper right cell corner
619
-        // float y1 = y0 + MESH_Y_DIST;                                      // upper right cell corner
620
-
621
         const float x0 = pgm_read_float(&(ubl.mesh_index_to_xpos[cell_xi  ])),  // 64 byte table lookup avoids mul+add
597
         const float x0 = pgm_read_float(&(ubl.mesh_index_to_xpos[cell_xi  ])),  // 64 byte table lookup avoids mul+add
622
                     y0 = pgm_read_float(&(ubl.mesh_index_to_ypos[cell_yi  ])),  // 64 byte table lookup avoids mul+add
598
                     y0 = pgm_read_float(&(ubl.mesh_index_to_ypos[cell_yi  ])),  // 64 byte table lookup avoids mul+add
623
                     x1 = pgm_read_float(&(ubl.mesh_index_to_xpos[cell_xi+1])),  // 64 byte table lookup avoids mul+add
599
                     x1 = pgm_read_float(&(ubl.mesh_index_to_xpos[cell_xi+1])),  // 64 byte table lookup avoids mul+add
624
-                    y1 = pgm_read_float(&(ubl.mesh_index_to_ypos[cell_yi+1])),  // 64 byte table lookup avoids mul+add
625
-
626
-                    cx = rx - x0,   // cell-relative x
627
-                    cy = ry - y0;   // cell-relative y
600
+                    y1 = pgm_read_float(&(ubl.mesh_index_to_ypos[cell_yi+1]));  // 64 byte table lookup avoids mul+add
628
 
601
 
629
-        float z_x0y0 = ubl.z_values[cell_xi  ][cell_yi  ],  // z at lower left corner
602
+        float cx = rx - x0,   // cell-relative x
603
+              cy = ry - y0;   // cell-relative y
604
+              z_x0y0 = ubl.z_values[cell_xi  ][cell_yi  ],  // z at lower left corner
630
               z_x1y0 = ubl.z_values[cell_xi+1][cell_yi  ],  // z at upper left corner
605
               z_x1y0 = ubl.z_values[cell_xi+1][cell_yi  ],  // z at upper left corner
631
               z_x0y1 = ubl.z_values[cell_xi  ][cell_yi+1],  // z at lower right corner
606
               z_x0y1 = ubl.z_values[cell_xi  ][cell_yi+1],  // z at lower right corner
632
               z_x1y1 = ubl.z_values[cell_xi+1][cell_yi+1];  // z at upper right corner
607
               z_x1y1 = ubl.z_values[cell_xi+1][cell_yi+1];  // z at upper right corner

Loading…
Cancel
Save