@ -65,8 +65,7 @@
unified_bed_leveling : : g29_phase_value ,
unified_bed_leveling : : g29_repetition_cnt ,
unified_bed_leveling : : g29_storage_slot = 0 ,
unified_bed_leveling : : g29_map_type ,
unified_bed_leveling : : g29_grid_size ;
unified_bed_leveling : : g29_map_type ;
bool unified_bed_leveling : : g29_c_flag ,
unified_bed_leveling : : g29_x_flag ,
unified_bed_leveling : : g29_y_flag ;
@ -75,6 +74,10 @@
unified_bed_leveling : : g29_card_thickness = 0.0 ,
unified_bed_leveling : : g29_constant = 0.0 ;
# if HAS_BED_PROBE
int unified_bed_leveling : : g29_grid_size ;
# endif
/**
* G29 : Unified Bed Leveling by Roxy
*
@ -310,6 +313,8 @@
return ;
}
if ( g29_parameter_parsing ( ) ) return ; // abort if parsing the simple parameters causes a problem,
// Check for commands that require the printer to be homed
if ( axis_unhomed_error ( ) ) {
const int8_t p_val = parser . intval ( ' P ' , - 1 ) ;
@ -317,8 +322,6 @@
gcode . home_all_axes ( ) ;
}
if ( g29_parameter_parsing ( ) ) return ; // abort if parsing the simple parameters causes a problem,
// Invalidate Mesh Points. This command is a little bit asymmetrical because
// it directly specifies the repetition count and does not use the 'R' parameter.
if ( parser . seen ( ' I ' ) ) {
@ -381,6 +384,8 @@
}
}
# if HAS_BED_PROBE
if ( parser . seen ( ' J ' ) ) {
if ( g29_grid_size ) { // if not 0 it is a normal n x n grid being probed
save_ubl_active_state_and_disable ( ) ;
@ -416,6 +421,8 @@
}
}
# endif // HAS_BED_PROBE
if ( parser . seen ( ' P ' ) ) {
if ( WITHIN ( g29_phase_value , 0 , 1 ) & & state . storage_slot = = - 1 ) {
state . storage_slot = 0 ;
@ -431,6 +438,8 @@
SERIAL_PROTOCOLLNPGM ( " Mesh zeroed. " ) ;
break ;
# if HAS_BED_PROBE
case 1 :
//
// Invalidate Entire Mesh and Automatically Probe Mesh in areas that can be reached by the probe
@ -449,6 +458,8 @@
parser . seen ( ' T ' ) , parser . seen ( ' E ' ) , parser . seen ( ' U ' ) ) ;
break ;
# endif
case 2 : {
# if ENABLED(NEWPANEL)
//
@ -776,6 +787,8 @@
z_values [ x ] [ y ] + = g29_constant ;
}
# if HAS_BED_PROBE
/**
* Probe all invalidated locations of the mesh that can be reached by the probe .
* This attempts to fill in locations closest to the nozzle ' s start location first .
@ -930,7 +943,10 @@
}
}
# endif // HAS_BED_PROBE
# if ENABLED(NEWPANEL)
float unified_bed_leveling : : measure_point_with_encoder ( ) {
while ( ubl_lcd_clicked ( ) ) delay ( 50 ) ; // wait for user to release encoder wheel
@ -1080,7 +1096,8 @@
do_blocking_move_to_z ( Z_CLEARANCE_DEPLOY_PROBE ) ;
do_blocking_move_to_xy ( lx , ly ) ;
}
# endif
# endif // NEWPANEL
bool unified_bed_leveling : : g29_parameter_parsing ( ) {
bool err_flag = false ;
@ -1114,19 +1131,34 @@
}
if ( parser . seen ( ' P ' ) ) {
g29_phase_value = parser . value_int ( ) ;
const int pv = parser . value_int ( ) ;
# if !HAS_BED_PROBE
if ( pv = = 1 ) {
SERIAL_PROTOCOLLNPGM ( " G29 P1 requires a probe. \n " ) ;
err_flag = true ;
}
else
# endif
{
g29_phase_value = pv ;
if ( ! WITHIN ( g29_phase_value , 0 , 6 ) ) {
SERIAL_PROTOCOLLNPGM ( " ?(P)hase value invalid (0-6). \n " ) ;
err_flag = true ;
}
}
}
if ( parser . seen ( ' J ' ) ) {
# if HAS_BED_PROBE
g29_grid_size = parser . has_value ( ) ? parser . value_int ( ) : 0 ;
if ( g29_grid_size & & ! WITHIN ( g29_grid_size , 2 , 9 ) ) {
SERIAL_PROTOCOLLNPGM ( " ?Invalid grid size (J) specified (2-9). \n " ) ;
err_flag = true ;
}
# else
SERIAL_PROTOCOLLNPGM ( " G29 J action requires a probe. \n " ) ;
err_flag = true ;
# endif
}
if ( g29_x_flag ! = g29_y_flag ) {
@ -1624,6 +1656,8 @@
}
}
# if HAS_BED_PROBE
void unified_bed_leveling : : tilt_mesh_based_on_probed_grid ( const bool do_ubl_mesh_map ) {
constexpr int16_t x_min = max ( MIN_PROBE_X , UBL_MESH_MIN_X ) ,
x_max = min ( MAX_PROBE_X , UBL_MESH_MAX_X ) ,
@ -1769,6 +1803,8 @@
if ( do_ubl_mesh_map ) display_map ( g29_map_type ) ;
}
# endif // HAS_BED_PROBE
# if ENABLED(UBL_G29_P31)
void unified_bed_leveling : : smart_fill_wlsf ( const float & weight_factor ) {