Browse Source

Apply const to axis args

Scott Lahteine 7 years ago
parent
commit
bb33a26e62
5 changed files with 11 additions and 11 deletions
  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 View File

706
 
706
 
707
 #define XYZ_CONSTS_FROM_CONFIG(type, array, CONFIG) \
707
 #define XYZ_CONSTS_FROM_CONFIG(type, array, CONFIG) \
708
   static const PROGMEM type array##_P[XYZ] = { X_##CONFIG, Y_##CONFIG, Z_##CONFIG }; \
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
   typedef void __void_##CONFIG##__
710
   typedef void __void_##CONFIG##__
711
 
711
 
712
 XYZ_CONSTS_FROM_CONFIG(float, base_min_pos,   MIN_POS);
712
 XYZ_CONSTS_FROM_CONFIG(float, base_min_pos,   MIN_POS);

+ 2
- 2
Marlin/stepper.cpp View File

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

+ 6
- 6
Marlin/stepper.h View File

209
     //
209
     //
210
     // Get the position of a stepper, in steps
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
     // Report the positions of the steppers, in steps
215
     // Report the positions of the steppers, in steps
219
     //
219
     //
220
     // Get the position (mm) of an axis based on stepper position(s)
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
     // SCARA AB axes are in degrees, not mm
225
     // SCARA AB axes are in degrees, not mm
226
     //
226
     //
227
     #if IS_SCARA
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
     #endif
229
     #endif
230
 
230
 
231
     //
231
     //
247
     //
247
     //
248
     // The direction of a single motor
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
     #if HAS_DIGIPOTSS || HAS_MOTOR_CURRENT_PWM
252
     #if HAS_DIGIPOTSS || HAS_MOTOR_CURRENT_PWM
253
       static void digitalPotWrite(const int16_t address, const int16_t value);
253
       static void digitalPotWrite(const int16_t address, const int16_t value);
287
     //
287
     //
288
     // Handle a triggered endstop
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
     // Triggered position of an axis in mm (not core-savvy)
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
       return endstops_trigsteps[axis] * planner.steps_to_mm[axis];
296
       return endstops_trigsteps[axis] * planner.steps_to_mm[axis];
297
     }
297
     }
298
 
298
 

+ 1
- 1
Marlin/stepper_dac.cpp View File

94
   static float dac_perc(int8_t n) { return 100.0 * mcp4728_getValue(dac_order[n]) * (1.0 / (DAC_STEPPER_MAX)); }
94
   static float dac_perc(int8_t n) { return 100.0 * mcp4728_getValue(dac_order[n]) * (1.0 / (DAC_STEPPER_MAX)); }
95
   static float dac_amps(int8_t n) { return mcp4728_getDrvPct(dac_order[n]) * (DAC_STEPPER_MAX) * 0.125 * (1.0 / (DAC_STEPPER_SENSE)); }
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
   void dac_current_set_percents(const uint8_t pct[XYZE]) {
98
   void dac_current_set_percents(const uint8_t pct[XYZE]) {
99
     LOOP_XYZE(i) dac_channel_pct[i] = pct[dac_order[i]];
99
     LOOP_XYZE(i) dac_channel_pct[i] = pct[dac_order[i]];
100
     mcp4728_setDrvPct(dac_channel_pct);
100
     mcp4728_setDrvPct(dac_channel_pct);

+ 1
- 1
Marlin/stepper_dac.h View File

51
 void dac_current_raw(uint8_t channel, uint16_t val);
51
 void dac_current_raw(uint8_t channel, uint16_t val);
52
 void dac_print_values();
52
 void dac_print_values();
53
 void dac_commit_eeprom();
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
 void dac_current_set_percents(const uint8_t pct[XYZE]);
55
 void dac_current_set_percents(const uint8_t pct[XYZE]);
56
 
56
 
57
 #endif // STEPPER_DAC_H
57
 #endif // STEPPER_DAC_H

Loading…
Cancel
Save