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

@ -96,8 +96,7 @@
* specified height, no correction is applied and natural printer kenimatics take over. If no * 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. * 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 * G # Grid * Perform a Grid Based Leveling of the current Mesh using a grid with n points on a side.
* a side.
* *
* H # Height Specify the Height to raise the nozzle after each manual probe of the bed. The * H # Height Specify the Height to raise the nozzle after each manual probe of the bed. The
* default is 5mm. * 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 * of the mesh, you are limited to 3-Point and Grid Leveling. (G29 P0 T and G29 P0 G
* respectively.) * 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 * 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 * 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 * 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; 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 * 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; int k = E2END - ubl_eeprom_start;
statistics_flag++; statistics_flag++;
SERIAL_PROTOCOLLNPGM("Version #4: 10/30/2016 branch"); SERIAL_PROTOCOLPGM("Unified Bed Leveling System Version 1.00 ");
SERIAL_PROTOCOLPGM("Unified Bed Leveling System ");
if (ubl.state.active) if (ubl.state.active)
SERIAL_PROTOCOLPGM("Active."); SERIAL_PROTOCOLPGM("Active.\n");
else else
SERIAL_PROTOCOLPGM("Inactive."); SERIAL_PROTOCOLPGM("Inactive.\n");
g29_print_line(); // These are just to help me find this info buried in the clutter SERIAL_EOL;
delay(50);
if (ubl.state.eeprom_storage_slot == 0xFFFF) { if (ubl.state.eeprom_storage_slot == 0xFFFF) {
SERIAL_PROTOCOLPGM("No Mesh Loaded."); SERIAL_PROTOCOLPGM("No Mesh Loaded.");
g29_print_line(); // These are just to help me find this info buried in the clutter
} }
else { else {
SERIAL_PROTOCOLPGM("Mesh: "); SERIAL_PROTOCOLPGM("Mesh: ");
prt_hex_word(ubl.state.eeprom_storage_slot); prt_hex_word(ubl.state.eeprom_storage_slot);
SERIAL_PROTOCOLPGM(" Loaded. "); 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 ); SERIAL_EOL;
g29_print_line(); // These are just to help me find this info buried in the clutter delay(50);
SERIAL_PROTOCOLPAIR("g29_correction_fade_height : ", ubl.state.g29_correction_fade_height );
SERIAL_EOL;
idle(); idle();
SERIAL_PROTOCOLPGM("z_offset: "); SERIAL_PROTOCOLPGM("z_offset: ");
SERIAL_PROTOCOL_F(ubl.state.z_offset, 6); 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: "); SERIAL_PROTOCOLPGM("X-Axis Mesh Points at: ");
for (uint8_t i = 0; i < UBL_MESH_NUM_X_POINTS; i++) { 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_PROTOCOL_F( ubl.map_x_index_to_bed_location(i), 1);
SERIAL_PROTOCOLPGM(" "); SERIAL_PROTOCOLPGM(" ");
delay(10);
} }
SERIAL_EOL; SERIAL_EOL;
delay(50);
idle();
SERIAL_PROTOCOLPGM("Y-Axis Mesh Points at: "); SERIAL_PROTOCOLPGM("Y-Axis Mesh Points at: ");
for (uint8_t i = 0; i < UBL_MESH_NUM_Y_POINTS; i++) { 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_PROTOCOL_F( ubl.map_y_index_to_bed_location(i), 1);
SERIAL_PROTOCOLPGM(" "); SERIAL_PROTOCOLPGM(" ");
delay(10);
} }
SERIAL_EOL; SERIAL_EOL;
delay(50);
idle();
#if HAS_KILL #if HAS_KILL
SERIAL_PROTOCOLPAIR("Kill pin on :", KILL_PIN); SERIAL_PROTOCOLPAIR("Kill pin on :", KILL_PIN);
SERIAL_PROTOCOLLNPAIR(" state:", READ(KILL_PIN)); SERIAL_PROTOCOLLNPAIR(" state:", READ(KILL_PIN));
#endif #endif
delay(50);
idle();
SERIAL_EOL;
SERIAL_PROTOCOLLNPAIR("ubl_state_at_invocation :", ubl_state_at_invocation); SERIAL_PROTOCOLLNPAIR("ubl_state_at_invocation :", ubl_state_at_invocation);
SERIAL_EOL;
SERIAL_PROTOCOLLNPAIR("ubl_state_recursion_chk :", ubl_state_recursion_chk); SERIAL_PROTOCOLLNPAIR("ubl_state_recursion_chk :", ubl_state_recursion_chk);
SERIAL_EOL; SERIAL_EOL;
SERIAL_PROTOCOLPGM("Free EEPROM space starts at: 0x"); SERIAL_PROTOCOLPGM("Free EEPROM space starts at: 0x");
prt_hex_word(ubl_eeprom_start); prt_hex_word(ubl_eeprom_start);
SERIAL_EOL; SERIAL_EOL;
delay(50);
idle(); idle();
SERIAL_PROTOCOLPGM("end of EEPROM : "); SERIAL_PROTOCOLPGM("end of EEPROM : ");
prt_hex_word(E2END); prt_hex_word(E2END);
SERIAL_EOL; SERIAL_EOL;
delay(50);
idle(); idle();
SERIAL_PROTOCOLLNPAIR("sizeof(ubl) : ", (int)sizeof(ubl)); SERIAL_PROTOCOLLNPAIR("sizeof(ubl) : ", (int)sizeof(ubl));
SERIAL_EOL; SERIAL_EOL;
SERIAL_PROTOCOLLNPAIR("z_value[][] size: ", (int)sizeof(z_values)); SERIAL_PROTOCOLLNPAIR("z_value[][] size: ", (int)sizeof(z_values));
SERIAL_EOL; SERIAL_EOL;
delay(50);
idle();
SERIAL_PROTOCOLPGM("EEPROM free for UBL: 0x"); SERIAL_PROTOCOLPGM("EEPROM free for UBL: 0x");
prt_hex_word(k); prt_hex_word(k);
@ -1162,41 +1165,28 @@
SERIAL_PROTOCOLPGM("EEPROM can hold 0x"); SERIAL_PROTOCOLPGM("EEPROM can hold 0x");
prt_hex_word(k / sizeof(z_values)); 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)); prt_hex_word(sizeof(ubl.state));
SERIAL_EOL;
idle(); idle();
SERIAL_PROTOCOLPAIR("\nUBL_MESH_NUM_X_POINTS ", UBL_MESH_NUM_X_POINTS); 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_NUM_Y_POINTS ", UBL_MESH_NUM_Y_POINTS);
SERIAL_PROTOCOLPAIR("\nUBL_MESH_MIN_X ", UBL_MESH_MIN_X); 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_MIN_Y ", UBL_MESH_MIN_Y);
SERIAL_PROTOCOLPAIR("\nUBL_MESH_MAX_X ", UBL_MESH_MAX_X); SERIAL_PROTOCOLPAIR("\nUBL_MESH_MAX_X ", UBL_MESH_MAX_X);
SERIAL_PROTOCOLPAIR("\nUBL_MESH_MAX_Y ", UBL_MESH_MAX_Y); SERIAL_PROTOCOLPAIR("\nUBL_MESH_MAX_Y ", UBL_MESH_MAX_Y);
delay(50);
idle();
SERIAL_PROTOCOLPGM("\nMESH_X_DIST "); SERIAL_PROTOCOLPGM("\nMESH_X_DIST ");
SERIAL_PROTOCOL_F(MESH_X_DIST, 6); SERIAL_PROTOCOL_F(MESH_X_DIST, 6);
SERIAL_PROTOCOLPGM("\nMESH_Y_DIST "); SERIAL_PROTOCOLPGM("\nMESH_Y_DIST ");
SERIAL_PROTOCOL_F(MESH_Y_DIST, 6); SERIAL_PROTOCOL_F(MESH_Y_DIST, 6);
SERIAL_EOL; 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(); idle();

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

Loading…
Cancel
Save