@ -64,8 +64,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 ;
@ -74,6 +73,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
*
@ -309,6 +312,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 ) ;
@ -316,8 +321,6 @@
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 ' ) ) {
@ -380,6 +383,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 ( ) ;
@ -415,6 +420,8 @@
}
}
# endif // HAS_BED_PROBE
if ( parser . seen ( ' P ' ) ) {
if ( WITHIN ( g29_phase_value , 0 , 1 ) & & state . storage_slot = = - 1 ) {
state . storage_slot = 0 ;
@ -430,6 +437,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
@ -448,6 +457,8 @@
parser . seen ( ' T ' ) , parser . seen ( ' E ' ) , parser . seen ( ' U ' ) ) ;
break ;
# endif // HAS_BED_PROBE
case 2 : {
# if ENABLED(NEWPANEL)
//
@ -775,6 +786,7 @@
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 .
@ -928,6 +940,7 @@
}
}
}
# endif // HAS_BED_PROBE
# if ENABLED(NEWPANEL)
float unified_bed_leveling : : measure_point_with_encoder ( ) {
@ -1079,7 +1092,7 @@
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 ;
@ -1113,19 +1126,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 ) {
@ -1625,6 +1653,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 ) ,
@ -1770,6 +1800,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 ) {