home: use some helper macros

like the heater.
This commit is contained in:
Nico Tonnhofer 2019-01-14 22:22:01 +01:00
parent 86123f80f7
commit e4896a1257
8 changed files with 46 additions and 70 deletions

View File

@ -112,9 +112,8 @@
#define E_ABSOLUTE #define E_ABSOLUTE
/** \def HOMING_OPT /** \def HOMING_OPT
Options for homing movements a user should be able to choose from in configtool. All
Options for homing movements. 'none' means no movement at all. For each commented out.
option XXX, a function home_XXX() has to exist, typically in home.c/.h.
*/ */
//#define HOMING_OPT none //#define HOMING_OPT none
//#define HOMING_OPT x_negative //#define HOMING_OPT x_negative
@ -125,15 +124,10 @@
//#define HOMING_OPT z_positive //#define HOMING_OPT z_positive
/** \def DEFINE_HOMING /** \def DEFINE_HOMING
Order (and number) of homing movements. Up to 4 homing steps are allowed.
Order (and number) of homing movements. If you don't need even one axis just DEFINE_HOMING(none).
*/ */
#ifndef DEFINE_HOMING DEFINE_HOMING(x_negative, y_negative, z_negative)
#define DEFINE_HOMING(...)
#endif
//DEFINE_HOMING_START
DEFINE_HOMING(x_negative, y_negative, z_negative, none)
//DEFINE_HOMING_END
/** \def ACCELERATION_REPRAP ACCELERATION_RAMPING ACCELERATION_TEMPORAL /** \def ACCELERATION_REPRAP ACCELERATION_RAMPING ACCELERATION_TEMPORAL
Choose optionally one of ACCELERATION_REPRAP, ACCELERATION_RAMPING or Choose optionally one of ACCELERATION_REPRAP, ACCELERATION_RAMPING or

View File

@ -112,9 +112,8 @@
#define E_ABSOLUTE #define E_ABSOLUTE
/** \def HOMING_OPT /** \def HOMING_OPT
Options for homing movements a user should be able to choose from in configtool. All
Options for homing movements. 'none' means no movement at all. For each commented out.
option XXX, a function home_XXX() has to exist, typically in home.c/.h.
*/ */
//#define HOMING_OPT none //#define HOMING_OPT none
//#define HOMING_OPT x_negative //#define HOMING_OPT x_negative
@ -125,15 +124,10 @@
//#define HOMING_OPT z_positive //#define HOMING_OPT z_positive
/** \def DEFINE_HOMING /** \def DEFINE_HOMING
Order (and number) of homing movements. Up to 4 homing steps are allowed.
Order (and number) of homing movements. If you don't need even one axis just DEFINE_HOMING(none).
*/ */
#ifndef DEFINE_HOMING DEFINE_HOMING(x_negative, y_negative, z_negative)
#define DEFINE_HOMING(...)
#endif
//DEFINE_HOMING_START
DEFINE_HOMING(x_negative, y_negative, z_negative, none)
//DEFINE_HOMING_END
/** \def ACCELERATION_REPRAP ACCELERATION_RAMPING ACCELERATION_TEMPORAL /** \def ACCELERATION_REPRAP ACCELERATION_RAMPING ACCELERATION_TEMPORAL
Choose optionally one of ACCELERATION_REPRAP, ACCELERATION_RAMPING or Choose optionally one of ACCELERATION_REPRAP, ACCELERATION_RAMPING or

View File

@ -112,9 +112,8 @@
#define E_ABSOLUTE #define E_ABSOLUTE
/** \def HOMING_OPT /** \def HOMING_OPT
Options for homing movements a user should be able to choose from in configtool. All
Options for homing movements. 'none' means no movement at all. For each commented out.
option XXX, a function home_XXX() has to exist, typically in home.c/.h.
*/ */
//#define HOMING_OPT none //#define HOMING_OPT none
//#define HOMING_OPT x_negative //#define HOMING_OPT x_negative
@ -125,15 +124,10 @@
//#define HOMING_OPT z_positive //#define HOMING_OPT z_positive
/** \def DEFINE_HOMING /** \def DEFINE_HOMING
Order (and number) of homing movements. Up to 4 homing steps are allowed.
Order (and number) of homing movements. If you don't need even one axis just DEFINE_HOMING(none).
*/ */
#ifndef DEFINE_HOMING DEFINE_HOMING(z_negative, x_negative, y_negative)
#define DEFINE_HOMING(...)
#endif
//DEFINE_HOMING_START
DEFINE_HOMING(z_negative, x_negative, y_negative, none)
//DEFINE_HOMING_END
/** \def ACCELERATION_REPRAP ACCELERATION_RAMPING ACCELERATION_TEMPORAL /** \def ACCELERATION_REPRAP ACCELERATION_RAMPING ACCELERATION_TEMPORAL
Choose optionally one of ACCELERATION_REPRAP, ACCELERATION_RAMPING or Choose optionally one of ACCELERATION_REPRAP, ACCELERATION_RAMPING or

View File

@ -112,9 +112,8 @@
#define E_ABSOLUTE #define E_ABSOLUTE
/** \def HOMING_OPT /** \def HOMING_OPT
Options for homing movements a user should be able to choose from in configtool. All
Options for homing movements. 'none' means no movement at all. For each commented out.
option XXX, a function home_XXX() has to exist, typically in home.c/.h.
*/ */
//#define HOMING_OPT none //#define HOMING_OPT none
//#define HOMING_OPT x_negative //#define HOMING_OPT x_negative
@ -125,15 +124,10 @@
//#define HOMING_OPT z_positive //#define HOMING_OPT z_positive
/** \def DEFINE_HOMING /** \def DEFINE_HOMING
Order (and number) of homing movements. Up to 4 homing steps are allowed.
Order (and number) of homing movements. If you don't need even one axis just DEFINE_HOMING(none).
*/ */
#ifndef DEFINE_HOMING DEFINE_HOMING(x_negative, y_negative, z_negative)
#define DEFINE_HOMING(...)
#endif
//DEFINE_HOMING_START
DEFINE_HOMING(x_negative, y_negative, z_negative, none)
//DEFINE_HOMING_END
/** \def ACCELERATION_REPRAP ACCELERATION_RAMPING ACCELERATION_TEMPORAL /** \def ACCELERATION_REPRAP ACCELERATION_RAMPING ACCELERATION_TEMPORAL
Choose optionally one of ACCELERATION_REPRAP, ACCELERATION_RAMPING or Choose optionally one of ACCELERATION_REPRAP, ACCELERATION_RAMPING or

View File

@ -112,9 +112,8 @@
#define E_ABSOLUTE #define E_ABSOLUTE
/** \def HOMING_OPT /** \def HOMING_OPT
Options for homing movements a user should be able to choose from in configtool. All
Options for homing movements. 'none' means no movement at all. For each commented out.
option XXX, a function home_XXX() has to exist, typically in home.c/.h.
*/ */
//#define HOMING_OPT none //#define HOMING_OPT none
//#define HOMING_OPT x_negative //#define HOMING_OPT x_negative
@ -125,15 +124,10 @@
//#define HOMING_OPT z_positive //#define HOMING_OPT z_positive
/** \def DEFINE_HOMING /** \def DEFINE_HOMING
Order (and number) of homing movements. Up to 4 homing steps are allowed.
Order (and number) of homing movements. If you don't need even one axis just DEFINE_HOMING(none).
*/ */
#ifndef DEFINE_HOMING DEFINE_HOMING(x_negative, y_negative, z_negative)
#define DEFINE_HOMING(...)
#endif
//DEFINE_HOMING_START
DEFINE_HOMING(x_negative, y_negative, z_negative, none)
//DEFINE_HOMING_END
/** \def ACCELERATION_REPRAP ACCELERATION_RAMPING ACCELERATION_TEMPORAL /** \def ACCELERATION_REPRAP ACCELERATION_RAMPING ACCELERATION_TEMPORAL
Choose optionally one of ACCELERATION_REPRAP, ACCELERATION_RAMPING or Choose optionally one of ACCELERATION_REPRAP, ACCELERATION_RAMPING or

View File

@ -24,6 +24,18 @@
#define DHTR_5(name, pin, invert, pwm, max_pwm) DEFINE_HEATER_ACTUAL(name, pin, invert, pwm, max_pwm) #define DHTR_5(name, pin, invert, pwm, max_pwm) DEFINE_HEATER_ACTUAL(name, pin, invert, pwm, max_pwm)
#define DHTR_6(name, pin, invert, pwm, max_pwm, arg6) DEFINE_HEATER_ACTUAL(name, pin, invert, pwm, max_pwm) #define DHTR_6(name, pin, invert, pwm, max_pwm, arg6) DEFINE_HEATER_ACTUAL(name, pin, invert, pwm, max_pwm)
#ifndef DEFINE_HOMING_ACTUAL
#define DEFINE_HOMING_ACTUAL(...)
#endif
// Homing movements helpers.
#define GET_MACRO_HOME(_1, _2, _3, _4, NAME, ...) NAME
#define DEFINE_HOMING(...) GET_MACRO_HOME(__VA_ARGS__, DHM_4, DHM_3, DHM_2, DHM_1)(__VA_ARGS__)
#define DHM_1(STEP_1) DEFINE_HOMING_ACTUAL(STEP_1, none, none, none)
#define DHM_2(STEP_1, STEP_2) DEFINE_HOMING_ACTUAL(STEP_1, STEP_2, none, none)
#define DHM_3(STEP_1, STEP_2, STEP_3) DEFINE_HOMING_ACTUAL(STEP_1, STEP_2, STEP_3, none)
#define DHM_4(STEP_1, STEP_2, STEP_3, STEP_4) DEFINE_HOMING_ACTUAL(STEP_1, STEP_2, STEP_3, STEP_4)
/** /**
This wrapper config header is used to allow makefiles and test scripts to This wrapper config header is used to allow makefiles and test scripts to
replace or augment the user's 'config.h' file in a controlled manner. A replace or augment the user's 'config.h' file in a controlled manner. A

View File

@ -112,9 +112,8 @@
#define E_ABSOLUTE #define E_ABSOLUTE
/** \def HOMING_OPT /** \def HOMING_OPT
Options for homing movements a user should be able to choose from in configtool. All
Options for homing movements. 'none' means no movement at all. For each commented out.
option XXX, a function home_XXX() has to exist, typically in home.c/.h.
*/ */
//#define HOMING_OPT none //#define HOMING_OPT none
//#define HOMING_OPT x_negative //#define HOMING_OPT x_negative
@ -125,15 +124,10 @@
//#define HOMING_OPT z_positive //#define HOMING_OPT z_positive
/** \def DEFINE_HOMING /** \def DEFINE_HOMING
Order (and number) of homing movements. Up to 4 homing steps are allowed.
Order (and number) of homing movements. If you don't need even one axis just DEFINE_HOMING(none).
*/ */
#ifndef DEFINE_HOMING DEFINE_HOMING(x_negative, y_negative, z_negative)
#define DEFINE_HOMING(...)
#endif
//DEFINE_HOMING_START
DEFINE_HOMING(x_negative, y_negative, z_negative, none)
//DEFINE_HOMING_END
/** \def ACCELERATION_REPRAP ACCELERATION_RAMPING ACCELERATION_TEMPORAL /** \def ACCELERATION_REPRAP ACCELERATION_RAMPING ACCELERATION_TEMPORAL
Choose optionally one of ACCELERATION_REPRAP, ACCELERATION_RAMPING or Choose optionally one of ACCELERATION_REPRAP, ACCELERATION_RAMPING or

8
home.c
View File

@ -71,9 +71,9 @@ void set_axis_home_position(enum axis_e n, int8_t dir);
/// home all 3 axes /// home all 3 axes
void home() { void home() {
#ifdef DEFINE_HOMING #ifdef DEFINE_HOMING_ACTUAL
#undef DEFINE_HOMING #undef DEFINE_HOMING_ACTUAL
#define DEFINE_HOMING(first, second, third, fourth) \ #define DEFINE_HOMING_ACTUAL(first, second, third, fourth) \
{ \ { \
home_##first(); \ home_##first(); \
home_##second(); \ home_##second(); \
@ -81,7 +81,7 @@ void home() {
home_##fourth(); \ home_##fourth(); \
}; };
#include "config_wrapper.h" #include "config_wrapper.h"
#undef DEFINE_HOMING #undef DEFINE_HOMING_ACTUAL
#endif #endif
} }