My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
  4. *
  5. * Based on Sprinter and grbl.
  6. * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. #ifndef MARLIN_H
  23. #define MARLIN_H
  24. #include <math.h>
  25. #include <stdio.h>
  26. #include <stdlib.h>
  27. #include <string.h>
  28. #include <inttypes.h>
  29. #include <util/delay.h>
  30. #include <avr/pgmspace.h>
  31. #include <avr/eeprom.h>
  32. #include <avr/interrupt.h>
  33. #include "MarlinConfig.h"
  34. #ifdef DEBUG_GCODE_PARSER
  35. #include "gcode.h"
  36. #endif
  37. #include "enum.h"
  38. #include "types.h"
  39. #include "fastio.h"
  40. #include "utility.h"
  41. #include "serial.h"
  42. #if ENABLED(PRINTCOUNTER)
  43. #include "printcounter.h"
  44. #else
  45. #include "stopwatch.h"
  46. #endif
  47. void idle(
  48. #if ENABLED(ADVANCED_PAUSE_FEATURE)
  49. bool no_stepper_sleep = false // pass true to keep steppers from disabling on timeout
  50. #endif
  51. );
  52. void manage_inactivity(bool ignore_stepper_queue = false);
  53. #if ENABLED(DUAL_X_CARRIAGE) || ENABLED(DUAL_NOZZLE_DUPLICATION_MODE)
  54. extern bool extruder_duplication_enabled;
  55. #endif
  56. #if HAS_X2_ENABLE
  57. #define enable_X() do{ X_ENABLE_WRITE( X_ENABLE_ON); X2_ENABLE_WRITE( X_ENABLE_ON); }while(0)
  58. #define disable_X() do{ X_ENABLE_WRITE(!X_ENABLE_ON); X2_ENABLE_WRITE(!X_ENABLE_ON); axis_known_position[X_AXIS] = false; }while(0)
  59. #elif HAS_X_ENABLE
  60. #define enable_X() X_ENABLE_WRITE( X_ENABLE_ON)
  61. #define disable_X() do{ X_ENABLE_WRITE(!X_ENABLE_ON); axis_known_position[X_AXIS] = false; }while(0)
  62. #else
  63. #define enable_X() NOOP
  64. #define disable_X() NOOP
  65. #endif
  66. #if HAS_Y2_ENABLE
  67. #define enable_Y() do{ Y_ENABLE_WRITE( Y_ENABLE_ON); Y2_ENABLE_WRITE(Y_ENABLE_ON); }while(0)
  68. #define disable_Y() do{ Y_ENABLE_WRITE(!Y_ENABLE_ON); Y2_ENABLE_WRITE(!Y_ENABLE_ON); axis_known_position[Y_AXIS] = false; }while(0)
  69. #elif HAS_Y_ENABLE
  70. #define enable_Y() Y_ENABLE_WRITE( Y_ENABLE_ON)
  71. #define disable_Y() do{ Y_ENABLE_WRITE(!Y_ENABLE_ON); axis_known_position[Y_AXIS] = false; }while(0)
  72. #else
  73. #define enable_Y() NOOP
  74. #define disable_Y() NOOP
  75. #endif
  76. #if HAS_Z2_ENABLE
  77. #define enable_Z() do{ Z_ENABLE_WRITE( Z_ENABLE_ON); Z2_ENABLE_WRITE(Z_ENABLE_ON); }while(0)
  78. #define disable_Z() do{ Z_ENABLE_WRITE(!Z_ENABLE_ON); Z2_ENABLE_WRITE(!Z_ENABLE_ON); axis_known_position[Z_AXIS] = false; }while(0)
  79. #elif HAS_Z_ENABLE
  80. #define enable_Z() Z_ENABLE_WRITE( Z_ENABLE_ON)
  81. #define disable_Z() do{ Z_ENABLE_WRITE(!Z_ENABLE_ON); axis_known_position[Z_AXIS] = false; }while(0)
  82. #else
  83. #define enable_Z() NOOP
  84. #define disable_Z() NOOP
  85. #endif
  86. #if ENABLED(MIXING_EXTRUDER)
  87. /**
  88. * Mixing steppers synchronize their enable (and direction) together
  89. */
  90. #if MIXING_STEPPERS > 3
  91. #define enable_E0() { E0_ENABLE_WRITE( E_ENABLE_ON); E1_ENABLE_WRITE( E_ENABLE_ON); E2_ENABLE_WRITE( E_ENABLE_ON); E3_ENABLE_WRITE( E_ENABLE_ON); }
  92. #define disable_E0() { E0_ENABLE_WRITE(!E_ENABLE_ON); E1_ENABLE_WRITE(!E_ENABLE_ON); E2_ENABLE_WRITE(!E_ENABLE_ON); E3_ENABLE_WRITE(!E_ENABLE_ON); }
  93. #elif MIXING_STEPPERS > 2
  94. #define enable_E0() { E0_ENABLE_WRITE( E_ENABLE_ON); E1_ENABLE_WRITE( E_ENABLE_ON); E2_ENABLE_WRITE( E_ENABLE_ON); }
  95. #define disable_E0() { E0_ENABLE_WRITE(!E_ENABLE_ON); E1_ENABLE_WRITE(!E_ENABLE_ON); E2_ENABLE_WRITE(!E_ENABLE_ON); }
  96. #else
  97. #define enable_E0() { E0_ENABLE_WRITE( E_ENABLE_ON); E1_ENABLE_WRITE( E_ENABLE_ON); }
  98. #define disable_E0() { E0_ENABLE_WRITE(!E_ENABLE_ON); E1_ENABLE_WRITE(!E_ENABLE_ON); }
  99. #endif
  100. #define enable_E1() NOOP
  101. #define disable_E1() NOOP
  102. #define enable_E2() NOOP
  103. #define disable_E2() NOOP
  104. #define enable_E3() NOOP
  105. #define disable_E3() NOOP
  106. #define enable_E4() NOOP
  107. #define disable_E4() NOOP
  108. #else // !MIXING_EXTRUDER
  109. #if HAS_E0_ENABLE
  110. #define enable_E0() E0_ENABLE_WRITE( E_ENABLE_ON)
  111. #define disable_E0() E0_ENABLE_WRITE(!E_ENABLE_ON)
  112. #else
  113. #define enable_E0() NOOP
  114. #define disable_E0() NOOP
  115. #endif
  116. #if E_STEPPERS > 1 && HAS_E1_ENABLE
  117. #define enable_E1() E1_ENABLE_WRITE( E_ENABLE_ON)
  118. #define disable_E1() E1_ENABLE_WRITE(!E_ENABLE_ON)
  119. #else
  120. #define enable_E1() NOOP
  121. #define disable_E1() NOOP
  122. #endif
  123. #if E_STEPPERS > 2 && HAS_E2_ENABLE
  124. #define enable_E2() E2_ENABLE_WRITE( E_ENABLE_ON)
  125. #define disable_E2() E2_ENABLE_WRITE(!E_ENABLE_ON)
  126. #else
  127. #define enable_E2() NOOP
  128. #define disable_E2() NOOP
  129. #endif
  130. #if E_STEPPERS > 3 && HAS_E3_ENABLE
  131. #define enable_E3() E3_ENABLE_WRITE( E_ENABLE_ON)
  132. #define disable_E3() E3_ENABLE_WRITE(!E_ENABLE_ON)
  133. #else
  134. #define enable_E3() NOOP
  135. #define disable_E3() NOOP
  136. #endif
  137. #if E_STEPPERS > 4 && HAS_E4_ENABLE
  138. #define enable_E4() E4_ENABLE_WRITE( E_ENABLE_ON)
  139. #define disable_E4() E4_ENABLE_WRITE(!E_ENABLE_ON)
  140. #else
  141. #define enable_E4() NOOP
  142. #define disable_E4() NOOP
  143. #endif
  144. #endif // !MIXING_EXTRUDER
  145. #if ENABLED(G38_PROBE_TARGET)
  146. extern bool G38_move, // flag to tell the interrupt handler that a G38 command is being run
  147. G38_endstop_hit; // flag from the interrupt handler to indicate if the endstop went active
  148. #endif
  149. /**
  150. * The axis order in all axis related arrays is X, Y, Z, E
  151. */
  152. #define _AXIS(AXIS) AXIS ##_AXIS
  153. void enable_all_steppers();
  154. void disable_e_steppers();
  155. void disable_all_steppers();
  156. void FlushSerialRequestResend();
  157. void ok_to_send();
  158. void kill(const char*);
  159. void quickstop_stepper();
  160. #if ENABLED(FILAMENT_RUNOUT_SENSOR)
  161. void handle_filament_runout();
  162. #endif
  163. extern uint8_t marlin_debug_flags;
  164. #define DEBUGGING(F) (marlin_debug_flags & (DEBUG_## F))
  165. extern bool Running;
  166. inline bool IsRunning() { return Running; }
  167. inline bool IsStopped() { return !Running; }
  168. bool enqueue_and_echo_command(const char* cmd, bool say_ok=false); // Add a single command to the end of the buffer. Return false on failure.
  169. void enqueue_and_echo_commands_P(const char * const cmd); // Set one or more commands to be prioritized over the next Serial/SD command.
  170. void clear_command_queue();
  171. extern millis_t previous_cmd_ms;
  172. inline void refresh_cmd_timeout() { previous_cmd_ms = millis(); }
  173. #if ENABLED(FAST_PWM_FAN)
  174. void setPwmFrequency(uint8_t pin, int val);
  175. #endif
  176. /**
  177. * Feedrate scaling and conversion
  178. */
  179. extern int16_t feedrate_percentage;
  180. #define MMS_SCALED(MM_S) ((MM_S)*feedrate_percentage*0.01)
  181. extern bool axis_relative_modes[];
  182. extern bool axis_known_position[XYZ];
  183. extern bool axis_homed[XYZ];
  184. extern volatile bool wait_for_heatup;
  185. #if HAS_RESUME_CONTINUE
  186. extern volatile bool wait_for_user;
  187. #endif
  188. extern float current_position[NUM_AXIS];
  189. // Workspace offsets
  190. #if HAS_WORKSPACE_OFFSET
  191. #if HAS_HOME_OFFSET
  192. extern float home_offset[XYZ];
  193. #endif
  194. #if HAS_POSITION_SHIFT
  195. extern float position_shift[XYZ];
  196. #endif
  197. #endif
  198. #if HAS_HOME_OFFSET && HAS_POSITION_SHIFT
  199. extern float workspace_offset[XYZ];
  200. #define WORKSPACE_OFFSET(AXIS) workspace_offset[AXIS]
  201. #elif HAS_HOME_OFFSET
  202. #define WORKSPACE_OFFSET(AXIS) home_offset[AXIS]
  203. #elif HAS_POSITION_SHIFT
  204. #define WORKSPACE_OFFSET(AXIS) position_shift[AXIS]
  205. #else
  206. #define WORKSPACE_OFFSET(AXIS) 0
  207. #endif
  208. #define NATIVE_TO_LOGICAL(POS, AXIS) ((POS) + WORKSPACE_OFFSET(AXIS))
  209. #define LOGICAL_TO_NATIVE(POS, AXIS) ((POS) - WORKSPACE_OFFSET(AXIS))
  210. #if HAS_POSITION_SHIFT || DISABLED(DELTA)
  211. #define LOGICAL_X_POSITION(POS) NATIVE_TO_LOGICAL(POS, X_AXIS)
  212. #define LOGICAL_Y_POSITION(POS) NATIVE_TO_LOGICAL(POS, Y_AXIS)
  213. #define RAW_X_POSITION(POS) LOGICAL_TO_NATIVE(POS, X_AXIS)
  214. #define RAW_Y_POSITION(POS) LOGICAL_TO_NATIVE(POS, Y_AXIS)
  215. #else
  216. #define LOGICAL_X_POSITION(POS) (POS)
  217. #define LOGICAL_Y_POSITION(POS) (POS)
  218. #define RAW_X_POSITION(POS) (POS)
  219. #define RAW_Y_POSITION(POS) (POS)
  220. #endif
  221. #define LOGICAL_Z_POSITION(POS) NATIVE_TO_LOGICAL(POS, Z_AXIS)
  222. #define RAW_Z_POSITION(POS) LOGICAL_TO_NATIVE(POS, Z_AXIS)
  223. // Hotend Offsets
  224. #if HOTENDS > 1
  225. extern float hotend_offset[XYZ][HOTENDS];
  226. #endif
  227. // Software Endstops
  228. extern float soft_endstop_min[XYZ], soft_endstop_max[XYZ];
  229. #if HAS_SOFTWARE_ENDSTOPS
  230. extern bool soft_endstops_enabled;
  231. void clamp_to_software_endstops(float target[XYZ]);
  232. #else
  233. #define soft_endstops_enabled false
  234. #define clamp_to_software_endstops(x) NOOP
  235. #endif
  236. #if HAS_WORKSPACE_OFFSET || ENABLED(DUAL_X_CARRIAGE)
  237. void update_software_endstops(const AxisEnum axis);
  238. #endif
  239. #if ENABLED(CNC_COORDINATE_SYSTEMS)
  240. #define MAX_COORDINATE_SYSTEMS 9
  241. extern float coordinate_system[MAX_COORDINATE_SYSTEMS][XYZ];
  242. bool select_coordinate_system(const int8_t _new);
  243. #endif
  244. void report_current_position();
  245. #if IS_KINEMATIC
  246. extern float delta[ABC];
  247. void inverse_kinematics(const float raw[XYZ]);
  248. #endif
  249. #if ENABLED(DELTA)
  250. extern float delta_height,
  251. delta_endstop_adj[ABC],
  252. delta_radius,
  253. delta_diagonal_rod,
  254. delta_calibration_radius,
  255. delta_segments_per_second,
  256. delta_tower_angle_trim[ABC],
  257. delta_clip_start_height;
  258. void recalc_delta_settings();
  259. #elif IS_SCARA
  260. void forward_kinematics_SCARA(const float &a, const float &b);
  261. #endif
  262. #if ENABLED(G26_MESH_VALIDATION)
  263. extern bool g26_debug_flag;
  264. #elif ENABLED(AUTO_BED_LEVELING_UBL)
  265. constexpr bool g26_debug_flag = false;
  266. #endif
  267. #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
  268. #define _GET_MESH_X(I) bilinear_start[X_AXIS] + I * bilinear_grid_spacing[X_AXIS]
  269. #define _GET_MESH_Y(J) bilinear_start[Y_AXIS] + J * bilinear_grid_spacing[Y_AXIS]
  270. #elif ENABLED(AUTO_BED_LEVELING_UBL)
  271. #define _GET_MESH_X(I) ubl.mesh_index_to_xpos(I)
  272. #define _GET_MESH_Y(J) ubl.mesh_index_to_ypos(J)
  273. #elif ENABLED(MESH_BED_LEVELING)
  274. #define _GET_MESH_X(I) mbl.index_to_xpos[I]
  275. #define _GET_MESH_Y(J) mbl.index_to_ypos[J]
  276. #endif
  277. #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
  278. extern int bilinear_grid_spacing[2], bilinear_start[2];
  279. extern float bilinear_grid_factor[2],
  280. z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
  281. float bilinear_z_offset(const float raw[XYZ]);
  282. #endif
  283. #if ENABLED(AUTO_BED_LEVELING_UBL)
  284. typedef struct { double A, B, D; } linear_fit;
  285. linear_fit* lsf_linear_fit(double x[], double y[], double z[], const int);
  286. #endif
  287. #if HAS_LEVELING
  288. bool leveling_is_valid();
  289. void set_bed_leveling_enabled(const bool enable=true);
  290. void reset_bed_level();
  291. #endif
  292. #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
  293. void set_z_fade_height(const float zfh);
  294. #endif
  295. #if ENABLED(X_DUAL_ENDSTOPS)
  296. extern float x_endstop_adj;
  297. #endif
  298. #if ENABLED(Y_DUAL_ENDSTOPS)
  299. extern float y_endstop_adj;
  300. #endif
  301. #if ENABLED(Z_DUAL_ENDSTOPS)
  302. extern float z_endstop_adj;
  303. #endif
  304. #if HAS_BED_PROBE
  305. extern float zprobe_zoffset;
  306. #define DEPLOY_PROBE() set_probe_deployed(true)
  307. #define STOW_PROBE() set_probe_deployed(false)
  308. #else
  309. #define DEPLOY_PROBE()
  310. #define STOW_PROBE()
  311. #endif
  312. #if ENABLED(HOST_KEEPALIVE_FEATURE)
  313. extern MarlinBusyState busy_state;
  314. #define KEEPALIVE_STATE(n) do{ busy_state = n; }while(0)
  315. #else
  316. #define KEEPALIVE_STATE(n) NOOP
  317. #endif
  318. #if FAN_COUNT > 0
  319. extern int16_t fanSpeeds[FAN_COUNT];
  320. #if ENABLED(EXTRA_FAN_SPEED)
  321. extern int16_t old_fanSpeeds[FAN_COUNT],
  322. new_fanSpeeds[FAN_COUNT];
  323. #endif
  324. #if ENABLED(PROBING_FANS_OFF)
  325. extern bool fans_paused;
  326. extern int16_t paused_fanSpeeds[FAN_COUNT];
  327. #endif
  328. #endif
  329. #if ENABLED(BARICUDA)
  330. extern uint8_t baricuda_valve_pressure, baricuda_e_to_p_pressure;
  331. #endif
  332. #if ENABLED(FILAMENT_WIDTH_SENSOR)
  333. extern bool filament_sensor; // Flag that filament sensor readings should control extrusion
  334. extern float filament_width_nominal, // Theoretical filament diameter i.e., 3.00 or 1.75
  335. filament_width_meas; // Measured filament diameter
  336. extern uint8_t meas_delay_cm, // Delay distance
  337. measurement_delay[]; // Ring buffer to delay measurement
  338. extern int8_t filwidth_delay_index[2]; // Ring buffer indexes. Used by planner, temperature, and main code
  339. #endif
  340. #if ENABLED(ADVANCED_PAUSE_FEATURE)
  341. extern AdvancedPauseMenuResponse advanced_pause_menu_response;
  342. #endif
  343. #if ENABLED(PID_EXTRUSION_SCALING)
  344. extern int lpq_len;
  345. #endif
  346. #if ENABLED(FWRETRACT)
  347. extern bool autoretract_enabled; // M209 S - Autoretract switch
  348. extern float retract_length, // M207 S - G10 Retract length
  349. retract_feedrate_mm_s, // M207 F - G10 Retract feedrate
  350. retract_zlift, // M207 Z - G10 Retract hop size
  351. retract_recover_length, // M208 S - G11 Recover length
  352. retract_recover_feedrate_mm_s, // M208 F - G11 Recover feedrate
  353. swap_retract_length, // M207 W - G10 Swap Retract length
  354. swap_retract_recover_length, // M208 W - G11 Swap Recover length
  355. swap_retract_recover_feedrate_mm_s; // M208 R - G11 Swap Recover feedrate
  356. #endif
  357. // Print job timer
  358. #if ENABLED(PRINTCOUNTER)
  359. extern PrintCounter print_job_timer;
  360. #else
  361. extern Stopwatch print_job_timer;
  362. #endif
  363. // Handling multiple extruders pins
  364. extern uint8_t active_extruder;
  365. #if HAS_TEMP_HOTEND || HAS_TEMP_BED
  366. void print_heaterstates();
  367. #endif
  368. #if ENABLED(MIXING_EXTRUDER)
  369. extern float mixing_factor[MIXING_STEPPERS];
  370. #endif
  371. /**
  372. * Blocking movement and shorthand functions
  373. */
  374. void do_blocking_move_to(const float &x, const float &y, const float &z, const float &fr_mm_s=0.0);
  375. void do_blocking_move_to_x(const float &x, const float &fr_mm_s=0.0);
  376. void do_blocking_move_to_z(const float &z, const float &fr_mm_s=0.0);
  377. void do_blocking_move_to_xy(const float &x, const float &y, const float &fr_mm_s=0.0);
  378. #define HAS_AXIS_UNHOMED_ERR ( \
  379. ENABLED(Z_PROBE_ALLEN_KEY) \
  380. || ENABLED(Z_PROBE_SLED) \
  381. || HAS_PROBING_PROCEDURE \
  382. || HOTENDS > 1 \
  383. || ENABLED(NOZZLE_CLEAN_FEATURE) \
  384. || ENABLED(NOZZLE_PARK_FEATURE) \
  385. || (ENABLED(ADVANCED_PAUSE_FEATURE) && ENABLED(HOME_BEFORE_FILAMENT_CHANGE)) \
  386. || HAS_M206_COMMAND \
  387. ) || ENABLED(NO_MOTION_BEFORE_HOMING)
  388. #if HAS_AXIS_UNHOMED_ERR
  389. bool axis_unhomed_error(const bool x=true, const bool y=true, const bool z=true);
  390. #endif
  391. /**
  392. * position_is_reachable family of functions
  393. */
  394. #if IS_KINEMATIC // (DELTA or SCARA)
  395. #if IS_SCARA
  396. extern const float L1, L2;
  397. #endif
  398. inline bool position_is_reachable(const float &rx, const float &ry) {
  399. #if ENABLED(DELTA)
  400. return HYPOT2(rx, ry) <= sq(DELTA_PRINTABLE_RADIUS);
  401. #elif IS_SCARA
  402. #if MIDDLE_DEAD_ZONE_R > 0
  403. const float R2 = HYPOT2(rx - SCARA_OFFSET_X, ry - SCARA_OFFSET_Y);
  404. return R2 >= sq(float(MIDDLE_DEAD_ZONE_R)) && R2 <= sq(L1 + L2);
  405. #else
  406. return HYPOT2(rx - SCARA_OFFSET_X, ry - SCARA_OFFSET_Y) <= sq(L1 + L2);
  407. #endif
  408. #else // CARTESIAN
  409. // To be migrated from MakerArm branch in future
  410. #endif
  411. }
  412. inline bool position_is_reachable_by_probe(const float &rx, const float &ry) {
  413. // Both the nozzle and the probe must be able to reach the point.
  414. // This won't work on SCARA since the probe offset rotates with the arm.
  415. return position_is_reachable(rx, ry)
  416. && position_is_reachable(rx - (X_PROBE_OFFSET_FROM_EXTRUDER), ry - (Y_PROBE_OFFSET_FROM_EXTRUDER));
  417. }
  418. #else // CARTESIAN
  419. inline bool position_is_reachable(const float &rx, const float &ry) {
  420. // Add 0.001 margin to deal with float imprecision
  421. return WITHIN(rx, X_MIN_POS - 0.001, X_MAX_POS + 0.001)
  422. && WITHIN(ry, Y_MIN_POS - 0.001, Y_MAX_POS + 0.001);
  423. }
  424. inline bool position_is_reachable_by_probe(const float &rx, const float &ry) {
  425. // Add 0.001 margin to deal with float imprecision
  426. return WITHIN(rx, MIN_PROBE_X - 0.001, MAX_PROBE_X + 0.001)
  427. && WITHIN(ry, MIN_PROBE_Y - 0.001, MAX_PROBE_Y + 0.001);
  428. }
  429. #endif // CARTESIAN
  430. #endif // MARLIN_H