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.
pull/1/head
esenapaj 9 years ago
committed by esenapaj
parent
commit
605808fe37
  1. 34
      Marlin/Marlin_main.cpp
  2. 4
      Marlin/endstops.cpp
  3. 2
      Marlin/stepper.h
  4. 2
      Marlin/ultralcd.cpp

34
Marlin/Marlin_main.cpp

@ -5933,7 +5933,7 @@ inline void gcode_M503() {
* M540: Set whether SD card print should abort on endstop hit (M540 S<0|1>)
*/
inline void gcode_M540() {
if (code_seen('S')) abort_on_endstop_hit = (code_value() > 0);
if (code_seen('S')) stepper.abort_on_endstop_hit = (code_value() > 0);
}
#endif // ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED
@ -6166,18 +6166,18 @@ inline void gcode_M503() {
inline void gcode_M907() {
#if HAS_DIGIPOTSS
for (int i = 0; i < NUM_AXIS; i++)
if (code_seen(axis_codes[i])) digipot_current(i, code_value());
if (code_seen('B')) digipot_current(4, code_value());
if (code_seen('S')) for (int i = 0; i <= 4; i++) digipot_current(i, code_value());
if (code_seen(axis_codes[i])) stepper.digipot_current(i, code_value());
if (code_seen('B')) stepper.digipot_current(4, code_value());
if (code_seen('S')) for (int i = 0; i <= 4; i++) stepper.digipot_current(i, code_value());
#endif
#if PIN_EXISTS(MOTOR_CURRENT_PWM_XY)
if (code_seen('X')) digipot_current(0, code_value());
if (code_seen('X')) stepper.digipot_current(0, code_value());
#endif
#if PIN_EXISTS(MOTOR_CURRENT_PWM_Z)
if (code_seen('Z')) digipot_current(1, code_value());
if (code_seen('Z')) stepper.digipot_current(1, code_value());
#endif
#if PIN_EXISTS(MOTOR_CURRENT_PWM_E)
if (code_seen('E')) digipot_current(2, code_value());
if (code_seen('E')) stepper.digipot_current(2, code_value());
#endif
#if ENABLED(DIGIPOT_I2C)
// this one uses actual amps in floating point
@ -6201,7 +6201,7 @@ inline void gcode_M907() {
*/
inline void gcode_M908() {
#if HAS_DIGIPOTSS
digitalPotWrite(
stepper.digitalPotWrite(
code_seen('P') ? code_value() : 0,
code_seen('S') ? code_value() : 0
);
@ -6228,10 +6228,10 @@ inline void gcode_M907() {
// M350 Set microstepping mode. Warning: Steps per unit remains unchanged. S code sets stepping mode for all drivers.
inline void gcode_M350() {
if (code_seen('S')) for (int i = 0; i <= 4; i++) microstep_mode(i, code_value());
for (int i = 0; i < NUM_AXIS; i++) if (code_seen(axis_codes[i])) microstep_mode(i, (uint8_t)code_value());
if (code_seen('B')) microstep_mode(4, code_value());
microstep_readings();
if (code_seen('S')) for (int i = 0; i <= 4; i++) stepper.microstep_mode(i, code_value());
for (int i = 0; i < NUM_AXIS; i++) if (code_seen(axis_codes[i])) stepper.microstep_mode(i, (uint8_t)code_value());
if (code_seen('B')) stepper.microstep_mode(4, code_value());
stepper.microstep_readings();
}
/**
@ -6241,15 +6241,15 @@ inline void gcode_M907() {
inline void gcode_M351() {
if (code_seen('S')) switch (code_value_short()) {
case 1:
for (int i = 0; i < NUM_AXIS; i++) if (code_seen(axis_codes[i])) microstep_ms(i, code_value(), -1);
if (code_seen('B')) microstep_ms(4, code_value(), -1);
for (int i = 0; i < NUM_AXIS; i++) if (code_seen(axis_codes[i])) stepper.microstep_ms(i, code_value(), -1);
if (code_seen('B')) stepper.microstep_ms(4, code_value(), -1);
break;
case 2:
for (int i = 0; i < NUM_AXIS; i++) if (code_seen(axis_codes[i])) microstep_ms(i, -1, code_value());
if (code_seen('B')) microstep_ms(4, -1, code_value());
for (int i = 0; i < NUM_AXIS; i++) if (code_seen(axis_codes[i])) stepper.microstep_ms(i, -1, code_value());
if (code_seen('B')) stepper.microstep_ms(4, -1, code_value());
break;
}
microstep_readings();
stepper.microstep_readings();
}
#endif // HAS_MICROSTEPS

4
Marlin/endstops.cpp

@ -25,7 +25,9 @@
*/
#include "Marlin.h"
#include "cardreader.h"
#include "endstops.h"
#include "temperature.h"
#include "stepper.h"
#include "ultralcd.h"
@ -147,7 +149,7 @@ void Endstops::report_state() {
hit_on_purpose();
#if ENABLED(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED) && ENABLED(SDSUPPORT)
if (abort_on_endstop_hit) {
if (stepper.abort_on_endstop_hit) {
card.sdprinting = false;
card.closefile();
stepper.quick_stop();

2
Marlin/stepper.h

@ -220,6 +220,7 @@ class Stepper {
#endif
void microstep_ms(uint8_t driver, int8_t ms1, int8_t ms2);
void digipot_current(uint8_t driver, int current);
void microstep_mode(uint8_t driver, uint8_t stepping);
void microstep_readings();
#if ENABLED(Z_DUAL_ENDSTOPS)
@ -324,7 +325,6 @@ class Stepper {
}
private:
void microstep_mode(uint8_t driver, uint8_t stepping);
void digipot_init();
void microstep_init();

2
Marlin/ultralcd.cpp

@ -1674,7 +1674,7 @@ static void lcd_control_motion_menu() {
#endif
MENU_ITEM_EDIT(float51, MSG_ESTEPS, &planner.axis_steps_per_unit[E_AXIS], 5, 9999);
#if ENABLED(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED)
MENU_ITEM_EDIT(bool, MSG_ENDSTOP_ABORT, &abort_on_endstop_hit);
MENU_ITEM_EDIT(bool, MSG_ENDSTOP_ABORT, &stepper.abort_on_endstop_hit);
#endif
#if ENABLED(SCARA)
MENU_ITEM_EDIT(float74, MSG_XSCALE, &axis_scaling[X_AXIS], 0.5, 2);

Loading…
Cancel
Save