Browse Source

Simplify some sanity checks with static_assert

pull/1/head
Scott Lahteine 8 years ago
parent
commit
e7e4500629
  1. 209
      Marlin/SanityCheck.h

209
Marlin/SanityCheck.h

@ -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
#if COUNT_LEV_5 > 1
#error "Select only one of: MESH_BED_LEVELING, AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_3POINT, or AUTO_BED_LEVELING_BILINEAR."
#endif
#endif #endif
, "Select only one of: MESH_BED_LEVELING, AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_3POINT, or AUTO_BED_LEVELING_BILINEAR."
);
/** /**
* 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
#define COUNT_KIN_2 COUNT_KIN_1
#endif #endif
#if ENABLED(MORGAN_SCARA) #if ENABLED(MORGAN_SCARA)
#define COUNT_KIN_3 INCREMENT(COUNT_KIN_2) + 1
#else
#define COUNT_KIN_3 COUNT_KIN_2
#endif #endif
#if ENABLED(MAKERARM_SCARA) #if ENABLED(MAKERARM_SCARA)
#define COUNT_KIN_4 INCREMENT(COUNT_KIN_3) + 1
#else
#define COUNT_KIN_4 COUNT_KIN_3
#endif #endif
#if ENABLED(COREXY) #if ENABLED(COREXY)
#define COUNT_KIN_5 INCREMENT(COUNT_KIN_4) + 1
#else
#define COUNT_KIN_5 COUNT_KIN_4
#endif #endif
#if ENABLED(COREXZ) #if ENABLED(COREXZ)
#define COUNT_KIN_6 INCREMENT(COUNT_KIN_5) + 1
#else
#define COUNT_KIN_6 COUNT_KIN_5
#endif #endif
#if ENABLED(COREYZ) #if ENABLED(COREYZ)
#define COUNT_KIN_7 INCREMENT(COUNT_KIN_6) + 1
#else
#define COUNT_KIN_7 COUNT_KIN_6
#endif #endif
#if ENABLED(COREYX) #if ENABLED(COREYX)
#define COUNT_KIN_8 INCREMENT(COUNT_KIN_7) + 1
#else
#define COUNT_KIN_8 COUNT_KIN_7
#endif #endif
#if ENABLED(COREZX) #if ENABLED(COREZX)
#define COUNT_KIN_9 INCREMENT(COUNT_KIN_8) + 1
#else
#define COUNT_KIN_9 COUNT_KIN_8
#endif #endif
#if ENABLED(COREZY) #if ENABLED(COREZY)
#define COUNT_KIN_10 INCREMENT(COUNT_KIN_9) + 1
#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 #endif
, "Please enable only one of DELTA, MORGAN_SCARA, MAKERARM_SCARA, COREXY, COREYX, COREXZ, COREZX, COREYZ, or COREZY."
);
/** /**
* 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
#define COUNT_LCD_2 COUNT_LCD_1
#endif #endif
#if ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER) && DISABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) #if ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER) && DISABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER)
#define COUNT_LCD_3 INCREMENT(COUNT_LCD_2) + 1
#else
#define COUNT_LCD_3 COUNT_LCD_2
#endif #endif
#if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) && DISABLED(BQ_LCD_SMART_CONTROLLER) #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) && DISABLED(BQ_LCD_SMART_CONTROLLER)
#define COUNT_LCD_4 INCREMENT(COUNT_LCD_3) + 1
#else
#define COUNT_LCD_4 COUNT_LCD_3
#endif #endif
#if ENABLED(CARTESIO_UI) #if ENABLED(CARTESIO_UI)
#define COUNT_LCD_5 INCREMENT(COUNT_LCD_4) + 1
#else
#define COUNT_LCD_5 COUNT_LCD_4
#endif #endif
#if ENABLED(PANEL_ONE) #if ENABLED(PANEL_ONE)
#define COUNT_LCD_6 INCREMENT(COUNT_LCD_5) + 1
#else
#define COUNT_LCD_6 COUNT_LCD_5
#endif #endif
#if ENABLED(MAKRPANEL) #if ENABLED(MAKRPANEL)
#define COUNT_LCD_7 INCREMENT(COUNT_LCD_6) + 1
#else
#define COUNT_LCD_7 COUNT_LCD_6
#endif #endif
#if ENABLED(REPRAPWORLD_GRAPHICAL_LCD) #if ENABLED(REPRAPWORLD_GRAPHICAL_LCD)
#define COUNT_LCD_8 INCREMENT(COUNT_LCD_7) + 1
#else
#define COUNT_LCD_8 COUNT_LCD_7
#endif #endif
#if ENABLED(VIKI2) #if ENABLED(VIKI2)
#define COUNT_LCD_9 INCREMENT(COUNT_LCD_8) + 1
#else
#define COUNT_LCD_9 COUNT_LCD_8
#endif #endif
#if ENABLED(miniVIKI) #if ENABLED(miniVIKI)
#define COUNT_LCD_10 INCREMENT(COUNT_LCD_9) + 1
#else
#define COUNT_LCD_10 COUNT_LCD_9
#endif #endif
#if ENABLED(ELB_FULL_GRAPHIC_CONTROLLER) #if ENABLED(ELB_FULL_GRAPHIC_CONTROLLER)
#define COUNT_LCD_11 INCREMENT(COUNT_LCD_10) + 1
#else
#define COUNT_LCD_11 COUNT_LCD_10
#endif #endif
#if ENABLED(G3D_PANEL) #if ENABLED(G3D_PANEL)
#define COUNT_LCD_12 INCREMENT(COUNT_LCD_11) + 1
#else
#define COUNT_LCD_12 COUNT_LCD_11
#endif #endif
#if ENABLED(MINIPANEL) #if ENABLED(MINIPANEL)
#define COUNT_LCD_13 INCREMENT(COUNT_LCD_12) + 1
#else
#define COUNT_LCD_13 COUNT_LCD_12
#endif #endif
#if ENABLED(REPRAPWORLD_KEYPAD) && DISABLED(CARTESIO_UI) #if ENABLED(REPRAPWORLD_KEYPAD) && DISABLED(CARTESIO_UI)
#define COUNT_LCD_14 INCREMENT(COUNT_LCD_13) + 1
#else
#define COUNT_LCD_14 COUNT_LCD_13
#endif #endif
#if ENABLED(RIGIDBOT_PANEL) #if ENABLED(RIGIDBOT_PANEL)
#define COUNT_LCD_15 INCREMENT(COUNT_LCD_14) + 1
#else
#define COUNT_LCD_15 COUNT_LCD_14
#endif #endif
#if ENABLED(RA_CONTROL_PANEL) #if ENABLED(RA_CONTROL_PANEL)
#define COUNT_LCD_16 INCREMENT(COUNT_LCD_15) + 1
#else
#define COUNT_LCD_16 COUNT_LCD_15
#endif #endif
#if ENABLED(LCD_I2C_SAINSMART_YWROBOT) #if ENABLED(LCD_I2C_SAINSMART_YWROBOT)
#define COUNT_LCD_17 INCREMENT(COUNT_LCD_16) + 1
#else
#define COUNT_LCD_17 COUNT_LCD_16
#endif #endif
#if ENABLED(LCM1602) #if ENABLED(LCM1602)
#define COUNT_LCD_18 INCREMENT(COUNT_LCD_17) + 1
#else
#define COUNT_LCD_18 COUNT_LCD_17
#endif #endif
#if ENABLED(LCD_I2C_PANELOLU2) #if ENABLED(LCD_I2C_PANELOLU2)
#define COUNT_LCD_19 INCREMENT(COUNT_LCD_18) + 1
#else
#define COUNT_LCD_19 COUNT_LCD_18
#endif #endif
#if ENABLED(LCD_I2C_VIKI) #if ENABLED(LCD_I2C_VIKI)
#define COUNT_LCD_20 INCREMENT(COUNT_LCD_19) + 1
#else
#define COUNT_LCD_20 COUNT_LCD_19
#endif #endif
#if ENABLED(U8GLIB_SSD1306) #if ENABLED(U8GLIB_SSD1306)
#define COUNT_LCD_21 INCREMENT(COUNT_LCD_20) + 1
#else
#define COUNT_LCD_21 COUNT_LCD_20
#endif #endif
#if ENABLED(SAV_3DLCD) #if ENABLED(SAV_3DLCD)
#define COUNT_LCD_22 INCREMENT(COUNT_LCD_21) + 1
#else
#define COUNT_LCD_22 COUNT_LCD_21
#endif #endif
#if ENABLED(BQ_LCD_SMART_CONTROLLER) #if ENABLED(BQ_LCD_SMART_CONTROLLER)
#define COUNT_LCD_23 INCREMENT(COUNT_LCD_22) + 1
#else
#define COUNT_LCD_23 COUNT_LCD_22
#endif #endif
#if ENABLED(SAV_3DGLCD) #if ENABLED(SAV_3DGLCD)
#define COUNT_LCD_24 INCREMENT(COUNT_LCD_23) + 1
#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 #endif
, "Please select no more than one LCD controller option."
);

Loading…
Cancel
Save