Browse Source

Additional follow-up the PR #3631(Encapsulate S...

Additional follow-up the PR #3631(Encapsulate Stepper, Planner, Endstops in singleton classes)

・Change from abort_on_endstop_hit to stepper.abort_on_endstop_hit in endstop.cpp, Marlin_main.cpp, and ultralcd.cpp
・Add include path to cardreader.h and temperature.h in endstop.cpp(for CardReader class and disable_all_heaters())
It fix compilation error when ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED and SDSUPPORT are enabled.

・Change from digipot_current() to stepper.digipot_current() in Marlin_main.cpp
・Change from digitalPotWrite() to stepper.digitalPotWrite() in Marlin_main.cpp
It fix compilation errors when HAS_DIGIPOTSS is enabled.

・Change from microstep_mode() to stepper.microstep_mode() in Marlin_main.cpp
・Change attribute of microstep_mode() from private to public in stepper.h
・Change from microstep_readings() to stepper.microstep_readings() in Marlin_main.cpp
・Change from microstep_ms() to stepper.microstep_ms() in Marlin_main.
It fix compilation errors when HAS_MICROSTEPS is enabled.
esenapaj 8 years ago
parent
commit
605808fe37
4 changed files with 22 additions and 20 deletions
  1. 17
    17
      Marlin/Marlin_main.cpp
  2. 3
    1
      Marlin/endstops.cpp
  3. 1
    1
      Marlin/stepper.h
  4. 1
    1
      Marlin/ultralcd.cpp

+ 17
- 17
Marlin/Marlin_main.cpp View File

5933
    * M540: Set whether SD card print should abort on endstop hit (M540 S<0|1>)
5933
    * M540: Set whether SD card print should abort on endstop hit (M540 S<0|1>)
5934
    */
5934
    */
5935
   inline void gcode_M540() {
5935
   inline void gcode_M540() {
5936
-    if (code_seen('S')) abort_on_endstop_hit = (code_value() > 0);
5936
+    if (code_seen('S')) stepper.abort_on_endstop_hit = (code_value() > 0);
5937
   }
5937
   }
5938
 
5938
 
5939
 #endif // ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED
5939
 #endif // ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED
