Get UBL up and running again

All the changes to get the code into compliance with Marlin coding
standards made UBL sick.   This pretty much gets UBL back up and
running.
master
Roxy-3D 7 years ago committed by Roxy-3D
parent 5de1da2b3c
commit b8e4a6970b

@ -2266,7 +2266,7 @@ static void clean_up_after_endstop_or_probe_move() {
#endif // HAS_BED_PROBE
#if PLANNER_LEVELING
#if PLANNER_LEVELING || ENABLED(AUTO_BED_LEVELING_UBL)
/**
* Turn bed leveling on or off, fixing the current
* position as-needed.
@ -2309,10 +2309,7 @@ static void clean_up_after_endstop_or_probe_move() {
planner.unapply_leveling(current_position);
}
#elif ENABLED(AUTO_BED_LEVELING_UBL)
if (ubl.state.eeprom_storage_slot == 0) {
ubl.state.active = enable;
ubl.store_state();
}
#endif
}
@ -2363,6 +2360,8 @@ static void clean_up_after_endstop_or_probe_move() {
for (uint8_t x = 0; x < ABL_GRID_MAX_POINTS_X; x++)
for (uint8_t y = 0; y < ABL_GRID_MAX_POINTS_Y; y++)
bed_level_grid[x][y] = UNPROBED;
#elif ENABLED(AUTO_BED_LEVELING_UBL)
ubl.reset();
#endif
#endif
}
@ -3482,6 +3481,11 @@ inline void gcode_G4() {
*
*/
inline void gcode_G28() {
#if ENABLED(AUTO_BED_LEVELING_UBL)
bool bed_leveling_state_at_entry=0;
bed_leveling_state_at_entry = ubl.state.active;
set_bed_leveling_enabled(false);
#endif
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) {
@ -3638,6 +3642,10 @@ inline void gcode_G28() {
#endif
// Enable mesh leveling again
#if ENABLED(AUTO_BED_LEVELING_UBL)
set_bed_leveling_enabled(bed_leveling_state_at_entry);
#endif
#if ENABLED(MESH_BED_LEVELING)
if (mbl.reactivate()) {
set_bed_leveling_enabled(true);
@ -5060,6 +5068,10 @@ inline void gcode_M42() {
* regenerated.
*/
inline void gcode_M48() {
#if ENABLED(AUTO_BED_LEVELING_UBL)
bool bed_leveling_state_at_entry=0;
bed_leveling_state_at_entry = ubl.state.active;
#endif
if (axis_unhomed_error(true, true, true)) return;
@ -5283,6 +5295,11 @@ inline void gcode_M42() {
set_bed_leveling_enabled(abl_was_enabled);
#endif
#if ENABLED(AUTO_BED_LEVELING_UBL)
set_bed_leveling_enabled(bed_leveling_state_at_entry);
ubl.state.active = bed_leveling_state_at_entry;
#endif
report_current_position();
}
@ -8511,7 +8528,7 @@ void process_next_command() {
gcode_G28();
break;
#if PLANNER_LEVELING
#if PLANNER_LEVELING || HAS_ABL
case 29: // G29 Detailed Z probe, probes the bed at 3 or more points,
// or provides access to the UBL System if enabled.
gcode_G29();

@ -96,8 +96,7 @@
* specified height, no correction is applied and natural printer kenimatics take over. If no
* number is specified for the command, 10mm is assumed to be reasonable.
*
* G # Grid * Perform a Grid Based Leveling of the current Mesh using a grid with n points on
* a side.
* G # Grid * Perform a Grid Based Leveling of the current Mesh using a grid with n points on a side.
*
* H # Height Specify the Height to raise the nozzle after each manual probe of the bed. The
* default is 5mm.
@ -267,12 +266,6 @@
* of the mesh, you are limited to 3-Point and Grid Leveling. (G29 P0 T and G29 P0 G
* respectively.)
*
* Z-Probe Sleds are not currently fully supported. There were too many complications caused
* by them to support them in the Unified Bed Leveling code. Support for them will be handled
* better in the upcoming Z-Probe Object that will happen during the Code Clean Up phase. (That
* is what they really are: A special case of the Z-Probe.) When a Z-Probe Object appears, it
* should slip in under the Unified Bed Leveling code without major trauma.
*
* When you do a G28 and then a G29 P1 to automatically build your first mesh, you are going to notice
* the Unified Bed Leveling probes points further and further away from the starting location. (The
* starting location defaults to the center of the bed.) The original Grid and Mesh leveling used
@ -1076,11 +1069,6 @@
ubl.state.active = ubl_state_at_invocation;
}
void g29_print_line(bool longer=false) {
SERIAL_PROTOCOLPGM(" -------------------------------------");
if (longer) SERIAL_PROTOCOLPGM("-------------------");
SERIAL_PROTOCOLLNPGM(" <----<<<");
}
/**
* Much of the 'What?' command can be eliminated. But until we are fully debugged, it is
@ -1090,70 +1078,85 @@
int k = E2END - ubl_eeprom_start;
statistics_flag++;
SERIAL_PROTOCOLLNPGM("Version #4: 10/30/2016 branch");
SERIAL_PROTOCOLPGM("Unified Bed Leveling System ");
SERIAL_PROTOCOLPGM("Unified Bed Leveling System Version 1.00 ");
if (ubl.state.active)
SERIAL_PROTOCOLPGM("Active.");
SERIAL_PROTOCOLPGM("Active.\n");
else
SERIAL_PROTOCOLPGM("Inactive.");
g29_print_line(); // These are just to help me find this info buried in the clutter
SERIAL_PROTOCOLPGM("Inactive.\n");
SERIAL_EOL;
delay(50);
if (ubl.state.eeprom_storage_slot == 0xFFFF) {
SERIAL_PROTOCOLPGM("No Mesh Loaded.");
g29_print_line(); // These are just to help me find this info buried in the clutter
}
else {
SERIAL_PROTOCOLPGM("Mesh: ");
prt_hex_word(ubl.state.eeprom_storage_slot);
SERIAL_PROTOCOLPGM(" Loaded. ");
g29_print_line(true); // These are just to help me find this info buried in the clutter
}
SERIAL_PROTOCOLPAIR("\ng29_correction_fade_height : ", ubl.state.g29_correction_fade_height );
g29_print_line(); // These are just to help me find this info buried in the clutter
SERIAL_EOL;
delay(50);
SERIAL_PROTOCOLPAIR("g29_correction_fade_height : ", ubl.state.g29_correction_fade_height );
SERIAL_EOL;
idle();
SERIAL_PROTOCOLPGM("z_offset: ");
SERIAL_PROTOCOL_F(ubl.state.z_offset, 6);
g29_print_line(true); // These are just to help me find this info buried in the clutter
SERIAL_EOL;
SERIAL_PROTOCOLPGM("X-Axis Mesh Points at: ");
for (uint8_t i = 0; i < UBL_MESH_NUM_X_POINTS; i++) {
SERIAL_PROTOCOL_F( ubl.map_x_index_to_bed_location(i), 1);
SERIAL_PROTOCOLPGM(" ");
delay(10);
}
SERIAL_EOL;
delay(50);
idle();
SERIAL_PROTOCOLPGM("Y-Axis Mesh Points at: ");
for (uint8_t i = 0; i < UBL_MESH_NUM_Y_POINTS; i++) {
SERIAL_PROTOCOL_F( ubl.map_y_index_to_bed_location(i), 1);
SERIAL_PROTOCOLPGM(" ");
delay(10);
}
SERIAL_EOL;
delay(50);
idle();
#if HAS_KILL
SERIAL_PROTOCOLPAIR("Kill pin on :", KILL_PIN);
SERIAL_PROTOCOLLNPAIR(" state:", READ(KILL_PIN));
#endif
delay(50);
idle();
SERIAL_EOL;
SERIAL_PROTOCOLLNPAIR("ubl_state_at_invocation :", ubl_state_at_invocation);
SERIAL_EOL;
SERIAL_PROTOCOLLNPAIR("ubl_state_recursion_chk :", ubl_state_recursion_chk);
SERIAL_EOL;
SERIAL_PROTOCOLPGM("Free EEPROM space starts at: 0x");
prt_hex_word(ubl_eeprom_start);
SERIAL_EOL;
delay(50);
idle();
SERIAL_PROTOCOLPGM("end of EEPROM : ");
prt_hex_word(E2END);
SERIAL_EOL;
delay(50);
idle();
SERIAL_PROTOCOLLNPAIR("sizeof(ubl) : ", (int)sizeof(ubl));
SERIAL_EOL;
SERIAL_PROTOCOLLNPAIR("z_value[][] size: ", (int)sizeof(z_values));
SERIAL_EOL;
delay(50);
idle();
SERIAL_PROTOCOLPGM("EEPROM free for UBL: 0x");
prt_hex_word(k);
@ -1162,41 +1165,28 @@
SERIAL_PROTOCOLPGM("EEPROM can hold 0x");
prt_hex_word(k / sizeof(z_values));
SERIAL_PROTOCOLLNPGM(" meshes.");
SERIAL_PROTOCOLLNPGM(" meshes.\n");
delay(50);
SERIAL_PROTOCOLPGM("sizeof(stat) :");
SERIAL_PROTOCOLPGM("sizeof(ubl.state) :");
prt_hex_word(sizeof(ubl.state));
SERIAL_EOL;
idle();
SERIAL_PROTOCOLPAIR("\nUBL_MESH_NUM_X_POINTS ", UBL_MESH_NUM_X_POINTS);
SERIAL_PROTOCOLPAIR("\nUBL_MESH_NUM_Y_POINTS ", UBL_MESH_NUM_Y_POINTS);
SERIAL_PROTOCOLPAIR("\nUBL_MESH_MIN_X ", UBL_MESH_MIN_X);
delay(50);
idle();
SERIAL_PROTOCOLPAIR("\nUBL_MESH_MIN_Y ", UBL_MESH_MIN_Y);
SERIAL_PROTOCOLPAIR("\nUBL_MESH_MAX_X ", UBL_MESH_MAX_X);
SERIAL_PROTOCOLPAIR("\nUBL_MESH_MAX_Y ", UBL_MESH_MAX_Y);
delay(50);
idle();
SERIAL_PROTOCOLPGM("\nMESH_X_DIST ");
SERIAL_PROTOCOL_F(MESH_X_DIST, 6);
SERIAL_PROTOCOLPGM("\nMESH_Y_DIST ");
SERIAL_PROTOCOL_F(MESH_Y_DIST, 6);
SERIAL_EOL;
idle();
SERIAL_PROTOCOLPAIR("\nsizeof(block_t): ", (int)sizeof(block_t));
SERIAL_PROTOCOLPAIR("\nsizeof(planner.block_buffer): ", (int)sizeof(planner.block_buffer));
SERIAL_PROTOCOLPAIR("\nsizeof(char): ", (int)sizeof(char));
SERIAL_PROTOCOLPAIR(" sizeof(unsigned char): ", (int)sizeof(unsigned char));
SERIAL_PROTOCOLPAIR("\nsizeof(int): ", (int)sizeof(int));
SERIAL_PROTOCOLPAIR(" sizeof(unsigned int): ", (int)sizeof(unsigned int));
SERIAL_PROTOCOLPAIR("\nsizeof(long): ", (int)sizeof(long));
SERIAL_PROTOCOLPAIR(" sizeof(unsigned long int): ", (int)sizeof(unsigned long int));
SERIAL_PROTOCOLPAIR("\nsizeof(float): ", (int)sizeof(float));
SERIAL_PROTOCOLPAIR(" sizeof(double): ", (int)sizeof(double));
SERIAL_PROTOCOLPAIR("\nsizeof(void *): ", (int)sizeof(void *));
struct pf { void *p_f(); } ptr_func;
SERIAL_PROTOCOLPAIR(" sizeof(struct pf): ", (int)sizeof(pf));
SERIAL_PROTOCOLPAIR(" sizeof(void *()): ", (int)sizeof(ptr_func));
SERIAL_EOL;
idle();

@ -1263,7 +1263,7 @@ void Stepper::report_positions() {
old_pin = _READ_DIR(X);
#if STEP_PULSE_CYCLES > CYCLES_EATEN_BY_BABYSTEP
pulse_start = TCNT0;
#endif \
#endif
START_BABYSTEP_AXIS(X, false);
#if STEP_PULSE_CYCLES > CYCLES_EATEN_BY_BABYSTEP
while ((uint32_t)(TCNT0 - pulse_start) < STEP_PULSE_CYCLES - CYCLES_EATEN_BY_BABYSTEP) { /* nada */ }

Loading…
Cancel
Save