Skip to content

Commit

Permalink
♻️ Refactor PROBE_PT_[123]
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Mar 16, 2023
1 parent 41b3409 commit 51d3eab
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 19 deletions.
11 changes: 4 additions & 7 deletions Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -2152,13 +2152,10 @@
* Points to probe for all 3-point Leveling procedures.
* Override if the automatically selected points are inadequate.
*/
#if EITHER(AUTO_BED_LEVELING_3POINT, AUTO_BED_LEVELING_UBL)
//#define PROBE_PT_1_X 15
//#define PROBE_PT_1_Y 180
//#define PROBE_PT_2_X 15
//#define PROBE_PT_2_Y 20
//#define PROBE_PT_3_X 170
//#define PROBE_PT_3_Y 20
#if NEEDS_THREE_PROBE_POINTS
//#define PROBE_PT_1 { 15, 180 } // (mm) { x, y }
//#define PROBE_PT_2 { 15, 20 }
//#define PROBE_PT_3 { 170, 20 }
#endif

/**
Expand Down
8 changes: 2 additions & 6 deletions Marlin/src/inc/Conditionals_post.h
Original file line number Diff line number Diff line change
Expand Up @@ -3188,13 +3188,9 @@
#undef MESH_MAX_Y
#endif

#define _POINT_COUNT (defined(PROBE_PT_1_X) + defined(PROBE_PT_2_X) + defined(PROBE_PT_3_X) + defined(PROBE_PT_1_Y) + defined(PROBE_PT_2_Y) + defined(PROBE_PT_3_Y))
#if _POINT_COUNT == 6
#define HAS_FIXED_3POINT 1
#elif _POINT_COUNT > 0
#error "For 3-Point Leveling all XY points must be defined (or none for the defaults)."
#if NEEDS_THREE_PROBE_POINTS && defined(PROBE_PT_1)
#define HAS_FIXED_3POINT 1 // Points are defined for ABL/UBL. Else calculated in probe.get_three_points.
#endif
#undef _POINT_COUNT

/**
* Buzzer/Speaker
Expand Down
8 changes: 8 additions & 0 deletions Marlin/src/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,8 @@
#error "DISABLE_INACTIVE_E is now set with DISABLE_INACTIVE_EXTRUDER."
#elif defined(INVERT_X_STEP_PIN) || defined(INVERT_Y_STEP_PIN) || defined(INVERT_Z_STEP_PIN) || defined(INVERT_I_STEP_PIN) || defined(INVERT_J_STEP_PIN) || defined(INVERT_K_STEP_PIN) || defined(INVERT_U_STEP_PIN) || defined(INVERT_V_STEP_PIN) || defined(INVERT_W_STEP_PIN) || defined(INVERT_E_STEP_PIN)
#error "INVERT_*_STEP_PIN true is now STEP_STATE_* LOW, and INVERT_*_STEP_PIN false is now STEP_STATE_* HIGH."
#elif defined(PROBE_PT_1_X) || defined(PROBE_PT_1_Y) || defined(PROBE_PT_2_X) || defined(PROBE_PT_2_Y) || defined(PROBE_PT_3_X) || defined(PROBE_PT_3_Y)
#error "PROBE_PT_[123]_[XY] is now defined using PROBE_PT_[123] with an array { x, y }."
#endif

// L64xx stepper drivers have been removed
Expand Down Expand Up @@ -2102,6 +2104,12 @@ static_assert(X_MAX_LENGTH >= X_BED_SIZE, "Movement bounds (X_MIN_POS, X_MAX_POS

#endif

#define _POINT_COUNT (defined(PROBE_PT_1) + defined(PROBE_PT_2) + defined(PROBE_PT_3))
#if _POINT_COUNT != 0 && _POINT_COUNT != 3
#error "For 3-Point Procedures all XY points must be defined (or none for the defaults)."
#endif
#undef _POINT_COUNT

#if ALL(HAS_LEVELING, RESTORE_LEVELING_AFTER_G28, ENABLE_LEVELING_AFTER_G28)
#error "Only enable RESTORE_LEVELING_AFTER_G28 or ENABLE_LEVELING_AFTER_G28, but not both."
#endif
Expand Down
10 changes: 5 additions & 5 deletions Marlin/src/module/probe.h
Original file line number Diff line number Diff line change
Expand Up @@ -294,12 +294,12 @@ class Probe {
template <typename T>
static void get_three_points(T points[3]) {
#if HAS_FIXED_3POINT
#define VALIDATE_PROBE_PT(N) static_assert(Probe::build_time::can_reach(xy_pos_t{PROBE_PT_##N##_X, PROBE_PT_##N##_Y}), \
"PROBE_PT_" STRINGIFY(N) "_(X|Y) is unreachable using default NOZZLE_TO_PROBE_OFFSET and PROBING_MARGIN");
#define VALIDATE_PROBE_PT(N) static_assert(Probe::build_time::can_reach(xy_pos_t(PROBE_PT_##N)), \
"PROBE_PT_" STRINGIFY(N) " is unreachable using default NOZZLE_TO_PROBE_OFFSET and PROBING_MARGIN.");
VALIDATE_PROBE_PT(1); VALIDATE_PROBE_PT(2); VALIDATE_PROBE_PT(3);
points[0] = xy_float_t({ PROBE_PT_1_X, PROBE_PT_1_Y });
points[1] = xy_float_t({ PROBE_PT_2_X, PROBE_PT_2_Y });
points[2] = xy_float_t({ PROBE_PT_3_X, PROBE_PT_3_Y });
points[0] = xy_float_t(PROBE_PT_1);
points[1] = xy_float_t(PROBE_PT_2);
points[2] = xy_float_t(PROBE_PT_3);
#else
#if IS_KINEMATIC
constexpr float SIN0 = 0.0, SIN120 = 0.866025, SIN240 = -0.866025,
Expand Down
3 changes: 2 additions & 1 deletion buildroot/tests/mega2560
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ opt_set MOTHERBOARD BOARD_AZTEEG_X3_PRO NUM_SERVOS 1 \
NUM_RUNOUT_SENSORS 5 FIL_RUNOUT2_PIN 44 FIL_RUNOUT3_PIN 45 FIL_RUNOUT4_PIN 46 FIL_RUNOUT5_PIN 47 \
FIL_RUNOUT3_STATE HIGH FILAMENT_RUNOUT_SCRIPT '"M600 T%c"'
opt_enable VIKI2 BOOT_MARLIN_LOGO_ANIMATED SDSUPPORT AUTO_REPORT_SD_STATUS \
Z_PROBE_SERVO_NR Z_SERVO_ANGLES DEACTIVATE_SERVOS_AFTER_MOVE AUTO_BED_LEVELING_3POINT DEBUG_LEVELING_FEATURE \
Z_PROBE_SERVO_NR Z_SERVO_ANGLES DEACTIVATE_SERVOS_AFTER_MOVE \
AUTO_BED_LEVELING_3POINT DEBUG_LEVELING_FEATURE PROBE_PT_1 PROBE_PT_2 PROBE_PT_3 \
EEPROM_SETTINGS EEPROM_CHITCHAT M114_DETAIL AUTO_REPORT_POSITION \
NO_VOLUMETRICS EXTENDED_CAPABILITIES_REPORT AUTO_REPORT_TEMPERATURES AUTOTEMP G38_PROBE_TARGET JOYSTICK \
DIRECT_STEPPING DETECT_BROKEN_ENDSTOP \
Expand Down

0 comments on commit 51d3eab

Please sign in to comment.