瀏覽代碼

References are better for array args

Scott Lahteine 6 年之前
父節點
當前提交
73e32925e4

+ 1
- 1
.travis.yml 查看文件

@@ -121,7 +121,7 @@ script:
121 121
   - opt_enable ULTIMAKERCONTROLLER SDSUPPORT
122 122
   - opt_enable PRINTCOUNTER NOZZLE_PARK_FEATURE NOZZLE_CLEAN_FEATURE PCA9632 USE_XMAX_PLUG
123 123
   - opt_enable_adv BEZIER_CURVE_SUPPORT EXPERIMENTAL_I2CBUS
124
-  - opt_enable_adv ADVANCED_PAUSE_FEATURE PARK_HEAD_ON_PAUSE LCD_INFO_MENU
124
+  - opt_enable_adv ADVANCED_PAUSE_FEATURE PARK_HEAD_ON_PAUSE LCD_INFO_MENU M114_DETAIL
125 125
   - opt_set_adv PWM_MOTOR_CURRENT {1300,1300,1250}
126 126
   - opt_set_adv I2C_SLAVE_ADDRESS 63
127 127
   - build_marlin_pio ${TRAVIS_BUILD_DIR} ${TEST_PLATFORM}

+ 1
- 1
Marlin/src/feature/bedlevel/ubl/ubl.h 查看文件

@@ -316,7 +316,7 @@ class unified_bed_leveling {
316 316
     }
317 317
 
318 318
     static bool prepare_segmented_line_to(const float rtarget[XYZE], const float &feedrate);
319
-    static void line_to_destination_cartesian(const float &fr, uint8_t e);
319
+    static void line_to_destination_cartesian(const float &fr, const uint8_t e);
320 320
 
321 321
     #define _CMPZ(a,b) (z_values[a][b] == z_values[a][b+1])
322 322
     #define CMPZ(a) (_CMPZ(a, 0) && _CMPZ(a, 1))

+ 2
- 2
Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp 查看文件

@@ -92,7 +92,7 @@
92 92
 
93 93
   }
94 94
 
