Improve sanity checks with static_assert, organize

2.0.x
Scott Lahteine 8 years ago
parent 6bb05c4543
commit 9128d9ab45

@ -270,23 +270,6 @@
#endif #endif
#endif #endif
/**
* Delta requirements
*/
#if ENABLED(DELTA)
#if DISABLED(USE_XMAX_PLUG) && DISABLED(USE_YMAX_PLUG) && DISABLED(USE_ZMAX_PLUG)
#error "You probably want to use Max Endstops for DELTA!"
#elif ENABLED(ENABLE_LEVELING_FADE_HEIGHT) && DISABLED(AUTO_BED_LEVELING_BILINEAR) && !UBL_DELTA
#error "ENABLE_LEVELING_FADE_HEIGHT on DELTA requires AUTO_BED_LEVELING_BILINEAR or AUTO_BED_LEVELING_UBL."
#elif ABL_GRID
#if (GRID_MAX_POINTS_X & 1) == 0 || (GRID_MAX_POINTS_Y & 1) == 0
#error "DELTA requires GRID_MAX_POINTS_X and GRID_MAX_POINTS_Y to be odd numbers."
#elif GRID_MAX_POINTS_X < 3
#error "DELTA requires GRID_MAX_POINTS_X and GRID_MAX_POINTS_Y to be 3 or higher."
#endif
#endif
#endif
/** /**
* Babystepping * Babystepping
*/ */
@ -430,44 +413,57 @@
#endif #endif
/** /**
* Allow only one bed leveling option to be defined * Kinematics
*/
/**
* Allow only one kinematic type to be defined
*/ */
static_assert(1 >= 0 static_assert(1 >= 0
#if ENABLED(AUTO_BED_LEVELING_LINEAR) #if ENABLED(DELTA)
+ 1 + 1
#endif #endif
#if ENABLED(AUTO_BED_LEVELING_3POINT) #if ENABLED(MORGAN_SCARA)
+ 1 + 1
#endif #endif
#if ENABLED(AUTO_BED_LEVELING_BILINEAR) #if ENABLED(MAKERARM_SCARA)
+ 1 + 1
#endif #endif
#if ENABLED(AUTO_BED_LEVELING_UBL) #if ENABLED(COREXY)
+ 1 + 1
#endif #endif
#if ENABLED(MESH_BED_LEVELING) #if ENABLED(COREXZ)
+ 1 + 1
#endif #endif
, "Select only one of: MESH_BED_LEVELING, AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_3POINT, AUTO_BED_LEVELING_BILINEAR or AUTO_BED_LEVELING_UBL." #if ENABLED(COREYZ)
+ 1
#endif
#if ENABLED(COREYX)
+ 1
#endif
#if ENABLED(COREZX)
+ 1
#endif
#if ENABLED(COREZY)
+ 1
#endif
, "Please enable only one of DELTA, MORGAN_SCARA, MAKERARM_SCARA, COREXY, COREYX, COREXZ, COREZX, COREYZ, or COREZY."
); );
/** /**
* Mesh Bed Leveling * Delta requirements
*/ */
#if ENABLED(MESH_BED_LEVELING)
#if ENABLED(DELTA) #if ENABLED(DELTA)
#error "MESH_BED_LEVELING does not yet support DELTA printers." #if DISABLED(USE_XMAX_PLUG) && DISABLED(USE_YMAX_PLUG) && DISABLED(USE_ZMAX_PLUG)
#elif GRID_MAX_POINTS_X > 9 || GRID_MAX_POINTS_Y > 9 #error "You probably want to use Max Endstops for DELTA!"
#error "GRID_MAX_POINTS_X and GRID_MAX_POINTS_Y must be less than 10 for MBL." #elif ENABLED(ENABLE_LEVELING_FADE_HEIGHT) && DISABLED(AUTO_BED_LEVELING_BILINEAR) && !UBL_DELTA
#endif #error "ENABLE_LEVELING_FADE_HEIGHT on DELTA requires AUTO_BED_LEVELING_BILINEAR or AUTO_BED_LEVELING_UBL."
#elif ABL_GRID
#if (GRID_MAX_POINTS_X & 1) == 0 || (GRID_MAX_POINTS_Y & 1) == 0
#error "DELTA requires GRID_MAX_POINTS_X and GRID_MAX_POINTS_Y to be odd numbers."
#elif GRID_MAX_POINTS_X < 3
#error "DELTA requires GRID_MAX_POINTS_X and GRID_MAX_POINTS_Y to be 3 or higher."
#endif #endif
/**
* Unified Bed Leveling
*/
#if ENABLED(AUTO_BED_LEVELING_UBL)
#if IS_SCARA
#error "AUTO_BED_LEVELING_UBL does not yet support SCARA printers."
#endif #endif
#endif #endif
@ -503,7 +499,6 @@ static_assert(1 >= 0
, "Please enable only one probe option: PROBE_MANUALLY, FIX_MOUNTED_PROBE, BLTOUCH, SOLENOID_PROBE, Z_PROBE_ALLEN_KEY, Z_PROBE_SLED, or Z Servo." , "Please enable only one probe option: PROBE_MANUALLY, FIX_MOUNTED_PROBE, BLTOUCH, SOLENOID_PROBE, Z_PROBE_ALLEN_KEY, Z_PROBE_SLED, or Z Servo."
); );
#if PROBE_SELECTED #if PROBE_SELECTED
/** /**
@ -594,46 +589,57 @@ static_assert(1 >= 0
#endif #endif
/** /**
* LCD_BED_LEVELING requirements * Allow only one bed leveling option to be defined
*/ */
#if ENABLED(LCD_BED_LEVELING) static_assert(1 >= 0
#if DISABLED(ULTIPANEL) #if ENABLED(AUTO_BED_LEVELING_LINEAR)
#error "LCD_BED_LEVELING requires an LCD controller." + 1
#elif DISABLED(MESH_BED_LEVELING) && !(HAS_ABL && ENABLED(PROBE_MANUALLY)) #endif
#error "LCD_BED_LEVELING requires MESH_BED_LEVELING or PROBE_MANUALLY." #if ENABLED(AUTO_BED_LEVELING_3POINT)
+ 1
#endif
#if ENABLED(AUTO_BED_LEVELING_BILINEAR)
+ 1
#endif #endif
#if ENABLED(AUTO_BED_LEVELING_UBL)
+ 1
#endif #endif
#if ENABLED(MESH_BED_LEVELING)
+ 1
#endif
, "Select only one of: MESH_BED_LEVELING, AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_3POINT, AUTO_BED_LEVELING_BILINEAR or AUTO_BED_LEVELING_UBL."
);
/** /**
* Homing Bump * Bed Leveling Requirements
*/ */
#if X_HOME_BUMP_MM < 0 || Y_HOME_BUMP_MM < 0 || Z_HOME_BUMP_MM < 0
#error "[XYZ]_HOME_BUMP_MM must be greater than or equal to 0." #if ENABLED(AUTO_BED_LEVELING_UBL)
#endif
/** /**
* Make sure Z_SAFE_HOMING point is reachable * Unified Bed Leveling
*/ */
#if ENABLED(Z_SAFE_HOMING)
#if !WITHIN(Z_SAFE_HOMING_X_POINT, MIN_PROBE_X, MAX_PROBE_X) #if IS_SCARA
#if HAS_BED_PROBE #error "AUTO_BED_LEVELING_UBL does not yet support SCARA printers."
#error "Z_SAFE_HOMING_X_POINT can't be reached by the Z probe." #elif DISABLED(EEPROM_SETTINGS)
#else #error "AUTO_BED_LEVELING_UBL requires EEPROM_SETTINGS. Please update your configuration."
#error "Z_SAFE_HOMING_X_POINT can't be reached by the nozzle." #elif !WITHIN(GRID_MAX_POINTS_X, 3, 15) || !WITHIN(GRID_MAX_POINTS_Y, 3, 15)
#endif #error "GRID_MAX_POINTS_[XY] must be a whole number between 3 and 15."
#elif !WITHIN(Z_SAFE_HOMING_Y_POINT, MIN_PROBE_Y, MAX_PROBE_Y)
#if HAS_BED_PROBE
#error "Z_SAFE_HOMING_Y_POINT can't be reached by the Z probe."
#else #else
#error "Z_SAFE_HOMING_Y_POINT can't be reached by the nozzle." static_assert(WITHIN(UBL_PROBE_PT_1_X, MIN_PROBE_X, MAX_PROBE_X), "UBL_PROBE_PT_1_X can't be reached by the Z probe.");
#endif static_assert(WITHIN(UBL_PROBE_PT_2_X, MIN_PROBE_X, MAX_PROBE_X), "UBL_PROBE_PT_2_X can't be reached by the Z probe.");
static_assert(WITHIN(UBL_PROBE_PT_3_X, MIN_PROBE_X, MAX_PROBE_X), "UBL_PROBE_PT_3_X can't be reached by the Z probe.");
static_assert(WITHIN(UBL_PROBE_PT_1_Y, MIN_PROBE_Y, MAX_PROBE_Y), "UBL_PROBE_PT_1_Y can't be reached by the Z probe.");
static_assert(WITHIN(UBL_PROBE_PT_2_Y, MIN_PROBE_Y, MAX_PROBE_Y), "UBL_PROBE_PT_2_Y can't be reached by the Z probe.");
static_assert(WITHIN(UBL_PROBE_PT_3_Y, MIN_PROBE_Y, MAX_PROBE_Y), "UBL_PROBE_PT_3_Y can't be reached by the Z probe.");
#endif #endif
#endif // Z_SAFE_HOMING
#elif HAS_ABL
/** /**
* Auto Bed Leveling * Auto Bed Leveling
*/ */
#if HAS_ABL
#if ENABLED(USE_RAW_KINEMATICS) #if ENABLED(USE_RAW_KINEMATICS)
#error "USE_RAW_KINEMATICS is not compatible with AUTO_BED_LEVELING" #error "USE_RAW_KINEMATICS is not compatible with AUTO_BED_LEVELING"
@ -647,65 +653,85 @@ static_assert(1 >= 0
#endif #endif
/** /**
* Check auto bed leveling sub-options, especially probe points * Check auto bed leveling probe points
*/ */
#if ABL_GRID #if ABL_GRID
#ifndef DELTA_PROBEABLE_RADIUS
#if LEFT_PROBE_BED_POSITION > RIGHT_PROBE_BED_POSITION #ifdef DELTA_PROBEABLE_RADIUS
#error "LEFT_PROBE_BED_POSITION must be less than RIGHT_PROBE_BED_POSITION." static_assert(LEFT_PROBE_BED_POSITION >= -DELTA_PROBEABLE_RADIUS, "LEFT_PROBE_BED_POSITION must be within DELTA_PROBEABLE_RADIUS.");
#elif FRONT_PROBE_BED_POSITION > BACK_PROBE_BED_POSITION static_assert(RIGHT_PROBE_BED_POSITION <= DELTA_PROBEABLE_RADIUS, "RIGHT_PROBE_BED_POSITION must be within DELTA_PROBEABLE_RADIUS.");
#error "FRONT_PROBE_BED_POSITION must be less than BACK_PROBE_BED_POSITION." static_assert(FRONT_PROBE_BED_POSITION >= -DELTA_PROBEABLE_RADIUS, "FRONT_PROBE_BED_POSITION must be within DELTA_PROBEABLE_RADIUS.");
#endif static_assert(BACK_PROBE_BED_POSITION <= DELTA_PROBEABLE_RADIUS, "BACK_PROBE_BED_POSITION must be within DELTA_PROBEABLE_RADIUS.");
#if LEFT_PROBE_BED_POSITION < MIN_PROBE_X #else
#error "The given LEFT_PROBE_BED_POSITION can't be reached by the Z probe." static_assert(LEFT_PROBE_BED_POSITION < RIGHT_PROBE_BED_POSITION, "LEFT_PROBE_BED_POSITION must be less than RIGHT_PROBE_BED_POSITION.");
#elif RIGHT_PROBE_BED_POSITION > MAX_PROBE_X static_assert(FRONT_PROBE_BED_POSITION < BACK_PROBE_BED_POSITION, "FRONT_PROBE_BED_POSITION must be less than BACK_PROBE_BED_POSITION.");
#error "The given RIGHT_PROBE_BED_POSITION can't be reached by the Z probe." static_assert(LEFT_PROBE_BED_POSITION >= MIN_PROBE_X, "LEFT_PROBE_BED_POSITION can't be reached by the Z probe.");
#elif FRONT_PROBE_BED_POSITION < MIN_PROBE_Y static_assert(RIGHT_PROBE_BED_POSITION <= MAX_PROBE_X, "RIGHT_PROBE_BED_POSITION can't be reached by the Z probe.");
#error "The given FRONT_PROBE_BED_POSITION can't be reached by the Z probe." static_assert(FRONT_PROBE_BED_POSITION >= MIN_PROBE_Y, "FRONT_PROBE_BED_POSITION can't be reached by the Z probe.");
#elif BACK_PROBE_BED_POSITION > MAX_PROBE_Y static_assert(BACK_PROBE_BED_POSITION <= MAX_PROBE_Y, "BACK_PROBE_BED_POSITION can't be reached by the Z probe.");
#error "The given BACK_PROBE_BED_POSITION can't be reached by the Z probe."
#endif
#endif
#elif ENABLED(AUTO_BED_LEVELING_UBL)
#if DISABLED(EEPROM_SETTINGS)
#error "AUTO_BED_LEVELING_UBL requires EEPROM_SETTINGS. Please update your configuration."
#elif !WITHIN(GRID_MAX_POINTS_X, 3, 15) || !WITHIN(GRID_MAX_POINTS_Y, 3, 15)
#error "GRID_MAX_POINTS_[XY] must be a whole number between 3 and 15."
#endif #endif
#if IS_CARTESIAN
#if !WITHIN(GRID_MAX_POINTS_X, 3, 15) || !WITHIN(GRID_MAX_POINTS_Y, 3, 15) #else // AUTO_BED_LEVELING_3POINT
#error "GRID_MAX_POINTS_[XY] must be a whole number between 3 and 15."
#elif !WITHIN(UBL_PROBE_PT_1_X, MIN_PROBE_X, MAX_PROBE_X) static_assert(WITHIN(ABL_PROBE_PT_1_X, MIN_PROBE_X, MAX_PROBE_X), "ABL_PROBE_PT_1_X can't be reached by the Z probe.");
#error "The given UBL_PROBE_PT_1_X can't be reached by the Z probe." static_assert(WITHIN(ABL_PROBE_PT_2_X, MIN_PROBE_X, MAX_PROBE_X), "ABL_PROBE_PT_2_X can't be reached by the Z probe.");
#elif !WITHIN(UBL_PROBE_PT_2_X, MIN_PROBE_X, MAX_PROBE_X) static_assert(WITHIN(ABL_PROBE_PT_3_X, MIN_PROBE_X, MAX_PROBE_X), "ABL_PROBE_PT_3_X can't be reached by the Z probe.");
#error "The given UBL_PROBE_PT_2_X can't be reached by the Z probe." static_assert(WITHIN(ABL_PROBE_PT_1_Y, MIN_PROBE_Y, MAX_PROBE_Y), "ABL_PROBE_PT_1_Y can't be reached by the Z probe.");
#elif !WITHIN(UBL_PROBE_PT_3_X, MIN_PROBE_X, MAX_PROBE_X) static_assert(WITHIN(ABL_PROBE_PT_2_Y, MIN_PROBE_Y, MAX_PROBE_Y), "ABL_PROBE_PT_2_Y can't be reached by the Z probe.");
#error "The given UBL_PROBE_PT_3_X can't be reached by the Z probe." static_assert(WITHIN(ABL_PROBE_PT_3_Y, MIN_PROBE_Y, MAX_PROBE_Y), "ABL_PROBE_PT_3_Y can't be reached by the Z probe.");
#elif !WITHIN(UBL_PROBE_PT_1_Y, MIN_PROBE_Y, MAX_PROBE_Y)
#error "The given UBL_PROBE_PT_1_Y can't be reached by the Z probe." #endif // AUTO_BED_LEVELING_3POINT
#elif !WITHIN(UBL_PROBE_PT_2_Y, MIN_PROBE_Y, MAX_PROBE_Y)
#error "The given UBL_PROBE_PT_2_Y can't be reached by the Z probe." #elif ENABLED(MESH_BED_LEVELING)
#elif !WITHIN(UBL_PROBE_PT_3_Y, MIN_PROBE_Y, MAX_PROBE_Y)
#error "The given UBL_PROBE_PT_3_Y can't be reached by the Z probe." /**
* Mesh Bed Leveling
*/
#if ENABLED(DELTA)
#error "MESH_BED_LEVELING does not yet support DELTA printers."
#elif GRID_MAX_POINTS_X > 9 || GRID_MAX_POINTS_Y > 9
#error "GRID_MAX_POINTS_X and GRID_MAX_POINTS_Y must be less than 10 for MBL."
#endif #endif
#endif #endif
#else // AUTO_BED_LEVELING_3POINT
#if !WITHIN(ABL_PROBE_PT_1_X, MIN_PROBE_X, MAX_PROBE_X) /**
#error "The given ABL_PROBE_PT_1_X can't be reached by the Z probe." * LCD_BED_LEVELING requirements
#elif !WITHIN(ABL_PROBE_PT_2_X, MIN_PROBE_X, MAX_PROBE_X) */
#error "The given ABL_PROBE_PT_2_X can't be reached by the Z probe." #if ENABLED(LCD_BED_LEVELING)
#elif !WITHIN(ABL_PROBE_PT_3_X, MIN_PROBE_X, MAX_PROBE_X) #if DISABLED(ULTIPANEL)
#error "The given ABL_PROBE_PT_3_X can't be reached by the Z probe." #error "LCD_BED_LEVELING requires an LCD controller."
#elif !WITHIN(ABL_PROBE_PT_1_Y, MIN_PROBE_Y, MAX_PROBE_Y) #elif DISABLED(MESH_BED_LEVELING) && !(HAS_ABL && ENABLED(PROBE_MANUALLY))
#error "The given ABL_PROBE_PT_1_Y can't be reached by the Z probe." #error "LCD_BED_LEVELING requires MESH_BED_LEVELING or PROBE_MANUALLY."
#elif !WITHIN(ABL_PROBE_PT_2_Y, MIN_PROBE_Y, MAX_PROBE_Y) #endif
#error "The given ABL_PROBE_PT_2_Y can't be reached by the Z probe." #endif
#elif !WITHIN(ABL_PROBE_PT_3_Y, MIN_PROBE_Y, MAX_PROBE_Y)
#error "The given ABL_PROBE_PT_3_Y can't be reached by the Z probe." /**
* Homing Bump
*/
#if X_HOME_BUMP_MM < 0 || Y_HOME_BUMP_MM < 0 || Z_HOME_BUMP_MM < 0
#error "[XYZ]_HOME_BUMP_MM must be greater than or equal to 0."
#endif #endif
#endif // AUTO_BED_LEVELING_3POINT
#endif // HAS_ABL /**
* Make sure Z_SAFE_HOMING point is reachable
*/
#if ENABLED(Z_SAFE_HOMING)
#if !WITHIN(Z_SAFE_HOMING_X_POINT, MIN_PROBE_X, MAX_PROBE_X)
#if HAS_BED_PROBE
#error "Z_SAFE_HOMING_X_POINT can't be reached by the Z probe."
#else
#error "Z_SAFE_HOMING_X_POINT can't be reached by the nozzle."
#endif
#elif !WITHIN(Z_SAFE_HOMING_Y_POINT, MIN_PROBE_Y, MAX_PROBE_Y)
#if HAS_BED_PROBE
#error "Z_SAFE_HOMING_Y_POINT can't be reached by the Z probe."
#else
#error "Z_SAFE_HOMING_Y_POINT can't be reached by the nozzle."
#endif
#endif
#endif // Z_SAFE_HOMING
/** /**
* Advance Extrusion * Advance Extrusion
@ -739,40 +765,6 @@ static_assert(1 >= 0
#error "Only enable one SAV_3DGLCD display type: U8GLIB_SSD1306 or U8GLIB_SH1106." #error "Only enable one SAV_3DGLCD display type: U8GLIB_SSD1306 or U8GLIB_SH1106."
#endif #endif
/**
* Don't set more than one kinematic type
*/
static_assert(1 >= 0
#if ENABLED(DELTA)
+ 1
#endif
#if ENABLED(MORGAN_SCARA)
+ 1
#endif
#if ENABLED(MAKERARM_SCARA)
+ 1
#endif
#if ENABLED(COREXY)
+ 1
#endif
#if ENABLED(COREXZ)
+ 1
#endif
#if ENABLED(COREYZ)
+ 1
#endif
#if ENABLED(COREYX)
+ 1
#endif
#if ENABLED(COREZX)
+ 1
#endif
#if ENABLED(COREZY)
+ 1
#endif
, "Please enable only one of DELTA, MORGAN_SCARA, MAKERARM_SCARA, COREXY, COREYX, COREXZ, COREZX, COREYZ, or COREZY."
);
/** /**
* Allen Key * Allen Key
* Deploying the Allen Key probe uses big moves in z direction. Too dangerous for an unhomed z-axis. * Deploying the Allen Key probe uses big moves in z direction. Too dangerous for an unhomed z-axis.
@ -1147,8 +1139,30 @@ static_assert(1 >= 0
, "Please select no more than one LCD controller option." , "Please select no more than one LCD controller option."
); );
#if ENABLED(HAVE_TMC2130) && !( \ /**
ENABLED( X_IS_TMC2130 ) \ * Make sure HAVE_TMCDRIVER is warranted
*/
#if ENABLED(HAVE_TMCDRIVER) && !( \
ENABLED( X_IS_TMC ) \
|| ENABLED( X2_IS_TMC ) \
|| ENABLED( Y_IS_TMC ) \
|| ENABLED( Y2_IS_TMC ) \
|| ENABLED( Z_IS_TMC ) \
|| ENABLED( Z2_IS_TMC ) \
|| ENABLED( E0_IS_TMC ) \
|| ENABLED( E1_IS_TMC ) \
|| ENABLED( E2_IS_TMC ) \
|| ENABLED( E3_IS_TMC ) \
|| ENABLED( E4_IS_TMC ) \
)
#error "HAVE_TMCDRIVER requires at least one TMC stepper to be set."
#endif
/**
* Make sure HAVE_TMC2130 is warranted
*/
#if ENABLED(HAVE_TMC2130)
#if !( ENABLED( X_IS_TMC2130 ) \
|| ENABLED( X2_IS_TMC2130 ) \ || ENABLED( X2_IS_TMC2130 ) \
|| ENABLED( Y_IS_TMC2130 ) \ || ENABLED( Y_IS_TMC2130 ) \
|| ENABLED( Y2_IS_TMC2130 ) \ || ENABLED( Y2_IS_TMC2130 ) \
@ -1157,12 +1171,32 @@ static_assert(1 >= 0
|| ENABLED( E0_IS_TMC2130 ) \ || ENABLED( E0_IS_TMC2130 ) \
|| ENABLED( E1_IS_TMC2130 ) \ || ENABLED( E1_IS_TMC2130 ) \
|| ENABLED( E2_IS_TMC2130 ) \ || ENABLED( E2_IS_TMC2130 ) \
|| ENABLED( E3_IS_TMC2130 ) ) || ENABLED( E3_IS_TMC2130 ) \
#error "Choose at least one TMC2130 stepper." || ENABLED( E4_IS_TMC2130 ) \
)
#error "HAVE_TMC2130 requires at least one TMC2130 stepper to be set."
#elif ENABLED(HYBRID_THRESHOLD) && DISABLED(STEALTHCHOP)
#error "Enable STEALTHCHOP to use HYBRID_THRESHOLD."
#endif
#endif #endif
#if ENABLED(HYBRID_THRESHOLD) && DISABLED(STEALTHCHOP) /**
#error "Enable STEALTHCHOP to use HYBRID_THRESHOLD." * Make sure HAVE_L6470DRIVER is warranted
*/
#if ENABLED(HAVE_L6470DRIVER) && !( \
ENABLED( X_IS_L6470 ) \
|| ENABLED( X2_IS_L6470 ) \
|| ENABLED( Y_IS_L6470 ) \
|| ENABLED( Y2_IS_L6470 ) \
|| ENABLED( Z_IS_L6470 ) \
|| ENABLED( Z2_IS_L6470 ) \
|| ENABLED( E0_IS_L6470 ) \
|| ENABLED( E1_IS_L6470 ) \
|| ENABLED( E2_IS_L6470 ) \
|| ENABLED( E3_IS_L6470 ) \
|| ENABLED( E4_IS_L6470 ) \
)
#error "HAVE_L6470DRIVER requires at least one L6470 stepper to be set."
#endif #endif
/** /**

Loading…
Cancel
Save