Merge pull request #6040 from thinkyhead/rc_sanity_use_assert

Simplify some sanity checks with static_assert
This commit is contained in:
Scott Lahteine 2017-03-17 05:22:17 -05:00 committed by GitHub
commit 734f9ea133

View File

@ -372,32 +372,21 @@
/** /**
* Allow only one bed leveling option to be defined * Allow only one bed leveling option to be defined
*/ */
#if HAS_ABL static_assert(1 >= 0
#define COUNT_LEV_1 0
#if ENABLED(AUTO_BED_LEVELING_LINEAR) #if ENABLED(AUTO_BED_LEVELING_LINEAR)
#define COUNT_LEV_2 INCREMENT(COUNT_LEV_1) + 1
#else
#define COUNT_LEV_2 COUNT_LEV_1
#endif #endif
#if ENABLED(AUTO_BED_LEVELING_3POINT) #if ENABLED(AUTO_BED_LEVELING_3POINT)
#define COUNT_LEV_3 INCREMENT(COUNT_LEV_2) + 1
#else
#define COUNT_LEV_3 COUNT_LEV_2
#endif #endif
#if ENABLED(AUTO_BED_LEVELING_BILINEAR) #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
#define COUNT_LEV_4 INCREMENT(COUNT_LEV_3) + 1
#else
#define COUNT_LEV_4 COUNT_LEV_3
#endif #endif
#if ENABLED(MESH_BED_LEVELING) #if ENABLED(MESH_BED_LEVELING)
#define COUNT_LEV_5 INCREMENT(COUNT_LEV_4) + 1
#else
#define COUNT_LEV_5 COUNT_LEV_4
#endif #endif
#if COUNT_LEV_5 > 1 , "Select only one of: MESH_BED_LEVELING, AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_3POINT, or AUTO_BED_LEVELING_BILINEAR."
#error "Select only one of: MESH_BED_LEVELING, AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_3POINT, or AUTO_BED_LEVELING_BILINEAR." );
#endif
#endif
/** /**
* Mesh Bed Leveling * Mesh Bed Leveling
@ -408,47 +397,38 @@
#elif MESH_NUM_X_POINTS > 9 || MESH_NUM_Y_POINTS > 9 #elif MESH_NUM_X_POINTS > 9 || MESH_NUM_Y_POINTS > 9
#error "MESH_NUM_X_POINTS and MESH_NUM_Y_POINTS must be less than 10." #error "MESH_NUM_X_POINTS and MESH_NUM_Y_POINTS must be less than 10."
#endif #endif
#elif ENABLED(MANUAL_BED_LEVELING)
#error "MANUAL_BED_LEVELING only applies to MESH_BED_LEVELING."
#endif #endif
/** /**
* Probes * Probes
*/ */
#if PROBE_SELECTED
/** /**
* Allow only one probe option to be defined * Allow only one probe option to be defined
*/ */
#define COUNT_PROBE_1 0 static_assert(1 >= 0
#if ENABLED(PROBE_MANUALLY)
+ 1
#endif
#if ENABLED(FIX_MOUNTED_PROBE) #if ENABLED(FIX_MOUNTED_PROBE)
#define COUNT_PROBE_2 INCREMENT(COUNT_PROBE_1) + 1
#else
#define COUNT_PROBE_2 COUNT_PROBE_1
#endif #endif
#if HAS_Z_SERVO_ENDSTOP && DISABLED(BLTOUCH) #if HAS_Z_SERVO_ENDSTOP && DISABLED(BLTOUCH)
#define COUNT_PROBE_3 INCREMENT(COUNT_PROBE_2) + 1
#else
#define COUNT_PROBE_3 COUNT_PROBE_2
#endif #endif
#if ENABLED(BLTOUCH) #if ENABLED(BLTOUCH)
#define COUNT_PROBE_4 INCREMENT(COUNT_PROBE_3) + 1
#else
#define COUNT_PROBE_4 COUNT_PROBE_3
#endif #endif
#if ENABLED(Z_PROBE_ALLEN_KEY) #if ENABLED(Z_PROBE_ALLEN_KEY)
#define COUNT_PROBE_5 INCREMENT(COUNT_PROBE_4) + 1
#else
#define COUNT_PROBE_5 COUNT_PROBE_4
#endif #endif
#if ENABLED(Z_PROBE_SLED) #if ENABLED(Z_PROBE_SLED)
#define COUNT_PROBE_6 INCREMENT(COUNT_PROBE_5) + 1
#else
#define COUNT_PROBE_6 COUNT_PROBE_5
#endif
#if COUNT_PROBE_6 > 1
#error "Please enable only one probe: FIX_MOUNTED_PROBE, Z Servo, BLTOUCH, Z_PROBE_ALLEN_KEY, or Z_PROBE_SLED."
#endif #endif
, "Please enable only one probe: PROBE_MANUALLY, FIX_MOUNTED_PROBE, Z Servo, BLTOUCH, Z_PROBE_ALLEN_KEY, or Z_PROBE_SLED."
);
#if PROBE_SELECTED
/** /**
* Z_PROBE_SLED is incompatible with DELTA * Z_PROBE_SLED is incompatible with DELTA
@ -515,6 +495,13 @@
#endif #endif
/**
* MANUAL_BED_LEVELING requirements
*/
#if ENABLED(MANUAL_BED_LEVELING) && DISABLED(MESH_BED_LEVELING)
#error "MANUAL_BED_LEVELING requires MESH_BED_LEVELING."
#endif
/** /**
* Homing Bump * Homing Bump
*/ */
@ -639,55 +626,36 @@
/** /**
* Don't set more than one kinematic type * Don't set more than one kinematic type
*/ */
#define COUNT_KIN_1 0 static_assert(1 >= 0
#if ENABLED(DELTA) #if ENABLED(DELTA)
#define COUNT_KIN_2 INCREMENT(COUNT_KIN_1) + 1
#else #endif
#define COUNT_KIN_2 COUNT_KIN_1 #if ENABLED(MORGAN_SCARA)
#endif + 1
#if ENABLED(MORGAN_SCARA) #endif
#define COUNT_KIN_3 INCREMENT(COUNT_KIN_2) #if ENABLED(MAKERARM_SCARA)
#else + 1
#define COUNT_KIN_3 COUNT_KIN_2 #endif
#endif #if ENABLED(COREXY)
#if ENABLED(MAKERARM_SCARA) + 1
#define COUNT_KIN_4 INCREMENT(COUNT_KIN_3) #endif
#else #if ENABLED(COREXZ)
#define COUNT_KIN_4 COUNT_KIN_3 + 1
#endif #endif
#if ENABLED(COREXY) #if ENABLED(COREYZ)
#define COUNT_KIN_5 INCREMENT(COUNT_KIN_4) + 1
#else #endif
#define COUNT_KIN_5 COUNT_KIN_4 #if ENABLED(COREYX)
#endif + 1
#if ENABLED(COREXZ) #endif
#define COUNT_KIN_6 INCREMENT(COUNT_KIN_5) #if ENABLED(COREZX)
#else + 1
#define COUNT_KIN_6 COUNT_KIN_5 #endif
#endif #if ENABLED(COREZY)
#if ENABLED(COREYZ) + 1
#define COUNT_KIN_7 INCREMENT(COUNT_KIN_6) #endif
#else , "Please enable only one of DELTA, MORGAN_SCARA, MAKERARM_SCARA, COREXY, COREYX, COREXZ, COREZX, COREYZ, or COREZY."
#define COUNT_KIN_7 COUNT_KIN_6 );
#endif
#if ENABLED(COREYX)
#define COUNT_KIN_8 INCREMENT(COUNT_KIN_7)
#else
#define COUNT_KIN_8 COUNT_KIN_7
#endif
#if ENABLED(COREZX)
#define COUNT_KIN_9 INCREMENT(COUNT_KIN_8)
#else
#define COUNT_KIN_9 COUNT_KIN_8
#endif
#if ENABLED(COREZY)
#define COUNT_KIN_10 INCREMENT(COUNT_KIN_9)
#else
#define COUNT_KIN_10 COUNT_KIN_9
#endif
#if COUNT_KIN_10 > 1
#error "Please enable only one of DELTA, MORGAN_SCARA, MAKERARM_SCARA, COREXY, COREYX, COREXZ, COREZX, COREYZ, or COREZY."
#endif
/** /**
* Allen Key * Allen Key
@ -950,124 +918,77 @@
* ELB_FULL_GRAPHIC_CONTROLLER => ULTIMAKERCONTROLLER * ELB_FULL_GRAPHIC_CONTROLLER => ULTIMAKERCONTROLLER
* PANEL_ONE => ULTIMAKERCONTROLLER * PANEL_ONE => ULTIMAKERCONTROLLER
*/ */
#define COUNT_LCD_1 0 static_assert(1 >= 0
#if ENABLED(ULTIMAKERCONTROLLER) \ #if ENABLED(ULTIMAKERCONTROLLER) \
&& DISABLED(SAV_3DGLCD) && DISABLED(miniVIKI) && DISABLED(VIKI2) \ && DISABLED(SAV_3DGLCD) && DISABLED(miniVIKI) && DISABLED(VIKI2) \
&& DISABLED(ELB_FULL_GRAPHIC_CONTROLLER) && DISABLED(PANEL_ONE) && DISABLED(ELB_FULL_GRAPHIC_CONTROLLER) && DISABLED(PANEL_ONE)
#define COUNT_LCD_2 INCREMENT(COUNT_LCD_1) + 1
#else #endif
#define COUNT_LCD_2 COUNT_LCD_1 #if ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER) && DISABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER)
#endif + 1
#if ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER) && DISABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) #endif
#define COUNT_LCD_3 INCREMENT(COUNT_LCD_2) #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) && DISABLED(BQ_LCD_SMART_CONTROLLER)
#else + 1
#define COUNT_LCD_3 COUNT_LCD_2 #endif
#endif #if ENABLED(CARTESIO_UI)
#if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) && DISABLED(BQ_LCD_SMART_CONTROLLER) + 1
#define COUNT_LCD_4 INCREMENT(COUNT_LCD_3) #endif
#else #if ENABLED(PANEL_ONE)
#define COUNT_LCD_4 COUNT_LCD_3 + 1
#endif #endif
#if ENABLED(CARTESIO_UI) #if ENABLED(MAKRPANEL)
#define COUNT_LCD_5 INCREMENT(COUNT_LCD_4) + 1
#else #endif
#define COUNT_LCD_5 COUNT_LCD_4 #if ENABLED(REPRAPWORLD_GRAPHICAL_LCD)
#endif + 1
#if ENABLED(PANEL_ONE) #endif
#define COUNT_LCD_6 INCREMENT(COUNT_LCD_5) #if ENABLED(VIKI2)
#else + 1
#define COUNT_LCD_6 COUNT_LCD_5 #endif
#endif #if ENABLED(miniVIKI)
#if ENABLED(MAKRPANEL) + 1
#define COUNT_LCD_7 INCREMENT(COUNT_LCD_6) #endif
#else #if ENABLED(ELB_FULL_GRAPHIC_CONTROLLER)
#define COUNT_LCD_7 COUNT_LCD_6 + 1
#endif #endif
#if ENABLED(REPRAPWORLD_GRAPHICAL_LCD) #if ENABLED(G3D_PANEL)
#define COUNT_LCD_8 INCREMENT(COUNT_LCD_7) + 1
#else #endif
#define COUNT_LCD_8 COUNT_LCD_7 #if ENABLED(MINIPANEL)
#endif + 1
#if ENABLED(VIKI2) #endif
#define COUNT_LCD_9 INCREMENT(COUNT_LCD_8) #if ENABLED(REPRAPWORLD_KEYPAD) && DISABLED(CARTESIO_UI)
#else + 1
#define COUNT_LCD_9 COUNT_LCD_8 #endif
#endif #if ENABLED(RIGIDBOT_PANEL)
#if ENABLED(miniVIKI) + 1
#define COUNT_LCD_10 INCREMENT(COUNT_LCD_9) #endif
#else #if ENABLED(RA_CONTROL_PANEL)
#define COUNT_LCD_10 COUNT_LCD_9 + 1
#endif #endif
#if ENABLED(ELB_FULL_GRAPHIC_CONTROLLER) #if ENABLED(LCD_I2C_SAINSMART_YWROBOT)
#define COUNT_LCD_11 INCREMENT(COUNT_LCD_10) + 1
#else #endif
#define COUNT_LCD_11 COUNT_LCD_10 #if ENABLED(LCM1602)
#endif + 1
#if ENABLED(G3D_PANEL) #endif
#define COUNT_LCD_12 INCREMENT(COUNT_LCD_11) #if ENABLED(LCD_I2C_PANELOLU2)
#else + 1
#define COUNT_LCD_12 COUNT_LCD_11 #endif
#endif #if ENABLED(LCD_I2C_VIKI)
#if ENABLED(MINIPANEL) + 1
#define COUNT_LCD_13 INCREMENT(COUNT_LCD_12) #endif
#else #if ENABLED(U8GLIB_SSD1306)
#define COUNT_LCD_13 COUNT_LCD_12 + 1
#endif #endif
#if ENABLED(REPRAPWORLD_KEYPAD) && DISABLED(CARTESIO_UI) #if ENABLED(SAV_3DLCD)
#define COUNT_LCD_14 INCREMENT(COUNT_LCD_13) + 1
#else #endif
#define COUNT_LCD_14 COUNT_LCD_13 #if ENABLED(BQ_LCD_SMART_CONTROLLER)
#endif + 1
#if ENABLED(RIGIDBOT_PANEL) #endif
#define COUNT_LCD_15 INCREMENT(COUNT_LCD_14) #if ENABLED(SAV_3DGLCD)
#else + 1
#define COUNT_LCD_15 COUNT_LCD_14 #endif
#endif , "Please select no more than one LCD controller option."
#if ENABLED(RA_CONTROL_PANEL) );
#define COUNT_LCD_16 INCREMENT(COUNT_LCD_15)
#else
#define COUNT_LCD_16 COUNT_LCD_15
#endif
#if ENABLED(LCD_I2C_SAINSMART_YWROBOT)
#define COUNT_LCD_17 INCREMENT(COUNT_LCD_16)
#else
#define COUNT_LCD_17 COUNT_LCD_16
#endif
#if ENABLED(LCM1602)
#define COUNT_LCD_18 INCREMENT(COUNT_LCD_17)
#else
#define COUNT_LCD_18 COUNT_LCD_17
#endif
#if ENABLED(LCD_I2C_PANELOLU2)
#define COUNT_LCD_19 INCREMENT(COUNT_LCD_18)
#else
#define COUNT_LCD_19 COUNT_LCD_18
#endif
#if ENABLED(LCD_I2C_VIKI)
#define COUNT_LCD_20 INCREMENT(COUNT_LCD_19)
#else
#define COUNT_LCD_20 COUNT_LCD_19
#endif
#if ENABLED(U8GLIB_SSD1306)
#define COUNT_LCD_21 INCREMENT(COUNT_LCD_20)
#else
#define COUNT_LCD_21 COUNT_LCD_20
#endif
#if ENABLED(SAV_3DLCD)
#define COUNT_LCD_22 INCREMENT(COUNT_LCD_21)
#else
#define COUNT_LCD_22 COUNT_LCD_21
#endif
#if ENABLED(BQ_LCD_SMART_CONTROLLER)
#define COUNT_LCD_23 INCREMENT(COUNT_LCD_22)
#else
#define COUNT_LCD_23 COUNT_LCD_22
#endif
#if ENABLED(SAV_3DGLCD)
#define COUNT_LCD_24 INCREMENT(COUNT_LCD_23)
#else
#define COUNT_LCD_24 COUNT_LCD_23
#endif
#if COUNT_LCD_24 > 1
#error "Please select no more than one LCD controller option."
#endif