2018-10-28 06:59:47 +00:00
/**
* Marlin 3 D Printer Firmware
2020-02-03 14:00:57 +00:00
* Copyright ( c ) 2020 MarlinFirmware [ https : //github.com/MarlinFirmware/Marlin]
2018-10-28 06:59:47 +00:00
*
* Based on Sprinter and grbl .
2019-06-28 04:57:50 +00:00
* Copyright ( c ) 2011 Camiel Gubbels / Erik van der Zalm
2018-10-28 06:59:47 +00: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
2020-07-23 03:20:14 +00:00
* along with this program . If not , see < https : //www.gnu.org/licenses/>.
2018-10-28 06:59:47 +00:00
*
*/
//
// Delta Calibrate Menu
//
# include "../../inc/MarlinConfigPre.h"
2022-01-25 21:33:03 +00:00
# if HAS_MARLINUI_MENU && EITHER(DELTA_CALIBRATION_MENU, DELTA_AUTO_CALIBRATION)
2018-10-28 06:59:47 +00:00
2020-08-21 10:21:34 +00:00
# include "menu_item.h"
2018-10-28 06:59:47 +00:00
# include "../../module/delta.h"
# include "../../module/motion.h"
2021-07-24 21:08:47 +00:00
# include "../../module/planner.h"
2018-10-28 06:59:47 +00:00
# if HAS_LEVELING
# include "../../feature/bedlevel/bedlevel.h"
# endif
2019-08-19 02:03:26 +00:00
# if ENABLED(EXTENSIBLE_UI)
2021-05-22 03:55:13 +00:00
# include "../extui/ui_api.h"
2019-08-19 02:03:26 +00:00
# endif
2019-09-29 09:25:39 +00:00
void _man_probe_pt ( const xy_pos_t & xy ) {
2020-01-26 06:02:06 +00:00
if ( ! ui . wait_for_move ) {
ui . wait_for_move = true ;
do_blocking_move_to_xy_z ( xy , Z_CLEARANCE_BETWEEN_PROBES ) ;
ui . wait_for_move = false ;
ui . synchronize ( ) ;
2021-07-24 21:08:47 +00:00
ui . manual_move . menu_scale = _MAX ( PROBE_MANUALLY_STEP , MIN_STEPS_PER_SEGMENT / planner . settings . axis_steps_per_mm [ 0 ] ) ; // Use first axis as for delta XYZ should always match
2020-01-26 06:02:06 +00:00
ui . goto_screen ( lcd_move_z ) ;
}
2018-10-28 06:59:47 +00:00
}
# if ENABLED(DELTA_AUTO_CALIBRATION)
2021-09-11 07:15:05 +00:00
# if HAS_RESUME_CONTINUE
# include "../../MarlinCore.h" // for wait_for_user_response()
# endif
2019-11-26 22:38:41 +00:00
# if ENABLED(HOST_PROMPT_SUPPORT)
2021-10-15 05:24:08 +00:00
# include "../../feature/host_actions.h" // for hostui.prompt_do
2019-11-26 22:38:41 +00:00
# endif
2019-09-29 09:25:39 +00:00
float lcd_probe_pt ( const xy_pos_t & xy ) {
_man_probe_pt ( xy ) ;
2019-03-23 21:30:43 +00:00
ui . defer_status_screen ( ) ;
2021-10-15 05:24:08 +00:00
TERN_ ( HOST_PROMPT_SUPPORT , hostui . prompt_do ( PROMPT_USER_CONTINUE , F ( " Delta Calibration in progress " ) , FPSTR ( CONTINUE_STR ) ) ) ;
2021-09-26 03:11:48 +00:00
TERN_ ( EXTENSIBLE_UI , ExtUI : : onUserConfirmRequired ( F ( " Delta Calibration in progress " ) ) ) ;
2021-09-11 07:15:05 +00:00
TERN_ ( HAS_RESUME_CONTINUE , wait_for_user_response ( ) ) ;
2018-11-11 18:16:24 +00:00
ui . goto_previous_screen_no_defer ( ) ;
2019-09-29 09:25:39 +00:00
return current_position . z ;
2018-10-28 06:59:47 +00:00
}
# endif
# if ENABLED(DELTA_CALIBRATION_MENU)
# include "../../gcode/queue.h"
void _lcd_calibrate_homing ( ) {
_lcd_draw_homing ( ) ;
2018-11-11 18:16:24 +00:00
if ( all_axes_homed ( ) ) ui . goto_previous_screen ( ) ;
2018-10-28 06:59:47 +00:00
}
void _lcd_delta_calibrate_home ( ) {
2019-11-02 04:51:25 +00:00
queue . inject_P ( G28_STR ) ;
2018-11-11 18:16:24 +00:00
ui . goto_screen ( _lcd_calibrate_homing ) ;
2018-10-28 06:59:47 +00:00
}
2021-04-01 22:59:57 +00:00
void _goto_tower_a ( const_float_t a ) {
2021-09-13 00:35:37 +00:00
constexpr float dcr = DELTA_PRINTABLE_RADIUS ;
2019-09-29 09:25:39 +00:00
xy_pos_t tower_vec = { cos ( RADIANS ( a ) ) , sin ( RADIANS ( a ) ) } ;
2021-09-13 00:35:37 +00:00
_man_probe_pt ( tower_vec * dcr ) ;
2019-09-29 09:25:39 +00:00
}
void _goto_tower_x ( ) { _goto_tower_a ( 210 ) ; }
void _goto_tower_y ( ) { _goto_tower_a ( 330 ) ; }
void _goto_tower_z ( ) { _goto_tower_a ( 90 ) ; }
void _goto_center ( ) { xy_pos_t ctr { 0 } ; _man_probe_pt ( ctr ) ; }
2018-10-28 06:59:47 +00:00
# endif
void lcd_delta_settings ( ) {
2020-03-18 15:30:19 +00:00
auto _recalc_delta_settings = [ ] {
2020-04-22 21:35:03 +00:00
TERN_ ( HAS_LEVELING , reset_bed_level ( ) ) ; // After changing kinematics bed-level data is no longer valid
2019-10-08 00:44:33 +00:00
recalc_delta_settings ( ) ;
} ;
2018-10-28 06:59:47 +00:00
START_MENU ( ) ;
2019-10-03 10:38:30 +00:00
BACK_ITEM ( MSG_DELTA_CALIBRATE ) ;
EDIT_ITEM ( float52sign , MSG_DELTA_HEIGHT , & delta_height , delta_height - 10 , delta_height + 10 , _recalc_delta_settings ) ;
2021-07-11 18:18:16 +00:00
# define EDIT_ENDSTOP_ADJ(LABEL,N) EDIT_ITEM_P(float43, PSTR(LABEL), &delta_endstop_adj.N, -5, 0, _recalc_delta_settings)
2019-11-26 22:38:41 +00:00
EDIT_ENDSTOP_ADJ ( " Ex " , a ) ;
EDIT_ENDSTOP_ADJ ( " Ey " , b ) ;
EDIT_ENDSTOP_ADJ ( " Ez " , c ) ;
2019-10-03 10:38:30 +00:00
EDIT_ITEM ( float52sign , MSG_DELTA_RADIUS , & delta_radius , delta_radius - 5 , delta_radius + 5 , _recalc_delta_settings ) ;
2019-10-10 00:46:10 +00:00
# define EDIT_ANGLE_TRIM(LABEL,N) EDIT_ITEM_P(float43, PSTR(LABEL), &delta_tower_angle_trim.N, -5, 5, _recalc_delta_settings)
2019-11-26 22:38:41 +00:00
EDIT_ANGLE_TRIM ( " Tx " , a ) ;
EDIT_ANGLE_TRIM ( " Ty " , b ) ;
EDIT_ANGLE_TRIM ( " Tz " , c ) ;
2019-10-03 10:38:30 +00:00
EDIT_ITEM ( float52sign , MSG_DELTA_DIAG_ROD , & delta_diagonal_rod , delta_diagonal_rod - 5 , delta_diagonal_rod + 5 , _recalc_delta_settings ) ;
2018-10-28 06:59:47 +00:00
END_MENU ( ) ;
}
void menu_delta_calibrate ( ) {
2021-03-24 10:40:28 +00:00
# if ENABLED(DELTA_CALIBRATION_MENU)
const bool all_homed = all_axes_homed ( ) ; // Acquire ahead of loop
# endif
2020-04-28 04:52:11 +00:00
2018-10-28 06:59:47 +00:00
START_MENU ( ) ;
2019-10-03 10:38:30 +00:00
BACK_ITEM ( MSG_MAIN ) ;
2018-10-28 06:59:47 +00:00
# if ENABLED(DELTA_AUTO_CALIBRATION)
2019-10-03 10:38:30 +00:00
GCODES_ITEM ( MSG_DELTA_AUTO_CALIBRATE , PSTR ( " G33 " ) ) ;
2018-10-28 06:59:47 +00:00
# if ENABLED(EEPROM_SETTINGS)
2020-05-10 05:12:56 +00:00
ACTION_ITEM ( MSG_STORE_EEPROM , ui . store_settings ) ;
ACTION_ITEM ( MSG_LOAD_EEPROM , ui . load_settings ) ;
2018-10-28 06:59:47 +00:00
# endif
# endif
2019-10-03 10:38:30 +00:00
SUBMENU ( MSG_DELTA_SETTINGS , lcd_delta_settings ) ;
2018-10-28 06:59:47 +00:00
# if ENABLED(DELTA_CALIBRATION_MENU)
2019-10-03 10:38:30 +00:00
SUBMENU ( MSG_AUTO_HOME , _lcd_delta_calibrate_home ) ;
2020-04-28 04:52:11 +00:00
if ( all_homed ) {
2019-10-03 10:38:30 +00:00
SUBMENU ( MSG_DELTA_CALIBRATE_X , _goto_tower_x ) ;
SUBMENU ( MSG_DELTA_CALIBRATE_Y , _goto_tower_y ) ;
SUBMENU ( MSG_DELTA_CALIBRATE_Z , _goto_tower_z ) ;
SUBMENU ( MSG_DELTA_CALIBRATE_CENTER , _goto_center ) ;
2018-10-28 06:59:47 +00:00
}
# endif
END_MENU ( ) ;
}
2022-01-25 21:33:03 +00:00
# endif // HAS_MARLINUI_MENU && (DELTA_CALIBRATION_MENU || DELTA_AUTO_CALIBRATION)