Adapt G26 to work for all meshes
This commit is contained in:
@ -41,6 +41,10 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if G26_MESH_VALIDATION
|
||||
bool g26_debug_flag; // = false
|
||||
#endif
|
||||
|
||||
bool leveling_is_valid() {
|
||||
return
|
||||
#if ENABLED(MESH_BED_LEVELING)
|
||||
|
@ -23,14 +23,17 @@
|
||||
#ifndef __BEDLEVEL_H__
|
||||
#define __BEDLEVEL_H__
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if ENABLED(MESH_BED_LEVELING)
|
||||
#include "mbl/mesh_bed_leveling.h"
|
||||
#elif ENABLED(AUTO_BED_LEVELING_UBL)
|
||||
#include "ubl/ubl.h"
|
||||
#elif HAS_ABL
|
||||
#include "abl/abl.h"
|
||||
typedef struct {
|
||||
int8_t x_index, y_index;
|
||||
float distance; // When populated, the distance from the search location
|
||||
} mesh_index_pair;
|
||||
|
||||
#if ENABLED(G26_MESH_VALIDATION)
|
||||
extern bool g26_debug_flag;
|
||||
#else
|
||||
constexpr bool g26_debug_flag = false;
|
||||
#endif
|
||||
|
||||
#if ENABLED(PROBE_MANUALLY)
|
||||
@ -68,4 +71,23 @@ void reset_bed_level();
|
||||
void out_of_range_error(const char* p_edge);
|
||||
#endif
|
||||
|
||||
#if ENABLED(AUTO_BED_LEVELING_BILINEAR)
|
||||
#define _GET_MESH_X(I) bilinear_start[X_AXIS] + I * bilinear_grid_spacing[X_AXIS]
|
||||
#define _GET_MESH_Y(J) bilinear_start[Y_AXIS] + J * bilinear_grid_spacing[Y_AXIS]
|
||||
#elif ENABLED(AUTO_BED_LEVELING_UBL)
|
||||
#define _GET_MESH_X(I) ubl.mesh_index_to_xpos(I)
|
||||
#define _GET_MESH_Y(J) ubl.mesh_index_to_ypos(J)
|
||||
#elif ENABLED(MESH_BED_LEVELING)
|
||||
#define _GET_MESH_X(I) mbl.index_to_xpos[I]
|
||||
#define _GET_MESH_Y(J) mbl.index_to_ypos[J]
|
||||
#endif
|
||||
|
||||
#if ENABLED(MESH_BED_LEVELING)
|
||||
#include "mbl/mesh_bed_leveling.h"
|
||||
#elif ENABLED(AUTO_BED_LEVELING_UBL)
|
||||
#include "ubl/ubl.h"
|
||||
#elif HAS_ABL
|
||||
#include "abl/abl.h"
|
||||
#endif
|
||||
|
||||
#endif // __BEDLEVEL_H__
|
||||
|
@ -34,16 +34,6 @@
|
||||
|
||||
#include "math.h"
|
||||
|
||||
/**
|
||||
* These support functions allow the use of large bit arrays of flags that take very
|
||||
* little RAM. Currently they are limited to being 16x16 in size. Changing the declaration
|
||||
* to unsigned long will allow us to go to 32x32 if higher resolution Mesh's are needed
|
||||
* in the future.
|
||||
*/
|
||||
void bit_clear(uint16_t bits[16], const uint8_t x, const uint8_t y) { CBI(bits[y], x); }
|
||||
void bit_set(uint16_t bits[16], const uint8_t x, const uint8_t y) { SBI(bits[y], x); }
|
||||
bool is_bit_set(uint16_t bits[16], const uint8_t x, const uint8_t y) { return TEST(bits[y], x); }
|
||||
|
||||
uint8_t ubl_cnt = 0;
|
||||
|
||||
void unified_bed_leveling::echo_name() { SERIAL_PROTOCOLPGM("Unified Bed Leveling"); }
|
||||
@ -74,9 +64,6 @@
|
||||
constexpr float unified_bed_leveling::_mesh_index_to_xpos[16],
|
||||
unified_bed_leveling::_mesh_index_to_ypos[16];
|
||||
|
||||
bool unified_bed_leveling::g26_debug_flag = false,
|
||||
unified_bed_leveling::has_control_of_lcd_panel = false;
|
||||
|
||||
#if ENABLED(ULTRA_LCD)
|
||||
bool unified_bed_leveling::lcd_map_control = false;
|
||||
#endif
|
||||
|
@ -23,9 +23,10 @@
|
||||
#ifndef UNIFIED_BED_LEVELING_H
|
||||
#define UNIFIED_BED_LEVELING_H
|
||||
|
||||
#include "../../../Marlin.h"
|
||||
#include "../bedlevel.h"
|
||||
#include "../../../module/planner.h"
|
||||
#include "../../../module/motion.h"
|
||||
#include "../../../Marlin.h"
|
||||
|
||||
#define UBL_VERSION "1.01"
|
||||
#define UBL_OK false
|
||||
@ -34,17 +35,6 @@
|
||||
#define USE_NOZZLE_AS_REFERENCE 0
|
||||
#define USE_PROBE_AS_REFERENCE 1
|
||||
|
||||
typedef struct {
|
||||
int8_t x_index, y_index;
|
||||
float distance; // When populated, the distance from the search location
|
||||
} mesh_index_pair;
|
||||
|
||||
// ubl.cpp
|
||||
|
||||
void bit_clear(uint16_t bits[16], const uint8_t x, const uint8_t y);
|
||||
void bit_set(uint16_t bits[16], const uint8_t x, const uint8_t y);
|
||||
bool is_bit_set(uint16_t bits[16], const uint8_t x, const uint8_t y);
|
||||
|
||||
// ubl_motion.cpp
|
||||
|
||||
void debug_current_and_destination(const char * const title);
|
||||
@ -56,7 +46,6 @@ enum MeshPointType { INVALID, REAL, SET_IN_BITMAP };
|
||||
// External references
|
||||
|
||||
char *ftostr43sign(const float&, char);
|
||||
bool ubl_lcd_clicked();
|
||||
|
||||
extern uint8_t ubl_cnt;
|
||||
|
||||
@ -87,22 +76,6 @@ class unified_bed_leveling {
|
||||
static int g29_grid_size;
|
||||
#endif
|
||||
|
||||
#if ENABLED(UBL_G26_MESH_VALIDATION)
|
||||
static float g26_extrusion_multiplier,
|
||||
g26_retraction_multiplier,
|
||||
g26_nozzle,
|
||||
g26_filament_diameter,
|
||||
g26_prime_length,
|
||||
g26_x_pos, g26_y_pos,
|
||||
g26_ooze_amount,
|
||||
g26_layer_height;
|
||||
static int16_t g26_bed_temp,
|
||||
g26_hotend_temp,
|
||||
g26_repeats;
|
||||
static int8_t g26_prime_flag;
|
||||
static bool g26_continue_with_closest, g26_keep_heaters_on;
|
||||
#endif
|
||||
|
||||
static float measure_point_with_encoder();
|
||||
static float measure_business_card_thickness(float);
|
||||
static bool g29_parameter_parsing();
|
||||
@ -119,21 +92,6 @@ class unified_bed_leveling {
|
||||
static bool smart_fill_one(const uint8_t x, const uint8_t y, const int8_t xdir, const int8_t ydir);
|
||||
static void smart_fill_mesh();
|
||||
|
||||
#if ENABLED(UBL_G26_MESH_VALIDATION)
|
||||
static bool exit_from_g26();
|
||||
static bool parse_G26_parameters();
|
||||
static void G26_line_to_destination(const float &feed_rate);
|
||||
static mesh_index_pair find_closest_circle_to_print(const float&, const float&);
|
||||
static bool look_for_lines_to_connect();
|
||||
static bool turn_on_heaters();
|
||||
static bool prime_nozzle();
|
||||
static void retract_filament(const float where[XYZE]);
|
||||
static void recover_filament(const float where[XYZE]);
|
||||
static void print_line_from_here_to_there(const float&, const float&, const float&, const float&, const float&, const float&);
|
||||
static void move_to(const float&, const float&, const float&, const float&);
|
||||
inline static void move_to(const float where[XYZE], const float &de) { move_to(where[X_AXIS], where[Y_AXIS], where[Z_AXIS], de); }
|
||||
#endif
|
||||
|
||||
public:
|
||||
|
||||
static void echo_name();
|
||||
@ -151,10 +109,6 @@ class unified_bed_leveling {
|
||||
static void G29() _O0; // O0 for no optimization
|
||||
static void smart_fill_wlsf(const float &) _O2; // O2 gives smaller code than Os on A2560
|
||||
|
||||
#if ENABLED(UBL_G26_MESH_VALIDATION)
|
||||
static void G26();
|
||||
#endif
|
||||
|
||||
static int8_t storage_slot;
|
||||
|
||||
static float z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
|
||||
@ -183,8 +137,6 @@ class unified_bed_leveling {
|
||||
MESH_MIN_Y + 14 * (MESH_Y_DIST), MESH_MIN_Y + 15 * (MESH_Y_DIST)
|
||||
};
|
||||
|
||||
static bool g26_debug_flag, has_control_of_lcd_panel;
|
||||
|
||||
#if ENABLED(ULTRA_LCD)
|
||||
static bool lcd_map_control;
|
||||
#endif
|
||||
|
@ -677,8 +677,7 @@
|
||||
lcd_reset_alert_level();
|
||||
LCD_MESSAGEPGM("");
|
||||
lcd_quick_feedback();
|
||||
|
||||
has_control_of_lcd_panel = false;
|
||||
lcd_external_control = false;
|
||||
#endif
|
||||
|
||||
return;
|
||||
@ -738,7 +737,10 @@
|
||||
void unified_bed_leveling::probe_entire_mesh(const float &rx, const float &ry, const bool do_ubl_mesh_map, const bool stow_probe, bool close_or_far) {
|
||||
mesh_index_pair location;
|
||||
|
||||
has_control_of_lcd_panel = true;
|
||||
#if ENABLED(NEWPANEL)
|
||||
lcd_external_control = true;
|
||||
#endif
|
||||
|
||||
save_ubl_active_state_and_disable(); // we don't do bed level correction because we want the raw data when we probe
|
||||
DEPLOY_PROBE();
|
||||
|
||||
@ -748,12 +750,12 @@
|
||||
if (do_ubl_mesh_map) display_map(g29_map_type);
|
||||
|
||||
#if ENABLED(NEWPANEL)
|
||||
if (ubl_lcd_clicked()) {
|
||||
if (is_lcd_clicked()) {
|
||||
SERIAL_PROTOCOLLNPGM("\nMesh only partially populated.\n");
|
||||
lcd_quick_feedback();
|
||||
STOW_PROBE();
|
||||
while (ubl_lcd_clicked()) idle();
|
||||
has_control_of_lcd_panel = false;
|
||||
while (is_lcd_clicked()) idle();
|
||||
lcd_external_control = false;
|
||||
restore_ubl_active_state_and_leave();
|
||||
safe_delay(50); // Debounce the Encoder wheel
|
||||
return;
|
||||
@ -894,11 +896,11 @@
|
||||
|
||||
float unified_bed_leveling::measure_point_with_encoder() {
|
||||
|
||||
while (ubl_lcd_clicked()) delay(50); // wait for user to release encoder wheel
|
||||
while (is_lcd_clicked()) delay(50); // wait for user to release encoder wheel
|
||||
delay(50); // debounce
|
||||
|
||||
KEEPALIVE_STATE(PAUSED_FOR_USER);
|
||||
while (!ubl_lcd_clicked()) { // we need the loop to move the nozzle based on the encoder wheel here!
|
||||
while (!is_lcd_clicked()) { // we need the loop to move the nozzle based on the encoder wheel here!
|
||||
idle();
|
||||
if (encoder_diff) {
|
||||
do_blocking_move_to_z(current_position[Z_AXIS] + 0.01 * float(encoder_diff));
|
||||
@ -912,7 +914,7 @@
|
||||
static void echo_and_take_a_measurement() { SERIAL_PROTOCOLLNPGM(" and take a measurement."); }
|
||||
|
||||
float unified_bed_leveling::measure_business_card_thickness(const float in_height) {
|
||||
has_control_of_lcd_panel = true;
|
||||
lcd_external_control = true;
|
||||
save_ubl_active_state_and_disable(); // Disable bed level correction for probing
|
||||
|
||||
do_blocking_move_to(0.5 * (MESH_MAX_X - (MESH_MIN_X)), 0.5 * (MESH_MAX_Y - (MESH_MIN_Y)), in_height);
|
||||
@ -944,7 +946,7 @@
|
||||
SERIAL_PROTOCOLLNPGM("mm thick.");
|
||||
}
|
||||
|
||||
has_control_of_lcd_panel = false;
|
||||
lcd_external_control = false;
|
||||
|
||||
restore_ubl_active_state_and_leave();
|
||||
|
||||
@ -953,7 +955,7 @@
|
||||
|
||||
void unified_bed_leveling::manually_probe_remaining_mesh(const float &rx, const float &ry, const float &z_clearance, const float &thick, const bool do_ubl_mesh_map) {
|
||||
|
||||
has_control_of_lcd_panel = true;
|
||||
lcd_external_control = true;
|
||||
|
||||
save_ubl_active_state_and_disable(); // we don't do bed level correction because we want the raw data when we probe
|
||||
|
||||
@ -978,7 +980,7 @@
|
||||
do_blocking_move_to_z(z_clearance);
|
||||
|
||||
KEEPALIVE_STATE(PAUSED_FOR_USER);
|
||||
has_control_of_lcd_panel = true;
|
||||
lcd_external_control = true;
|
||||
|
||||
if (do_ubl_mesh_map) display_map(g29_map_type); // show user where we're probing
|
||||
|
||||
@ -987,9 +989,9 @@
|
||||
const float z_step = 0.01; // existing behavior: 0.01mm per click, occasionally step
|
||||
//const float z_step = 1.0 / planner.axis_steps_per_mm[Z_AXIS]; // approx one step each click
|
||||
|
||||
while (ubl_lcd_clicked()) delay(50); // wait for user to release encoder wheel
|
||||
while (is_lcd_clicked()) delay(50); // wait for user to release encoder wheel
|
||||
delay(50); // debounce
|
||||
while (!ubl_lcd_clicked()) { // we need the loop to move the nozzle based on the encoder wheel here!
|
||||
while (!is_lcd_clicked()) { // we need the loop to move the nozzle based on the encoder wheel here!
|
||||
idle();
|
||||
if (encoder_diff) {
|
||||
do_blocking_move_to_z(current_position[Z_AXIS] + float(encoder_diff) * z_step);
|
||||
@ -997,11 +999,11 @@
|
||||
}
|
||||
}
|
||||
|
||||
// this sequence to detect an ubl_lcd_clicked() debounce it and leave if it is
|
||||
// this sequence to detect an is_lcd_clicked() debounce it and leave if it is
|
||||
// a Press and Hold is repeated in a lot of places (including G26_Mesh_Validation.cpp). This
|
||||
// should be redone and compressed.
|
||||
const millis_t nxt = millis() + 1500L;
|
||||
while (ubl_lcd_clicked()) { // debounce and watch for abort
|
||||
while (is_lcd_clicked()) { // debounce and watch for abort
|
||||
idle();
|
||||
if (ELAPSED(millis(), nxt)) {
|
||||
SERIAL_PROTOCOLLNPGM("\nMesh only partially populated.");
|
||||
@ -1009,8 +1011,8 @@
|
||||
|
||||
#if ENABLED(NEWPANEL)
|
||||
lcd_quick_feedback();
|
||||
while (ubl_lcd_clicked()) idle();
|
||||
has_control_of_lcd_panel = false;
|
||||
while (is_lcd_clicked()) idle();
|
||||
lcd_external_control = false;
|
||||
#endif
|
||||
|
||||
KEEPALIVE_STATE(IN_HANDLER);
|
||||
@ -1509,7 +1511,7 @@
|
||||
new_z = FLOOR(new_z * 1000.0) * 0.001; // Chop off digits after the 1000ths place
|
||||
|
||||
KEEPALIVE_STATE(PAUSED_FOR_USER);
|
||||
has_control_of_lcd_panel = true;
|
||||
lcd_external_control = true;
|
||||
|
||||
if (do_ubl_mesh_map) display_map(g29_map_type); // show the user which point is being adjusted
|
||||
|
||||
@ -1523,27 +1525,27 @@
|
||||
do_blocking_move_to_z(h_offset + new_z); // Move the nozzle as the point is edited
|
||||
#endif
|
||||
idle();
|
||||
} while (!ubl_lcd_clicked());
|
||||
} while (!is_lcd_clicked());
|
||||
|
||||
if (!lcd_map_control) lcd_return_to_status();
|
||||
|
||||
// The technique used here generates a race condition for the encoder click.
|
||||
// It could get detected in lcd_mesh_edit (actually _lcd_mesh_fine_tune) or here.
|
||||
// Let's work on specifying a proper API for the LCD ASAP, OK?
|
||||
has_control_of_lcd_panel = true;
|
||||
lcd_external_control = true;
|
||||
|
||||
// this sequence to detect an ubl_lcd_clicked() debounce it and leave if it is
|
||||
// this sequence to detect an is_lcd_clicked() debounce it and leave if it is
|
||||
// a Press and Hold is repeated in a lot of places (including G26_Mesh_Validation.cpp). This
|
||||
// should be redone and compressed.
|
||||
const millis_t nxt = millis() + 1500UL;
|
||||
while (ubl_lcd_clicked()) { // debounce and watch for abort
|
||||
while (is_lcd_clicked()) { // debounce and watch for abort
|
||||
idle();
|
||||
if (ELAPSED(millis(), nxt)) {
|
||||
lcd_return_to_status();
|
||||
do_blocking_move_to_z(Z_CLEARANCE_BETWEEN_PROBES);
|
||||
LCD_MESSAGEPGM(MSG_EDITING_STOPPED);
|
||||
|
||||
while (ubl_lcd_clicked()) idle();
|
||||
while (is_lcd_clicked()) idle();
|
||||
|
||||
goto FINE_TUNE_EXIT;
|
||||
}
|
||||
@ -1559,7 +1561,7 @@
|
||||
|
||||
FINE_TUNE_EXIT:
|
||||
|
||||
has_control_of_lcd_panel = false;
|
||||
lcd_external_control = false;
|
||||
KEEPALIVE_STATE(IN_HANDLER);
|
||||
|
||||
if (do_ubl_mesh_map) display_map(g29_map_type);
|
||||
|
@ -23,9 +23,7 @@
|
||||
|
||||
#if ENABLED(AUTO_BED_LEVELING_UBL)
|
||||
|
||||
#include "ubl.h"
|
||||
|
||||
#include "../../../Marlin.h"
|
||||
#include "../bedlevel.h"
|
||||
#include "../../../module/planner.h"
|
||||
#include "../../../module/stepper.h"
|
||||
#include "../../../module/motion.h"
|
||||
@ -34,6 +32,7 @@
|
||||
#include "../../../module/delta.h"
|
||||
#endif
|
||||
|
||||
#include "../../../Marlin.h"
|
||||
#include <math.h>
|
||||
|
||||
extern float destination[XYZE];
|
||||
@ -55,7 +54,7 @@
|
||||
|
||||
// if the title message starts with a '!' it is so important, we are going to
|
||||
// ignore the status of the g26_debug_flag
|
||||
if (*title != '!' && !ubl.g26_debug_flag) return;
|
||||
if (*title != '!' && !g26_debug_flag) return;
|
||||
|
||||
const float de = destination[E_AXIS] - current_position[E_AXIS];
|
||||
|
||||
|
Reference in New Issue
Block a user