6166
 inline void gcode_M907() {
6166
 inline void gcode_M907() {
6167
   #if HAS_DIGIPOTSS
6167
   #if HAS_DIGIPOTSS
6168
     for (int i = 0; i < NUM_AXIS; i++)
6168
     for (int i = 0; i < NUM_AXIS; i++)
6169
-      if (code_seen(axis_codes[i])) digipot_current(i, code_value());
6170
-    if (code_seen('B')) digipot_current(4, code_value());
6171
-    if (code_seen('S')) for (int i = 0; i <= 4; i++) digipot_current(i, code_value());
6169
+      if (code_seen(axis_codes[i])) stepper.digipot_current(i, code_value());
6170
+    if (code_seen('B')) stepper.digipot_current(4, code_value());
6171
+    if (code_seen('S')) for (int i = 0; i <= 4; i++) stepper.digipot_current(i, code_value());
6172
   #endif
6172
   #endif
6173
   #if PIN_EXISTS(MOTOR_CURRENT_PWM_XY)
6173
   #if PIN_EXISTS(MOTOR_CURRENT_PWM_XY)
6174
-    if (code_seen('X')) digipot_current(0, code_value());
6174
+    if (code_seen('X')) stepper.digipot_current(0, code_value());
6175
   #endif
6175
   #endif
6176
   #if PIN_EXISTS(MOTOR_CURRENT_PWM_Z)
6176
   #if PIN_EXISTS(MOTOR_CURRENT_PWM_Z)
6177
-    if (code_seen('Z')) digipot_current(1, code_value());
6177
+    if (code_seen('Z')) stepper.digipot_current(1, code_value());
6178
   #endif
6178
   #endif
6179
   #if PIN_EXISTS(MOTOR_CURRENT_PWM_E)
6179
   #if PIN_EXISTS(MOTOR_CURRENT_PWM_E)
6180
-    if (code_seen('E')) digipot_current(2, code_value());
6180
+    if (code_seen('E')) stepper.digipot_current(2, code_value());
6181
   #endif
6181
   #endif
6182
   #if ENABLED(DIGIPOT_I2C)
6182
   #if ENABLED(DIGIPOT_I2C)
6183
     // this one uses actual amps in floating point
6183
     // this one uses actual amps in floating point
6201
    */
6201
    */
6202
   inline void gcode_M908() {
6202
   inline void gcode_M908() {
6203
     #if HAS_DIGIPOTSS
6203
     #if HAS_DIGIPOTSS
6204
-      digitalPotWrite(
6204
+      stepper.digitalPotWrite(
6205
         code_seen('P') ? code_value() : 0,
6205
         code_seen('P') ? code_value() : 0,
6206
         code_seen('S') ? code_value() : 0
6206
         code_seen('S') ? code_value() : 0
6207
       );
6207
       );
6228
 
6228
 
6229
   // M350 Set microstepping mode. Warning: Steps per unit remains unchanged. S code sets stepping mode for all drivers.
6229
   // M350 Set microstepping mode. Warning: Steps per unit remains unchanged. S code sets stepping mode for all drivers.
6230
   inline void gcode_M350() {
6230
   inline void gcode_M350() {
6231
-    if (code_seen('S')) for (int i = 0; i <= 4; i++) microstep_mode(i, code_value());
6232
-    for (int i = 0; i < NUM_AXIS; i++) if (code_seen(axis_codes[i])) microstep_mode(i, (uint8_t)code_value());
6233
-    if (code_seen('B')) microstep_mode(4, code_value());
6234
-    microstep_readings();
6231
+    if (code_seen('S')) for (int i = 0; i <= 4; i++) stepper.microstep_mode(i, code_value());
6232
+    for (int i = 0; i < NUM_AXIS; i++) if (code_seen(axis_codes[i])) stepper.microstep_mode(i, (uint8_t)code_value());
6233
+    if (code_seen('B')) stepper.microstep_mode(4, code_value());
6234
+    stepper.microstep_readings();
6235
   }
6235
   }
6236
 
6236
 
6237
   /**
6237
   /**
6241
   inline void gcode_M351() {
6241
   inline void gcode_M351() {
6242
     if (code_seen('S')) switch (code_value_short()) {
6242
     if (code_seen('S')) switch (code_value_short()) {
6243
       case 1:
6243
       case 1:
6244
-        for (int i = 0; i < NUM_AXIS; i++) if (code_seen(axis_codes[i])) microstep_ms(i, code_value(), -1);
6245
-        if (code_seen('B')) microstep_ms(4, code_value(), -1);
6244
+        for (int i = 0; i < NUM_AXIS; i++) if (code_seen(axis_codes[i])) stepper.microstep_ms(i, code_value(), -1);
6245
+        if (code_seen('B')) stepper.microstep_ms(4, code_value(), -1);
6246
         break;
6246
         break;
6247
       case 2:
6247
       case 2:
6248
-        for (int i = 0; i < NUM_AXIS; i++) if (code_seen(axis_codes[i])) microstep_ms(i, -1, code_value());
6249
-        if (code_seen('B')) microstep_ms(4, -1, code_value());
6248
+        for (int i = 0; i < NUM_AXIS; i++) if (code_seen(axis_codes[i])) stepper.microstep_ms(i, -1, code_value());
6249
+        if (code_seen('B')) stepper.microstep_ms(4, -1, code_value());
6250
         break;
6250
         break;
6251
     }
6251
     }
6252
-    microstep_readings();
6252
+    stepper.microstep_readings();
6253
   }
6253
   }
6254
 
6254
 
6255
 #endif // HAS_MICROSTEPS
6255
 #endif // HAS_MICROSTEPS

+ 3
- 1
Marlin/endstops.cpp View File

25
  */
25
  */
26
 
26
 
27
 #include "Marlin.h"
27
 #include "Marlin.h"
28
+#include "cardreader.h"
28
 #include "endstops.h"
29
 #include "endstops.h"
30
+#include "temperature.h"
29
 #include "stepper.h"
31
 #include "stepper.h"
30
 #include "ultralcd.h"
32
 #include "ultralcd.h"
31
 
33
 
147
     hit_on_purpose();
149
     hit_on_purpose();
148
 
150
 
149
     #if ENABLED(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED) && ENABLED(SDSUPPORT)
151
     #if ENABLED(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED) && ENABLED(SDSUPPORT)
150
-      if (abort_on_endstop_hit) {
152
+      if (stepper.abort_on_endstop_hit) {
151
         card.sdprinting = false;
153
         card.sdprinting = false;
152
         card.closefile();
154
         card.closefile();
153
         stepper.quick_stop();
155
         stepper.quick_stop();

+ 1
- 1
Marlin/stepper.h View File

220
     #endif
220
     #endif
221
     void microstep_ms(uint8_t driver, int8_t ms1, int8_t ms2);
221
     void microstep_ms(uint8_t driver, int8_t ms1, int8_t ms2);
222
     void digipot_current(uint8_t driver, int current);
222
     void digipot_current(uint8_t driver, int current);
223
+    void microstep_mode(uint8_t driver, uint8_t stepping);
223
     void microstep_readings();
224
     void microstep_readings();
224
 
225
 
225
     #if ENABLED(Z_DUAL_ENDSTOPS)
226
     #if ENABLED(Z_DUAL_ENDSTOPS)
324
     }
325
     }
325
 
326
 
326
   private:
327
   private:
327
-    void microstep_mode(uint8_t driver, uint8_t stepping);
328
     void digipot_init();
328
     void digipot_init();
329
     void microstep_init();
329
     void microstep_init();
330
 
330
 

+ 1
- 1
Marlin/ultralcd.cpp View File

1674
   #endif
1674
   #endif
1675
   MENU_ITEM_EDIT(float51, MSG_ESTEPS, &planner.axis_steps_per_unit[E_AXIS], 5, 9999);
1675
   MENU_ITEM_EDIT(float51, MSG_ESTEPS, &planner.axis_steps_per_unit[E_AXIS], 5, 9999);
1676
   #if ENABLED(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED)
1676
   #if ENABLED(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED)
1677
-    MENU_ITEM_EDIT(bool, MSG_ENDSTOP_ABORT, &abort_on_endstop_hit);
1677
+    MENU_ITEM_EDIT(bool, MSG_ENDSTOP_ABORT, &stepper.abort_on_endstop_hit);
1678
   #endif
1678
   #endif
1679
   #if ENABLED(SCARA)
1679
   #if ENABLED(SCARA)
1680
     MENU_ITEM_EDIT(float74, MSG_XSCALE, &axis_scaling[X_AXIS], 0.5, 2);
1680
     MENU_ITEM_EDIT(float74, MSG_XSCALE, &axis_scaling[X_AXIS], 0.5, 2);

Loading…
Cancel
Save