95
-  void unified_bed_leveling::line_to_destination_cartesian(const float &feed_rate, uint8_t extruder) {
95
+  void unified_bed_leveling::line_to_destination_cartesian(const float &feed_rate, const uint8_t extruder) {
96 96
     /**
97 97
      * Much of the nozzle movement will be within the same cell. So we will do as little computation
98 98
      * as possible to determine if this is the case. If this move is within the same cell, we will
@@ -475,7 +475,7 @@
475 475
     // We don't want additional apply_leveling() performed by regular buffer_line or buffer_line_kinematic,
476 476
     // so we call _buffer_line directly here.  Per-segmented leveling and kinematics performed first.
477 477
 
478
-    inline void _O2 ubl_buffer_segment_raw(const float raw[XYZE], const float &fr) {
478
+    inline void _O2 ubl_buffer_segment_raw(const float (&raw)[XYZE], const float &fr) {
479 479
 
480 480
       #if ENABLED(DELTA)  // apply delta inverse_kinematics
481 481
 

+ 3
- 3
Marlin/src/gcode/bedlevel/G26.cpp 查看文件

@@ -261,16 +261,16 @@ void move_to(const float &rx, const float &ry, const float &z, const float &e_de
261 261
   set_destination_from_current();
262 262
 }
263 263
 
264
-FORCE_INLINE void move_to(const float where[XYZE], const float &de) { move_to(where[X_AXIS], where[Y_AXIS], where[Z_AXIS], de); }
264
+FORCE_INLINE void move_to(const float (&where)[XYZE], const float &de) { move_to(where[X_AXIS], where[Y_AXIS], where[Z_AXIS], de); }
265 265
 
266
-void retract_filament(const float where[XYZE]) {
266
+void retract_filament(const float (&where)[XYZE]) {
267 267
   if (!g26_retracted) { // Only retract if we are not already retracted!
268 268
     g26_retracted = true;
269 269
     move_to(where, -1.0 * g26_retraction_multiplier);
270 270
   }
271 271
 }
272 272
 
273
-void recover_filament(const float where[XYZE]) {
273
+void recover_filament(const float (&where)[XYZE]) {
274 274
   if (g26_retracted) { // Only un-retract if we are retracted.
275 275
     move_to(where, 1.2 * g26_retraction_multiplier);
276 276
     g26_retracted = false;

+ 2
- 2
Marlin/src/gcode/host/M114.cpp 查看文件

@@ -28,7 +28,7 @@
28 28
 
29 29
 #if ENABLED(M114_DETAIL)
30 30
 
31
-  void report_xyze(const float pos[XYZE], const uint8_t n = 4, const uint8_t precision = 3) {
31
+  void report_xyze(const float pos[], const uint8_t n = 4, const uint8_t precision = 3) {
32 32
     char str[12];
33 33
     for (uint8_t i = 0; i < n; i++) {
34 34
       SERIAL_CHAR(' ');
@@ -39,7 +39,7 @@
39 39
     SERIAL_EOL();
40 40
   }
41 41
 
42
-  inline void report_xyz(const float pos[XYZ]) { report_xyze(pos, 3); }
42
+  inline void report_xyz(const float pos[]) { report_xyze(pos, 3); }
43 43
 
44 44
   void report_current_position_detail() {
45 45
 

+ 9
- 9
Marlin/src/gcode/motion/G2_G3.cpp 查看文件

@@ -44,9 +44,9 @@
44 44
  * options for G2/G3 arc generation. In future these options may be GCode tunable.
45 45
  */
46 46
 void plan_arc(
47
-  float rtarget[XYZE], // Destination position
48
-  float *offset,       // Center of rotation relative to current_position
49
-  uint8_t clockwise    // Clockwise?
47
+  const float (&cart)[XYZE],  // Destination position
48
+  const float (&offset)[2],   // Center of rotation relative to current_position
49
+  const uint8_t clockwise     // Clockwise?
50 50
 ) {
51 51
   #if ENABLED(CNC_WORKSPACE_PLANES)
52 52
     AxisEnum p_axis, q_axis, l_axis;
@@ -66,10 +66,10 @@ void plan_arc(
66 66
   const float radius = HYPOT(r_P, r_Q),
67 67
               center_P = current_position[p_axis] - r_P,
68 68
               center_Q = current_position[q_axis] - r_Q,
69
-              rt_X = rtarget[p_axis] - center_P,
70
-              rt_Y = rtarget[q_axis] - center_Q,
71
-              linear_travel = rtarget[l_axis] - current_position[l_axis],
72
-              extruder_travel = rtarget[E_AXIS] - current_position[E_AXIS];
69
+              rt_X = cart[p_axis] - center_P,
70
+              rt_Y = cart[q_axis] - center_Q,
71
+              linear_travel = cart[l_axis] - current_position[l_axis],
72
+              extruder_travel = cart[E_AXIS] - current_position[E_AXIS];
73 73
 
74 74
   // CCW angle of rotation between position and target from the circle center. Only one atan2() trig computation required.
75 75
   float angular_travel = ATAN2(r_P * rt_Y - r_Q * rt_X, r_P * rt_X + r_Q * rt_Y);
@@ -77,7 +77,7 @@ void plan_arc(
77 77
   if (clockwise) angular_travel -= RADIANS(360);
78 78
 
79 79
   // Make a circle if the angular rotation is 0 and the target is current position
80
-  if (angular_travel == 0 && current_position[p_axis] == rtarget[p_axis] && current_position[q_axis] == rtarget[q_axis])
80
+  if (angular_travel == 0 && current_position[p_axis] == cart[p_axis] && current_position[q_axis] == cart[q_axis])
81 81
     angular_travel = RADIANS(360);
82 82
 
83 83
   const float mm_of_travel = HYPOT(angular_travel * radius, FABS(linear_travel));
@@ -177,7 +177,7 @@ void plan_arc(
177 177
   }
178 178
 
179 179
   // Ensure last segment arrives at target location.
180
-  planner.buffer_line_kinematic(rtarget, fr_mm_s, active_extruder);
180
+  planner.buffer_line_kinematic(cart, fr_mm_s, active_extruder);
181 181
 
182 182
   // As far as the parser is concerned, the position is now == target. In reality the
183 183
   // motion control system might still be processing the action and the real tool position

+ 2
- 2
Marlin/src/gcode/motion/G5.cpp 查看文件

@@ -27,7 +27,7 @@
27 27
 #include "../../module/motion.h"
28 28
 #include "../../module/planner_bezier.h"
29 29
 
30
-void plan_cubic_move(const float offset[4]) {
30
+void plan_cubic_move(const float (&offset)[4]) {
31 31
   cubic_b_spline(current_position, destination, offset, MMS_SCALED(feedrate_mm_s), active_extruder);
32 32
 
33 33
   // As far as the parser is concerned, the position is now == destination. In reality the
@@ -62,7 +62,7 @@ void GcodeSuite::G5() {
62 62
 
63 63
     get_destination_from_command();
64 64
 
65
-    const float offset[] = {
65
+    const float offset[4] = {
66 66
       parser.linearval('I'),
67 67
       parser.linearval('J'),
68 68
       parser.linearval('P'),

+ 7
- 1
Marlin/src/module/motion.cpp 查看文件

@@ -517,13 +517,19 @@ float soft_endstop_min[XYZ] = { X_MIN_BED, Y_MIN_BED, Z_MIN_POS },
517 517
   /**
518 518
    * Prepare a linear move in a DELTA or SCARA setup.
519 519
    *
520
+   * Called from prepare_move_to_destination as the
521
+   * default Delta/SCARA segmenter.
522
+   *
520 523
    * This calls planner.buffer_line several times, adding
521 524
    * small incremental moves for DELTA or SCARA.
522 525
    *
523 526
    * For Unified Bed Leveling (Delta or Segmented Cartesian)
524 527
    * the ubl.prepare_segmented_line_to method replaces this.
528
+   *
529
+   * For Auto Bed Leveling (Bilinear) with SEGMENT_LEVELED_MOVES
530
+   * this is replaced by segmented_line_to_destination below.
525 531
    */
526
-  inline bool prepare_kinematic_move_to(float rtarget[XYZE]) {
532
+  inline bool prepare_kinematic_move_to(const float (&rtarget)[XYZE]) {
527 533
 
528 534
     // Get the top feedrate of the move in the XY plane
529 535
     const float _feedrate_mm_s = MMS_SCALED(feedrate_mm_s);

+ 7
- 7
Marlin/src/module/planner.cpp 查看文件

@@ -1466,18 +1466,18 @@ void Planner::_set_position_mm(const float &a, const float &b, const float &c, c
1466 1466
   ZERO(previous_speed);
1467 1467
 }
1468 1468
 
1469
-void Planner::set_position_mm_kinematic(const float position[NUM_AXIS]) {
1469
+void Planner::set_position_mm_kinematic(const float (&cart)[XYZE]) {
1470 1470
   #if PLANNER_LEVELING
1471
-    float lpos[XYZ] = { position[X_AXIS], position[Y_AXIS], position[Z_AXIS] };
1472
-    apply_leveling(lpos);
1471
+    float raw[XYZ] = { cart[X_AXIS], cart[Y_AXIS], cart[Z_AXIS] };
1472
+    apply_leveling(raw);
1473 1473
   #else
1474
-    const float * const lpos = position;
1474
+    const float (&raw)[XYZE] = cart;
1475 1475
   #endif
1476 1476
   #if IS_KINEMATIC
1477
-    inverse_kinematics(lpos);
1478
-    _set_position_mm(delta[A_AXIS], delta[B_AXIS], delta[C_AXIS], position[E_AXIS]);
1477
+    inverse_kinematics(raw);
1478
+    _set_position_mm(delta[A_AXIS], delta[B_AXIS], delta[C_AXIS], cart[E_AXIS]);
1479 1479
   #else
1480
-    _set_position_mm(lpos[X_AXIS], lpos[Y_AXIS], lpos[Z_AXIS], position[E_AXIS]);
1480
+    _set_position_mm(raw[X_AXIS], raw[Y_AXIS], raw[Z_AXIS], cart[E_AXIS]);
1481 1481
   #endif
1482 1482
 }
1483 1483
 

+ 4
- 4
Marlin/src/module/planner.h 查看文件

@@ -356,7 +356,7 @@ class Planner {
356 356
        * as it will be given to the planner and steppers.
357 357
        */
358 358
       static void apply_leveling(float &rx, float &ry, float &rz);
359
-      static void apply_leveling(float raw[XYZ]) { apply_leveling(raw[X_AXIS], raw[Y_AXIS], raw[Z_AXIS]); }
359
+      static void apply_leveling(float (&raw)[XYZ]) { apply_leveling(raw[X_AXIS], raw[Y_AXIS], raw[Z_AXIS]); }
360 360
       static void unapply_leveling(float raw[XYZ]);
361 361
 
362 362
     #else
@@ -421,12 +421,12 @@ class Planner {
421 421
      *  fr_mm_s  - (target) speed of the move (mm/s)
422 422
      *  extruder - target extruder
423 423
      */
424
-    FORCE_INLINE static void buffer_line_kinematic(const float cart[XYZE], const float &fr_mm_s, const uint8_t extruder) {
424
+    FORCE_INLINE static void buffer_line_kinematic(const float (&cart)[XYZE], const float &fr_mm_s, const uint8_t extruder) {
425 425
       #if PLANNER_LEVELING
426 426
         float raw[XYZ] = { cart[X_AXIS], cart[Y_AXIS], cart[Z_AXIS] };
427 427
         apply_leveling(raw);
428 428
       #else
429
-        const float * const raw = cart;
429
+        const float (&raw)[XYZE] = cart;
430 430
       #endif
431 431
       #if IS_KINEMATIC
432 432
         inverse_kinematics(raw);
@@ -451,7 +451,7 @@ class Planner {
451 451
       #endif
452 452
       _set_position_mm(rx, ry, rz, e);
453 453
     }
454
-    static void set_position_mm_kinematic(const float position[NUM_AXIS]);
454
+    static void set_position_mm_kinematic(const float (&cart)[XYZE]);
455 455
     static void set_position_mm(const AxisEnum axis, const float &v);
456 456
     FORCE_INLINE static void set_z_position_mm(const float &z) { set_position_mm(Z_AXIS, z); }
457 457
     FORCE_INLINE static void set_e_position_mm(const float &e) { set_position_mm(AxisEnum(E_AXIS), e); }

+ 1
- 1
Marlin/src/module/probe.cpp 查看文件

@@ -107,7 +107,7 @@ inline void do_probe_raise(const float z_raise) {
107 107
 
108 108
 #elif ENABLED(Z_PROBE_ALLEN_KEY)
109 109
 
110
-  FORCE_INLINE void do_blocking_move_to(const float raw[XYZ], const float &fr_mm_s) {
110
+  FORCE_INLINE void do_blocking_move_to(const float (&raw)[XYZ], const float &fr_mm_s) {
111 111
     do_blocking_move_to(raw[X_AXIS], raw[Y_AXIS], raw[Z_AXIS], fr_mm_s);
112 112
   }
113 113
 

+ 3
- 3
Marlin/src/module/stepper.cpp 查看文件

@@ -1193,7 +1193,7 @@ void Stepper::set_e_position(const long &e) {
1193 1193
 /**
1194 1194
  * Get a stepper's position in steps.
1195 1195
  */
1196
-long Stepper::position(AxisEnum axis) {
1196
+long Stepper::position(const AxisEnum axis) {
1197 1197
   CRITICAL_SECTION_START;
1198 1198
   const long count_pos = count_position[axis];
1199 1199
   CRITICAL_SECTION_END;
@@ -1204,7 +1204,7 @@ long Stepper::position(AxisEnum axis) {
1204 1204
  * Get an axis position according to stepper position(s)
1205 1205
  * For CORE machines apply translation from ABC to XYZ.
1206 1206
  */
1207
-float Stepper::get_axis_position_mm(AxisEnum axis) {
1207
+float Stepper::get_axis_position_mm(const AxisEnum axis) {
1208 1208
   float axis_steps;
1209 1209
   #if IS_CORE
1210 1210
     // Requesting one of the "core" axes?
@@ -1242,7 +1242,7 @@ void Stepper::quick_stop() {
1242 1242
   #endif
1243 1243
 }
1244 1244
 
1245
-void Stepper::endstop_triggered(AxisEnum axis) {
1245
+void Stepper::endstop_triggered(const AxisEnum axis) {
1246 1246
 
1247 1247
   #if IS_CORE
1248 1248
 

+ 6
- 6
Marlin/src/module/stepper.h 查看文件

@@ -183,7 +183,7 @@ class Stepper {
183 183
     //
184 184
     // Get the position of a stepper, in steps
185 185
     //
186
-    static long position(AxisEnum axis);
186
+    static long position(const AxisEnum axis);
187 187
 
188 188
     //
189 189
     // Report the positions of the steppers, in steps
@@ -193,13 +193,13 @@ class Stepper {
193 193
     //
194 194
     // Get the position (mm) of an axis based on stepper position(s)
195 195
     //
196
-    static float get_axis_position_mm(AxisEnum axis);
196
+    static float get_axis_position_mm(const AxisEnum axis);
197 197
 
198 198
     //
199 199
     // SCARA AB axes are in degrees, not mm
200 200
     //
201 201
     #if IS_SCARA
202
-      FORCE_INLINE static float get_axis_position_degrees(AxisEnum axis) { return get_axis_position_mm(axis); }
202
+      FORCE_INLINE static float get_axis_position_degrees(const AxisEnum axis) { return get_axis_position_mm(axis); }
203 203
     #endif
204 204
 
205 205
     //
@@ -221,7 +221,7 @@ class Stepper {
221 221
     //
222 222
     // The direction of a single motor
223 223
     //
224
-    FORCE_INLINE static bool motor_direction(AxisEnum axis) { return TEST(last_direction_bits, axis); }
224
+    FORCE_INLINE static bool motor_direction(const AxisEnum axis) { return TEST(last_direction_bits, axis); }
225 225
 
226 226
     #if HAS_DIGIPOTSS || HAS_MOTOR_CURRENT_PWM
227 227
       static void digitalPotWrite(const int16_t address, const int16_t value);
@@ -263,12 +263,12 @@ class Stepper {
263 263
     //
264 264
     // Handle a triggered endstop
265 265
     //
266
-    static void endstop_triggered(AxisEnum axis);
266
+    static void endstop_triggered(const AxisEnum axis);
267 267
 
268 268
     //
269 269
     // Triggered position of an axis in mm (not core-savvy)
270 270
     //
271
-    FORCE_INLINE static float triggered_position_mm(AxisEnum axis) {
271
+    FORCE_INLINE static float triggered_position_mm(const AxisEnum axis) {
272 272
       return endstops_trigsteps[axis] * planner.steps_to_mm[axis];
273 273
     }
274 274
 

Loading…
取消
儲存