2017-09-08 22:35:25 +02:00
|
|
|
/**
|
|
|
|
* Marlin 3D Printer Firmware
|
2019-06-28 06:57:50 +02:00
|
|
|
* Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
2017-09-08 22:35:25 +02:00
|
|
|
*
|
|
|
|
* Based on Sprinter and grbl.
|
2019-06-28 06:57:50 +02:00
|
|
|
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
2017-09-08 22:35:25 +02:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
2018-11-04 09:25:55 +01:00
|
|
|
#pragma once
|
2017-09-08 22:35:25 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* probe.h - Move, deploy, enable, etc.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "../inc/MarlinConfig.h"
|
|
|
|
|
|
|
|
#if HAS_BED_PROBE
|
2019-09-25 04:29:21 +02:00
|
|
|
|
2019-09-29 11:25:39 +02:00
|
|
|
extern xyz_pos_t probe_offset;
|
2019-09-25 15:58:27 +02:00
|
|
|
|
2020-01-04 00:46:26 +01:00
|
|
|
#if HAS_PROBE_XY_OFFSET
|
|
|
|
extern xyz_pos_t &probe_offset_xy;
|
|
|
|
#else
|
|
|
|
constexpr xy_pos_t probe_offset_xy{0};
|
|
|
|
#endif
|
|
|
|
|
2017-11-19 20:59:40 +01:00
|
|
|
bool set_probe_deployed(const bool deploy);
|
2018-04-30 10:25:47 +02:00
|
|
|
#ifdef Z_AFTER_PROBING
|
2018-03-11 19:07:55 +01:00
|
|
|
void move_z_after_probing();
|
|
|
|
#endif
|
2018-03-21 07:01:43 +01:00
|
|
|
enum ProbePtRaise : unsigned char {
|
|
|
|
PROBE_PT_NONE, // No raise or stow after run_z_probe
|
|
|
|
PROBE_PT_STOW, // Do a complete stow after run_z_probe
|
2018-04-12 04:14:48 +02:00
|
|
|
PROBE_PT_RAISE, // Raise to "between" clearance after run_z_probe
|
|
|
|
PROBE_PT_BIG_RAISE // Raise to big clearance after run_z_probe
|
2018-03-21 07:01:43 +01:00
|
|
|
};
|
2019-09-18 01:16:28 +02:00
|
|
|
float probe_at_point(const float &rx, const float &ry, const ProbePtRaise raise_after=PROBE_PT_NONE, const uint8_t verbose_level=0, const bool probe_relative=true);
|
2019-09-29 11:25:39 +02:00
|
|
|
inline float probe_at_point(const xy_pos_t &pos, const ProbePtRaise raise_after=PROBE_PT_NONE, const uint8_t verbose_level=0, const bool probe_relative=true) {
|
|
|
|
return probe_at_point(pos.x, pos.y, raise_after, verbose_level, probe_relative);
|
|
|
|
}
|
2017-09-08 22:35:25 +02:00
|
|
|
#define DEPLOY_PROBE() set_probe_deployed(true)
|
|
|
|
#define STOW_PROBE() set_probe_deployed(false)
|
2018-04-24 00:13:01 +02:00
|
|
|
#if HAS_HEATED_BED && ENABLED(WAIT_FOR_BED_HEATER)
|
2018-04-21 22:43:21 +02:00
|
|
|
extern const char msg_wait_for_bed_heating[25];
|
|
|
|
#endif
|
2019-09-25 04:29:21 +02:00
|
|
|
|
2017-09-08 22:35:25 +02:00
|
|
|
#else
|
2019-09-25 04:29:21 +02:00
|
|
|
|
2019-09-29 11:25:39 +02:00
|
|
|
constexpr xyz_pos_t probe_offset{0};
|
2020-01-04 00:46:26 +01:00
|
|
|
constexpr xy_pos_t probe_offset_xy{0};
|
2019-09-29 11:25:39 +02:00
|
|
|
|
2017-09-08 22:35:25 +02:00
|
|
|
#define DEPLOY_PROBE()
|
|
|
|
#define STOW_PROBE()
|
2019-09-25 04:29:21 +02:00
|
|
|
|
2019-09-28 08:19:11 +02:00
|
|
|
#endif
|
|
|
|
|
2020-01-20 08:44:36 +01:00
|
|
|
#if HAS_BED_PROBE || HAS_LEVELING
|
2019-11-21 10:26:00 +01:00
|
|
|
#if IS_KINEMATIC
|
2019-11-24 00:01:49 +01:00
|
|
|
constexpr float printable_radius = (
|
2019-11-21 10:26:00 +01:00
|
|
|
#if ENABLED(DELTA)
|
2019-11-24 00:01:49 +01:00
|
|
|
DELTA_PRINTABLE_RADIUS
|
2019-11-21 10:26:00 +01:00
|
|
|
#elif IS_SCARA
|
2019-11-24 00:01:49 +01:00
|
|
|
SCARA_PRINTABLE_RADIUS
|
2019-11-21 10:26:00 +01:00
|
|
|
#endif
|
2019-11-24 00:01:49 +01:00
|
|
|
);
|
|
|
|
|
2019-11-21 10:26:00 +01:00
|
|
|
inline float probe_radius() {
|
2020-01-04 00:46:26 +01:00
|
|
|
return printable_radius - _MAX(MIN_PROBE_EDGE, HYPOT(probe_offset_xy.x, probe_offset_xy.y));
|
2019-11-21 10:26:00 +01:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2019-09-28 08:19:11 +02:00
|
|
|
inline float probe_min_x() {
|
2019-11-24 00:01:49 +01:00
|
|
|
return (
|
2019-09-28 08:19:11 +02:00
|
|
|
#if IS_KINEMATIC
|
2019-11-24 00:01:49 +01:00
|
|
|
(X_CENTER) - probe_radius()
|
2019-09-28 08:19:11 +02:00
|
|
|
#else
|
2020-01-04 00:46:26 +01:00
|
|
|
_MAX((X_MIN_BED) + (MIN_PROBE_EDGE_LEFT), (X_MIN_POS) + probe_offset_xy.x)
|
2019-09-28 08:19:11 +02:00
|
|
|
#endif
|
2019-11-24 00:01:49 +01:00
|
|
|
);
|
2019-09-28 08:19:11 +02:00
|
|
|
}
|
|
|
|
inline float probe_max_x() {
|
2019-11-24 00:01:49 +01:00
|
|
|
return (
|
2019-09-28 08:19:11 +02:00
|
|
|
#if IS_KINEMATIC
|
2019-11-24 00:01:49 +01:00
|
|
|
(X_CENTER) + probe_radius()
|
2019-09-28 08:19:11 +02:00
|
|
|
#else
|
2020-01-04 00:46:26 +01:00
|
|
|
_MIN((X_MAX_BED) - (MIN_PROBE_EDGE_RIGHT), (X_MAX_POS) + probe_offset_xy.x)
|
2019-09-28 08:19:11 +02:00
|
|
|
#endif
|
2019-11-24 00:01:49 +01:00
|
|
|
);
|
2019-09-28 08:19:11 +02:00
|
|
|
}
|
|
|
|
inline float probe_min_y() {
|
2019-11-24 00:01:49 +01:00
|
|
|
return (
|
2019-09-28 08:19:11 +02:00
|
|
|
#if IS_KINEMATIC
|
2019-11-24 00:01:49 +01:00
|
|
|
(Y_CENTER) - probe_radius()
|
2019-09-28 08:19:11 +02:00
|
|
|
#else
|
2020-01-04 00:46:26 +01:00
|
|
|
_MAX((Y_MIN_BED) + (MIN_PROBE_EDGE_FRONT), (Y_MIN_POS) + probe_offset_xy.y)
|
2019-09-28 08:19:11 +02:00
|
|
|
#endif
|
2019-11-24 00:01:49 +01:00
|
|
|
);
|
2019-09-28 08:19:11 +02:00
|
|
|
}
|
|
|
|
inline float probe_max_y() {
|
2019-11-24 00:01:49 +01:00
|
|
|
return (
|
2019-09-28 08:19:11 +02:00
|
|
|
#if IS_KINEMATIC
|
2019-11-24 00:01:49 +01:00
|
|
|
(Y_CENTER) + probe_radius()
|
2019-09-28 08:19:11 +02:00
|
|
|
#else
|
2020-01-04 00:46:26 +01:00
|
|
|
_MIN((Y_MAX_BED) - (MIN_PROBE_EDGE_BACK), (Y_MAX_POS) + probe_offset_xy.y)
|
2019-09-28 08:19:11 +02:00
|
|
|
#endif
|
2019-11-24 00:01:49 +01:00
|
|
|
);
|
2019-09-28 08:19:11 +02:00
|
|
|
}
|
2019-11-21 10:26:00 +01:00
|
|
|
|
|
|
|
#if NEEDS_THREE_PROBE_POINTS
|
|
|
|
// Retrieve three points to probe the bed. Any type exposing set(X,Y) may be used.
|
|
|
|
template <typename T>
|
|
|
|
inline void get_three_probe_points(T points[3]) {
|
|
|
|
#if ENABLED(HAS_FIXED_3POINT)
|
|
|
|
points[0].set(PROBE_PT_1_X, PROBE_PT_1_Y);
|
|
|
|
points[1].set(PROBE_PT_2_X, PROBE_PT_2_Y);
|
|
|
|
points[2].set(PROBE_PT_3_X, PROBE_PT_3_Y);
|
|
|
|
#else
|
|
|
|
#if IS_KINEMATIC
|
|
|
|
constexpr float SIN0 = 0.0, SIN120 = 0.866025, SIN240 = -0.866025,
|
|
|
|
COS0 = 1.0, COS120 = -0.5 , COS240 = -0.5;
|
|
|
|
points[0].set((X_CENTER) + probe_radius() * COS0, (Y_CENTER) + probe_radius() * SIN0);
|
|
|
|
points[1].set((X_CENTER) + probe_radius() * COS120, (Y_CENTER) + probe_radius() * SIN120);
|
|
|
|
points[2].set((X_CENTER) + probe_radius() * COS240, (Y_CENTER) + probe_radius() * SIN240);
|
|
|
|
#else
|
|
|
|
points[0].set(probe_min_x(), probe_min_y());
|
|
|
|
points[1].set(probe_max_x(), probe_min_y());
|
|
|
|
points[2].set((probe_max_x() - probe_min_x()) / 2, probe_max_y());
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
#endif
|
2017-09-08 22:35:25 +02:00
|
|
|
#endif
|
|
|
|
|
2018-04-02 06:54:12 +02:00
|
|
|
#if HAS_Z_SERVO_PROBE
|
2017-09-08 22:35:25 +02:00
|
|
|
void servo_probe_init();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if QUIET_PROBING
|
|
|
|
void probing_pause(const bool p);
|
|
|
|
#endif
|