Przeglądaj źródła

Apply const to axis args

Scott Lahteine 6 lat temu
rodzic
commit
bb33a26e62
5 zmienionych plików z 11 dodań i 11 usunięć
  1. 1
    1
      Marlin/Marlin_main.cpp
  2. 2
    2
      Marlin/stepper.cpp
  3. 6
    6
      Marlin/stepper.h
  4. 1
    1
      Marlin/stepper_dac.cpp
  5. 1
    1
      Marlin/stepper_dac.h

+ 1
- 1
Marlin/Marlin_main.cpp Wyświetl plik

@@ -706,7 +706,7 @@ FORCE_INLINE signed char pgm_read_any(const signed char *p) { return pgm_read_by
706 706
 
707 707
 #define XYZ_CONSTS_FROM_CONFIG(type, array, CONFIG) \
708 708
   static const PROGMEM type array##_P[XYZ] = { X_##CONFIG, Y_##CONFIG, Z_##CONFIG }; \
709
-  static inline type array(AxisEnum axis) { return pgm_read_any(&array##_P[axis]); } \
709
+  static inline type array(const AxisEnum axis) { return pgm_read_any(&array##_P[axis]); } \
710 710
   typedef void __void_##CONFIG##__
711 711
 
712 712
 XYZ_CONSTS_FROM_CONFIG(float, base_min_pos,   MIN_POS);

+ 2
- 2
Marlin/stepper.cpp Wyświetl plik

@@ -1198,7 +1198,7 @@ void Stepper::set_e_position(const long &e) {
1198 1198
 /**
1199 1199
  * Get a stepper's position in steps.
1200 1200
  */
1201
-long Stepper::position(AxisEnum axis) {
1201
+long Stepper::position(const AxisEnum axis) {
1202 1202
   CRITICAL_SECTION_START;
1203 1203
   const long count_pos = count_position[axis];
1204 1204
   CRITICAL_SECTION_END;
@@ -1209,7 +1209,7 @@ long Stepper::position(AxisEnum axis) {
1209 1209
  * Get an axis position according to stepper position(s)
1210 1210
  * For CORE machines apply translation from ABC to XYZ.
1211 1211
  */
1212
-float Stepper::get_axis_position_mm(AxisEnum axis) {
1212
+float Stepper::get_axis_position_mm(const AxisEnum axis) {
1213 1213
   float axis_steps;
1214 1214
   #if IS_CORE
1215 1215
     // Requesting one of the "core" axes?

+ 6
- 6
Marlin/stepper.h Wyświetl plik

@@ -209,7 +209,7 @@ class Stepper {
209 209
     //
210 210
     // Get the position of a stepper, in steps
211 211
     //
212
-    static long position(AxisEnum axis);
212
+    static long position(const AxisEnum axis);
213 213
 
214 214
     //
215 215
     // Report the positions of the steppers, in steps
@@ -219,13 +219,13 @@ class Stepper {
219 219
     //
220 220
     // Get the position (mm) of an axis based on stepper position(s)
221 221
     //
222
-    static float get_axis_position_mm(AxisEnum axis);
222
+    static float get_axis_position_mm(const AxisEnum axis);
223 223
 
224 224
     //
225 225
     // SCARA AB axes are in degrees, not mm
226 226
     //
227 227
     #if IS_SCARA
228
-      FORCE_INLINE static float get_axis_position_degrees(AxisEnum axis) { return get_axis_position_mm(axis); }
228
+      FORCE_INLINE static float get_axis_position_degrees(const AxisEnum axis) { return get_axis_position_mm(axis); }
229 229
     #endif
230 230
 
231 231
     //
@@ -247,7 +247,7 @@ class Stepper {
247 247
     //
248 248
     // The direction of a single motor
249 249
     //
250
-    FORCE_INLINE static bool motor_direction(AxisEnum axis) { return TEST(last_direction_bits, axis); }
250
+    FORCE_INLINE static bool motor_direction(const AxisEnum axis) { return TEST(last_direction_bits, axis); }
251 251
 
252 252
     #if HAS_DIGIPOTSS || HAS_MOTOR_CURRENT_PWM
253 253
       static void digitalPotWrite(const int16_t address, const int16_t value);
@@ -287,12 +287,12 @@ class Stepper {
287 287
     //
288 288
     // Handle a triggered endstop
289 289
     //
290
-    static void endstop_triggered(AxisEnum axis);
290
+    static void endstop_triggered(const AxisEnum axis);
291 291
 
292 292
     //
293 293
     // Triggered position of an axis in mm (not core-savvy)
294 294
     //
295
-    FORCE_INLINE static float triggered_position_mm(AxisEnum axis) {
295
+    FORCE_INLINE static float triggered_position_mm(const AxisEnum axis) {
296 296
       return endstops_trigsteps[axis] * planner.steps_to_mm[axis];
297 297
     }
298 298
 

+ 1
- 1
Marlin/stepper_dac.cpp Wyświetl plik

@@ -94,7 +94,7 @@
94 94
   static float dac_perc(int8_t n) { return 100.0 * mcp4728_getValue(dac_order[n]) * (1.0 / (DAC_STEPPER_MAX)); }
95 95
   static float dac_amps(int8_t n) { return mcp4728_getDrvPct(dac_order[n]) * (DAC_STEPPER_MAX) * 0.125 * (1.0 / (DAC_STEPPER_SENSE)); }
96 96
 
97
-  uint8_t dac_current_get_percent(AxisEnum axis) { return mcp4728_getDrvPct(dac_order[axis]); }
97
+  uint8_t dac_current_get_percent(const AxisEnum axis) { return mcp4728_getDrvPct(dac_order[axis]); }
98 98
   void dac_current_set_percents(const uint8_t pct[XYZE]) {
99 99
     LOOP_XYZE(i) dac_channel_pct[i] = pct[dac_order[i]];
100 100
     mcp4728_setDrvPct(dac_channel_pct);

+ 1
- 1
Marlin/stepper_dac.h Wyświetl plik

@@ -51,7 +51,7 @@ void dac_current_percent(uint8_t channel, float val);
51 51
 void dac_current_raw(uint8_t channel, uint16_t val);
52 52
 void dac_print_values();
53 53
 void dac_commit_eeprom();
54
-uint8_t dac_current_get_percent(AxisEnum axis);
54
+uint8_t dac_current_get_percent(const AxisEnum axis);
55 55
 void dac_current_set_percents(const uint8_t pct[XYZE]);
56 56
 
57 57
 #endif // STEPPER_DAC_H

Ładowanie…
Anuluj
Zapisz