My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

G28.cpp 18KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2020 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 <https://www.gnu.org/licenses/>.
  20. *
  21. */
  22. #include "../../inc/MarlinConfig.h"
  23. #include "../gcode.h"
  24. #include "../../module/stepper.h"
  25. #include "../../module/endstops.h"
  26. #if HAS_MULTI_HOTEND
  27. #include "../../module/tool_change.h"
  28. #endif
  29. #if HAS_LEVELING
  30. #include "../../feature/bedlevel/bedlevel.h"
  31. #endif
  32. #if ENABLED(SENSORLESS_HOMING)
  33. #include "../../feature/tmc_util.h"
  34. #endif
  35. #include "../../module/probe.h"
  36. #if ENABLED(BLTOUCH)
  37. #include "../../feature/bltouch.h"
  38. #endif
  39. #include "../../lcd/marlinui.h"
  40. #if ENABLED(EXTENSIBLE_UI)
  41. #include "../../lcd/extui/ui_api.h"
  42. #elif ENABLED(DWIN_CREALITY_LCD)
  43. #include "../../lcd/e3v2/creality/dwin.h"
  44. #elif ENABLED(DWIN_CREALITY_LCD_ENHANCED)
  45. #include "../../lcd/e3v2/enhanced/dwin.h"
  46. #endif
  47. #if HAS_L64XX // set L6470 absolute position registers to counts
  48. #include "../../libs/L64XX/L64XX_Marlin.h"
  49. #endif
  50. #if ENABLED(LASER_MOVE_G28_OFF)
  51. #include "../../feature/spindle_laser.h"
  52. #endif
  53. #define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
  54. #include "../../core/debug_out.h"
  55. #if ENABLED(QUICK_HOME)
  56. static void quick_home_xy() {
  57. // Pretend the current position is 0,0
  58. current_position.set(0.0, 0.0);
  59. sync_plan_position();
  60. const int x_axis_home_dir = TOOL_X_HOME_DIR(active_extruder);
  61. const float mlx = max_length(X_AXIS),
  62. mly = max_length(Y_AXIS),
  63. mlratio = mlx > mly ? mly / mlx : mlx / mly,
  64. fr_mm_s = _MIN(homing_feedrate(X_AXIS), homing_feedrate(Y_AXIS)) * SQRT(sq(mlratio) + 1.0);
  65. #if ENABLED(SENSORLESS_HOMING)
  66. sensorless_t stealth_states {
  67. tmc_enable_stallguard(stepperX)
  68. , tmc_enable_stallguard(stepperY)
  69. , false
  70. , false
  71. #if AXIS_HAS_STALLGUARD(X2)
  72. || tmc_enable_stallguard(stepperX2)
  73. #endif
  74. , false
  75. #if AXIS_HAS_STALLGUARD(Y2)
  76. || tmc_enable_stallguard(stepperY2)
  77. #endif
  78. };
  79. #endif
  80. do_blocking_move_to_xy(1.5 * mlx * x_axis_home_dir, 1.5 * mly * Y_HOME_DIR, fr_mm_s);
  81. endstops.validate_homing_move();
  82. current_position.set(0.0, 0.0);
  83. #if ENABLED(SENSORLESS_HOMING) && DISABLED(ENDSTOPS_ALWAYS_ON_DEFAULT)
  84. tmc_disable_stallguard(stepperX, stealth_states.x);
  85. tmc_disable_stallguard(stepperY, stealth_states.y);
  86. #if AXIS_HAS_STALLGUARD(X2)
  87. tmc_disable_stallguard(stepperX2, stealth_states.x2);
  88. #endif
  89. #if AXIS_HAS_STALLGUARD(Y2)
  90. tmc_disable_stallguard(stepperY2, stealth_states.y2);
  91. #endif
  92. #endif
  93. }
  94. #endif // QUICK_HOME
  95. #if ENABLED(Z_SAFE_HOMING)
  96. inline void home_z_safely() {
  97. DEBUG_SECTION(log_G28, "home_z_safely", DEBUGGING(LEVELING));
  98. // Disallow Z homing if X or Y homing is needed
  99. if (homing_needed_error(_BV(X_AXIS) | _BV(Y_AXIS))) return;
  100. sync_plan_position();
  101. /**
  102. * Move the Z probe (or just the nozzle) to the safe homing point
  103. * (Z is already at the right height)
  104. */
  105. constexpr xy_float_t safe_homing_xy = { Z_SAFE_HOMING_X_POINT, Z_SAFE_HOMING_Y_POINT };
  106. #if HAS_HOME_OFFSET
  107. xy_float_t okay_homing_xy = safe_homing_xy;
  108. okay_homing_xy -= home_offset;
  109. #else
  110. constexpr xy_float_t okay_homing_xy = safe_homing_xy;
  111. #endif
  112. destination.set(okay_homing_xy, current_position.z);
  113. TERN_(HOMING_Z_WITH_PROBE, destination -= probe.offset_xy);
  114. if (position_is_reachable(destination)) {
  115. if (DEBUGGING(LEVELING)) DEBUG_POS("home_z_safely", destination);
  116. // Free the active extruder for movement
  117. TERN_(DUAL_X_CARRIAGE, idex_set_parked(false));
  118. TERN_(SENSORLESS_HOMING, safe_delay(500)); // Short delay needed to settle
  119. do_blocking_move_to_xy(destination);
  120. homeaxis(Z_AXIS);
  121. }
  122. else {
  123. LCD_MESSAGEPGM(MSG_ZPROBE_OUT);
  124. SERIAL_ECHO_MSG(STR_ZPROBE_OUT_SER);
  125. }
  126. }
  127. #endif // Z_SAFE_HOMING
  128. #if ENABLED(IMPROVE_HOMING_RELIABILITY)
  129. motion_state_t begin_slow_homing() {
  130. motion_state_t motion_state{0};
  131. motion_state.acceleration.set(planner.settings.max_acceleration_mm_per_s2[X_AXIS],
  132. planner.settings.max_acceleration_mm_per_s2[Y_AXIS]
  133. OPTARG(DELTA, planner.settings.max_acceleration_mm_per_s2[Z_AXIS])
  134. );
  135. planner.settings.max_acceleration_mm_per_s2[X_AXIS] = 100;
  136. planner.settings.max_acceleration_mm_per_s2[Y_AXIS] = 100;
  137. TERN_(DELTA, planner.settings.max_acceleration_mm_per_s2[Z_AXIS] = 100);
  138. #if HAS_CLASSIC_JERK
  139. motion_state.jerk_state = planner.max_jerk;
  140. planner.max_jerk.set(0, 0 OPTARG(DELTA, 0));
  141. #endif
  142. planner.reset_acceleration_rates();
  143. return motion_state;
  144. }
  145. void end_slow_homing(const motion_state_t &motion_state) {
  146. planner.settings.max_acceleration_mm_per_s2[X_AXIS] = motion_state.acceleration.x;
  147. planner.settings.max_acceleration_mm_per_s2[Y_AXIS] = motion_state.acceleration.y;
  148. TERN_(DELTA, planner.settings.max_acceleration_mm_per_s2[Z_AXIS] = motion_state.acceleration.z);
  149. TERN_(HAS_CLASSIC_JERK, planner.max_jerk = motion_state.jerk_state);
  150. planner.reset_acceleration_rates();
  151. }
  152. #endif // IMPROVE_HOMING_RELIABILITY
  153. /**
  154. * G28: Home all axes according to settings
  155. *
  156. * Parameters
  157. *
  158. * None Home to all axes with no parameters.
  159. * With QUICK_HOME enabled XY will home together, then Z.
  160. *
  161. * L<bool> Force leveling state ON (if possible) or OFF after homing (Requires RESTORE_LEVELING_AFTER_G28 or ENABLE_LEVELING_AFTER_G28)
  162. * O Home only if the position is not known and trusted
  163. * R<linear> Raise by n mm/inches before homing
  164. *
  165. * Cartesian/SCARA parameters
  166. *
  167. * X Home to the X endstop
  168. * Y Home to the Y endstop
  169. * Z Home to the Z endstop
  170. */
  171. void GcodeSuite::G28() {
  172. DEBUG_SECTION(log_G28, "G28", DEBUGGING(LEVELING));
  173. if (DEBUGGING(LEVELING)) log_machine_info();
  174. TERN_(LASER_MOVE_G28_OFF, cutter.set_inline_enabled(false)); // turn off laser
  175. TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(M_HOMING));
  176. #if ENABLED(DUAL_X_CARRIAGE)
  177. bool IDEX_saved_duplication_state = extruder_duplication_enabled;
  178. DualXMode IDEX_saved_mode = dual_x_carriage_mode;
  179. #endif
  180. #if ENABLED(MARLIN_DEV_MODE)
  181. if (parser.seen_test('S')) {
  182. LOOP_LINEAR_AXES(a) set_axis_is_at_home((AxisEnum)a);
  183. sync_plan_position();
  184. SERIAL_ECHOLNPGM("Simulated Homing");
  185. report_current_position();
  186. return;
  187. }
  188. #endif
  189. // Home (O)nly if position is unknown
  190. if (!axes_should_home() && parser.seen_test('O')) {
  191. if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("> homing not needed, skip");
  192. return;
  193. }
  194. TERN_(HAS_DWIN_E3V2_BASIC, DWIN_StartHoming());
  195. TERN_(EXTENSIBLE_UI, ExtUI::onHomingStart());
  196. planner.synchronize(); // Wait for planner moves to finish!
  197. SET_SOFT_ENDSTOP_LOOSE(false); // Reset a leftover 'loose' motion state
  198. // Disable the leveling matrix before homing
  199. #if CAN_SET_LEVELING_AFTER_G28
  200. const bool leveling_restore_state = parser.boolval('L', TERN1(RESTORE_LEVELING_AFTER_G28, planner.leveling_active));
  201. #endif
  202. // Cancel any prior G29 session
  203. TERN_(PROBE_MANUALLY, g29_in_progress = false);
  204. // Disable leveling before homing
  205. TERN_(HAS_LEVELING, set_bed_leveling_enabled(false));
  206. // Reset to the XY plane
  207. TERN_(CNC_WORKSPACE_PLANES, workspace_plane = PLANE_XY);
  208. // Count this command as movement / activity
  209. reset_stepper_timeout();
  210. #define HAS_CURRENT_HOME(N) (defined(N##_CURRENT_HOME) && N##_CURRENT_HOME != N##_CURRENT)
  211. #if HAS_CURRENT_HOME(X) || HAS_CURRENT_HOME(X2) || HAS_CURRENT_HOME(Y) || HAS_CURRENT_HOME(Y2) || (ENABLED(DELTA) && HAS_CURRENT_HOME(Z))
  212. #define HAS_HOMING_CURRENT 1
  213. #endif
  214. #if HAS_HOMING_CURRENT
  215. auto debug_current = [](PGM_P const s, const int16_t a, const int16_t b) {
  216. DEBUG_ECHOPGM_P(s); DEBUG_ECHOLNPAIR(" current: ", a, " -> ", b);
  217. };
  218. #if HAS_CURRENT_HOME(X)
  219. const int16_t tmc_save_current_X = stepperX.getMilliamps();
  220. stepperX.rms_current(X_CURRENT_HOME);
  221. if (DEBUGGING(LEVELING)) debug_current(PSTR("X"), tmc_save_current_X, X_CURRENT_HOME);
  222. #endif
  223. #if HAS_CURRENT_HOME(X2)
  224. const int16_t tmc_save_current_X2 = stepperX2.getMilliamps();
  225. stepperX2.rms_current(X2_CURRENT_HOME);
  226. if (DEBUGGING(LEVELING)) debug_current(PSTR("X2"), tmc_save_current_X2, X2_CURRENT_HOME);
  227. #endif
  228. #if HAS_CURRENT_HOME(Y)
  229. const int16_t tmc_save_current_Y = stepperY.getMilliamps();
  230. stepperY.rms_current(Y_CURRENT_HOME);
  231. if (DEBUGGING(LEVELING)) debug_current(PSTR("Y"), tmc_save_current_Y, Y_CURRENT_HOME);
  232. #endif
  233. #if HAS_CURRENT_HOME(Y2)
  234. const int16_t tmc_save_current_Y2 = stepperY2.getMilliamps();
  235. stepperY2.rms_current(Y2_CURRENT_HOME);
  236. if (DEBUGGING(LEVELING)) debug_current(PSTR("Y2"), tmc_save_current_Y2, Y2_CURRENT_HOME);
  237. #endif
  238. #if HAS_CURRENT_HOME(Z) && ENABLED(DELTA)
  239. const int16_t tmc_save_current_Z = stepperZ.getMilliamps();
  240. stepperZ.rms_current(Z_CURRENT_HOME);
  241. if (DEBUGGING(LEVELING)) debug_current(PSTR("Z"), tmc_save_current_Z, Z_CURRENT_HOME);
  242. #endif
  243. #endif
  244. #if ENABLED(IMPROVE_HOMING_RELIABILITY)
  245. motion_state_t saved_motion_state = begin_slow_homing();
  246. #endif
  247. // Always home with tool 0 active
  248. #if HAS_MULTI_HOTEND
  249. #if DISABLED(DELTA) || ENABLED(DELTA_HOME_TO_SAFE_ZONE)
  250. const uint8_t old_tool_index = active_extruder;
  251. #endif
  252. // PARKING_EXTRUDER homing requires different handling of movement / solenoid activation, depending on the side of homing
  253. #if ENABLED(PARKING_EXTRUDER)
  254. const bool pe_final_change_must_unpark = parking_extruder_unpark_after_homing(old_tool_index, X_HOME_DIR + 1 == old_tool_index * 2);
  255. #endif
  256. tool_change(0, true);
  257. #endif
  258. TERN_(HAS_DUPLICATION_MODE, set_duplication_enabled(false));
  259. remember_feedrate_scaling_off();
  260. endstops.enable(true); // Enable endstops for next homing move
  261. #if ENABLED(DELTA)
  262. constexpr bool doZ = true; // for NANODLP_Z_SYNC if your DLP is on a DELTA
  263. home_delta();
  264. TERN_(IMPROVE_HOMING_RELIABILITY, end_slow_homing(saved_motion_state));
  265. #elif ENABLED(AXEL_TPARA)
  266. constexpr bool doZ = true; // for NANODLP_Z_SYNC if your DLP is on a TPARA
  267. home_TPARA();
  268. #else
  269. #define _UNSAFE(A) (homeZ && TERN0(Z_SAFE_HOMING, axes_should_home(_BV(A##_AXIS))))
  270. const bool homeZ = TERN0(HAS_Z_AXIS, parser.seen_test('Z')),
  271. LINEAR_AXIS_LIST( // Other axes should be homed before Z safe-homing
  272. needX = _UNSAFE(X), needY = _UNSAFE(Y), needZ = false, // UNUSED
  273. needI = _UNSAFE(I), needJ = _UNSAFE(J), needK = _UNSAFE(K)
  274. ),
  275. LINEAR_AXIS_LIST( // Home each axis if needed or flagged
  276. homeX = needX || parser.seen_test('X'),
  277. homeY = needY || parser.seen_test('Y'),
  278. homeZZ = homeZ,
  279. homeI = needI || parser.seen_test(AXIS4_NAME), homeJ = needJ || parser.seen_test(AXIS5_NAME), homeK = needK || parser.seen_test(AXIS6_NAME),
  280. ),
  281. home_all = LINEAR_AXIS_GANG( // Home-all if all or none are flagged
  282. homeX == homeX, && homeY == homeX, && homeZ == homeX,
  283. && homeI == homeX, && homeJ == homeX, && homeK == homeX
  284. ),
  285. LINEAR_AXIS_LIST(
  286. doX = home_all || homeX, doY = home_all || homeY, doZ = home_all || homeZ,
  287. doI = home_all || homeI, doJ = home_all || homeJ, doK = home_all || homeK
  288. );
  289. #if HAS_Z_AXIS
  290. UNUSED(needZ); UNUSED(homeZZ);
  291. #else
  292. constexpr bool doZ = false;
  293. #endif
  294. TERN_(HOME_Z_FIRST, if (doZ) homeaxis(Z_AXIS));
  295. const float z_homing_height = parser.seenval('R') ? parser.value_linear_units() : Z_HOMING_HEIGHT;
  296. if (z_homing_height && (LINEAR_AXIS_GANG(doX, || doY, || TERN0(Z_SAFE_HOMING, doZ), || doI, || doJ, || doK))) {
  297. // Raise Z before homing any other axes and z is not already high enough (never lower z)
  298. if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Raise Z (before homing) by ", z_homing_height);
  299. do_z_clearance(z_homing_height);
  300. TERN_(BLTOUCH, bltouch.init());
  301. }
  302. // Diagonal move first if both are homing
  303. TERN_(QUICK_HOME, if (doX && doY) quick_home_xy());
  304. // Home Y (before X)
  305. if (ENABLED(HOME_Y_BEFORE_X) && (doY || TERN0(CODEPENDENT_XY_HOMING, doX)))
  306. homeaxis(Y_AXIS);
  307. // Home X
  308. if (doX || (doY && ENABLED(CODEPENDENT_XY_HOMING) && DISABLED(HOME_Y_BEFORE_X))) {
  309. #if ENABLED(DUAL_X_CARRIAGE)
  310. // Always home the 2nd (right) extruder first
  311. active_extruder = 1;
  312. homeaxis(X_AXIS);
  313. // Remember this extruder's position for later tool change
  314. inactive_extruder_x = current_position.x;
  315. // Home the 1st (left) extruder
  316. active_extruder = 0;
  317. homeaxis(X_AXIS);
  318. // Consider the active extruder to be in its "parked" position
  319. idex_set_parked();
  320. #else
  321. homeaxis(X_AXIS);
  322. #endif
  323. }
  324. // Home Y (after X)
  325. if (DISABLED(HOME_Y_BEFORE_X) && doY)
  326. homeaxis(Y_AXIS);
  327. TERN_(IMPROVE_HOMING_RELIABILITY, end_slow_homing(saved_motion_state));
  328. // Home Z last if homing towards the bed
  329. #if HAS_Z_AXIS && DISABLED(HOME_Z_FIRST)
  330. if (doZ) {
  331. #if EITHER(Z_MULTI_ENDSTOPS, Z_STEPPER_AUTO_ALIGN)
  332. stepper.set_all_z_lock(false);
  333. stepper.set_separate_multi_axis(false);
  334. #endif
  335. TERN(Z_SAFE_HOMING, home_z_safely(), homeaxis(Z_AXIS));
  336. probe.move_z_after_homing();
  337. }
  338. #endif
  339. #if LINEAR_AXES >= 4
  340. if (doI) homeaxis(I_AXIS);
  341. #endif
  342. #if LINEAR_AXES >= 5
  343. if (doJ) homeaxis(J_AXIS);
  344. #endif
  345. #if LINEAR_AXES >= 6
  346. if (doK) homeaxis(K_AXIS);
  347. #endif
  348. sync_plan_position();
  349. #endif
  350. /**
  351. * Preserve DXC mode across a G28 for IDEX printers in DXC_DUPLICATION_MODE.
  352. * This is important because it lets a user use the LCD Panel to set an IDEX Duplication mode, and
  353. * then print a standard GCode file that contains a single print that does a G28 and has no other
  354. * IDEX specific commands in it.
  355. */
  356. #if ENABLED(DUAL_X_CARRIAGE)
  357. if (idex_is_duplicating()) {
  358. TERN_(IMPROVE_HOMING_RELIABILITY, saved_motion_state = begin_slow_homing());
  359. // Always home the 2nd (right) extruder first
  360. active_extruder = 1;
  361. homeaxis(X_AXIS);
  362. // Remember this extruder's position for later tool change
  363. inactive_extruder_x = current_position.x;
  364. // Home the 1st (left) extruder
  365. active_extruder = 0;
  366. homeaxis(X_AXIS);
  367. // Consider the active extruder to be parked
  368. idex_set_parked();
  369. dual_x_carriage_mode = IDEX_saved_mode;
  370. set_duplication_enabled(IDEX_saved_duplication_state);
  371. TERN_(IMPROVE_HOMING_RELIABILITY, end_slow_homing(saved_motion_state));
  372. }
  373. #endif // DUAL_X_CARRIAGE
  374. endstops.not_homing();
  375. // Clear endstop state for polled stallGuard endstops
  376. TERN_(SPI_ENDSTOPS, endstops.clear_endstop_state());
  377. // Move to a height where we can use the full xy-area
  378. TERN_(DELTA_HOME_TO_SAFE_ZONE, do_blocking_move_to_z(delta_clip_start_height));
  379. TERN_(CAN_SET_LEVELING_AFTER_G28, if (leveling_restore_state) set_bed_leveling_enabled());
  380. restore_feedrate_and_scaling();
  381. // Restore the active tool after homing
  382. #if HAS_MULTI_HOTEND && (DISABLED(DELTA) || ENABLED(DELTA_HOME_TO_SAFE_ZONE))
  383. tool_change(old_tool_index, TERN(PARKING_EXTRUDER, !pe_final_change_must_unpark, DISABLED(DUAL_X_CARRIAGE))); // Do move if one of these
  384. #endif
  385. #if HAS_HOMING_CURRENT
  386. if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Restore driver current...");
  387. #if HAS_CURRENT_HOME(X)
  388. stepperX.rms_current(tmc_save_current_X);
  389. #endif
  390. #if HAS_CURRENT_HOME(X2)
  391. stepperX2.rms_current(tmc_save_current_X2);
  392. #endif
  393. #if HAS_CURRENT_HOME(Y)
  394. stepperY.rms_current(tmc_save_current_Y);
  395. #endif
  396. #if HAS_CURRENT_HOME(Y2)
  397. stepperY2.rms_current(tmc_save_current_Y2);
  398. #endif
  399. #if HAS_CURRENT_HOME(Z) && ENABLED(DELTA)
  400. stepperZ.rms_current(tmc_save_current_Z);
  401. #endif
  402. #if HAS_CURRENT_HOME(I)
  403. stepperI.rms_current(tmc_save_current_I);
  404. #endif
  405. #if HAS_CURRENT_HOME(J)
  406. stepperJ.rms_current(tmc_save_current_J);
  407. #endif
  408. #if HAS_CURRENT_HOME(K)
  409. stepperK.rms_current(tmc_save_current_K);
  410. #endif
  411. #endif // HAS_HOMING_CURRENT
  412. ui.refresh();
  413. TERN_(HAS_DWIN_E3V2_BASIC, DWIN_CompletedHoming());
  414. TERN_(EXTENSIBLE_UI, ExtUI::onHomingComplete());
  415. report_current_position();
  416. if (ENABLED(NANODLP_Z_SYNC) && (doZ || ENABLED(NANODLP_ALL_AXIS)))
  417. SERIAL_ECHOLNPGM(STR_Z_MOVE_COMP);
  418. TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(M_IDLE));
  419. #if HAS_L64XX
  420. // Set L6470 absolute position registers to counts
  421. // constexpr *might* move this to PROGMEM.
  422. // If not, this will need a PROGMEM directive and an accessor.
  423. #define _EN_ITEM(N) , E_AXIS
  424. static constexpr AxisEnum L64XX_axis_xref[MAX_L64XX] = {
  425. LINEAR_AXIS_LIST(X_AXIS, Y_AXIS, Z_AXIS, I_AXIS, J_AXIS, K_AXIS),
  426. X_AXIS, Y_AXIS, Z_AXIS, Z_AXIS, Z_AXIS
  427. REPEAT(E_STEPPERS, _EN_ITEM)
  428. };
  429. #undef _EN_ITEM
  430. for (uint8_t j = 1; j <= L64XX::chain[0]; j++) {
  431. const uint8_t cv = L64XX::chain[j];
  432. L64xxManager.set_param((L64XX_axis_t)cv, L6470_ABS_POS, stepper.position(L64XX_axis_xref[cv]));
  433. }
  434. #endif
  435. }