Skip to content

Commit 685e5bb

Browse files
Roxy-3Ddamicreabox
authored andcommitted
Fix G26's circle drawing... (MarlinFirmware#8291)
* Fix G26's circle drawing... This mostly catches the bugfix-v1.1.x branch up to bugfix-v2.0.0 I'll have to do something similar to get bugfix-v2.0.0 caught up to bugfix-v1.1.x * only use planner.leveling_active if appropriate
1 parent 7545456 commit 685e5bb

File tree

6 files changed

+144
-74
lines changed

6 files changed

+144
-74
lines changed

Marlin/Marlin_main.cpp

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10071,7 +10071,7 @@ void quickstop_stepper() {
1007110071
hasQ = !hasZ && parser.seen('Q');
1007210072

1007310073
if (hasC) {
10074-
const mesh_index_pair location = ubl.find_closest_mesh_point_of_type(REAL, current_position[X_AXIS], current_position[Y_AXIS], USE_NOZZLE_AS_REFERENCE, NULL, false);
10074+
const mesh_index_pair location = ubl.find_closest_mesh_point_of_type(REAL, current_position[X_AXIS], current_position[Y_AXIS], USE_NOZZLE_AS_REFERENCE, NULL);
1007510075
ix = location.x_index;
1007610076
iy = location.y_index;
1007710077
}
@@ -12955,24 +12955,28 @@ void set_current_from_steppers_for_axis(const AxisEnum axis) {
1295512955
* Returns true if current_position[] was set to destination[]
1295612956
*/
1295712957
inline bool prepare_move_to_destination_cartesian() {
12958-
if (current_position[X_AXIS] != destination[X_AXIS] || current_position[Y_AXIS] != destination[Y_AXIS]) {
12959-
const float fr_scaled = MMS_SCALED(feedrate_mm_s);
12958+
const float fr_scaled = MMS_SCALED(feedrate_mm_s);
1296012959
#if HAS_MESH
12961-
if (planner.leveling_active) {
12962-
#if ENABLED(AUTO_BED_LEVELING_UBL)
12963-
ubl.line_to_destination_cartesian(fr_scaled, active_extruder);
12964-
#elif ENABLED(MESH_BED_LEVELING)
12965-
mesh_line_to_destination(fr_scaled);
12966-
#elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
12967-
bilinear_line_to_destination(fr_scaled);
12968-
#endif
12969-
return true;
12960+
if (!planner.leveling_active) {
12961+
line_to_destination(fr_scaled);
12962+
return false;
1297012963
}
12964+
#if ENABLED(AUTO_BED_LEVELING_UBL)
12965+
ubl.line_to_destination_cartesian(fr_scaled, active_extruder); // UBL's motion routine needs to know about all moves,
12966+
return true; // even purely Z-Axis moves
12967+
#else
12968+
if (current_position[X_AXIS] != destination[X_AXIS] || current_position[Y_AXIS] != destination[Y_AXIS]) {
12969+
#if ENABLED(MESH_BED_LEVELING)
12970+
mesh_line_to_destination(fr_scaled);
12971+
#elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
12972+
bilinear_line_to_destination(fr_scaled);
12973+
#endif
12974+
return true;
12975+
}
12976+
else
12977+
line_to_destination();
12978+
#endif
1297112979
#endif // HAS_MESH
12972-
line_to_destination(fr_scaled);
12973-
}
12974-
else
12975-
line_to_destination();
1297612980

1297712981
return false;
1297812982
}

Marlin/example_configurations/gCreate/gMax1.5+/Configuration.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@
694694
*/
695695
#define X_PROBE_OFFSET_FROM_EXTRUDER -17 // X offset: -left +right [of the nozzle]
696696
#define Y_PROBE_OFFSET_FROM_EXTRUDER -10 // Y offset: -front +behind [the nozzle]
697-
#define Z_PROBE_OFFSET_FROM_EXTRUDER -1.027 // Z offset: -below +above [the nozzle]
697+
#define Z_PROBE_OFFSET_FROM_EXTRUDER -0.87 // Z offset: -below +above [the nozzle]
698698

699699
// X and Y axis travel speed (mm/m) between probes
700700
#define XY_PROBE_SPEED 7500

Marlin/example_configurations/gCreate/gMax1.5+/Configuration_adv.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@
617617
* On print completion the LCD Menu will open with the file selected.
618618
* You can just click to start the print, or navigate elsewhere.
619619
*/
620-
//#define SD_REPRINT_LAST_SELECTED_FILE
620+
#define SD_REPRINT_LAST_SELECTED_FILE
621621

622622
#endif // SDSUPPORT
623623

@@ -679,7 +679,7 @@
679679
#if ENABLED(BABYSTEPPING)
680680
//#define BABYSTEP_XY // Also enable X/Y Babystepping. Not supported on DELTA!
681681
#define BABYSTEP_INVERT_Z false // Change if Z babysteps should go the other way
682-
#define BABYSTEP_MULTIPLICATOR 1 // Babysteps are very small. Increase for faster motion.
682+
#define BABYSTEP_MULTIPLICATOR 3 // Babysteps are very small. Increase for faster motion.
683683
//#define BABYSTEP_ZPROBE_OFFSET // Enable to combine M851 and Babystepping
684684
#define DOUBLECLICK_FOR_Z_BABYSTEPPING // Double-click on the Status Screen for Z Babystepping.
685685
#define DOUBLECLICK_MAX_INTERVAL 1250 // Maximum interval between clicks, in milliseconds.

Marlin/ubl.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@
3636
* to unsigned long will allow us to go to 32x32 if higher resolution Mesh's are needed
3737
* in the future.
3838
*/
39-
void bit_clear(uint16_t bits[16], uint8_t x, uint8_t y) { CBI(bits[y], x); }
40-
void bit_set(uint16_t bits[16], uint8_t x, uint8_t y) { SBI(bits[y], x); }
41-
bool is_bit_set(uint16_t bits[16], uint8_t x, uint8_t y) { return TEST(bits[y], x); }
39+
void bit_clear(uint16_t bits[16], const uint8_t x, const uint8_t y) { CBI(bits[y], x); }
40+
void bit_set(uint16_t bits[16], const uint8_t x, const uint8_t y) { SBI(bits[y], x); }
41+
bool is_bit_set(uint16_t bits[16], const uint8_t x, const uint8_t y) { return TEST(bits[y], x); }
4242

4343
uint8_t ubl_cnt = 0;
4444

Marlin/ubl.h

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@
4646

4747
// ubl.cpp
4848

49-
void bit_clear(uint16_t bits[16], uint8_t x, uint8_t y);
50-
void bit_set(uint16_t bits[16], uint8_t x, uint8_t y);
51-
bool is_bit_set(uint16_t bits[16], uint8_t x, uint8_t y);
49+
void bit_clear(uint16_t bits[16], const uint8_t x, const uint8_t y);
50+
void bit_set(uint16_t bits[16], const uint8_t x, const uint8_t y);
51+
bool is_bit_set(uint16_t bits[16], const uint8_t x, const uint8_t y);
5252

5353
// ubl_motion.cpp
5454

@@ -147,7 +147,8 @@
147147
static void save_ubl_active_state_and_disable();
148148
static void restore_ubl_active_state_and_leave();
149149
static void display_map(const int);
150-
static mesh_index_pair find_closest_mesh_point_of_type(const MeshPointType, const float&, const float&, const bool, uint16_t[16], bool);
150+
static mesh_index_pair find_closest_mesh_point_of_type(const MeshPointType, const float&, const float&, const bool, uint16_t[16]);
151+
static mesh_index_pair find_furthest_invalid_mesh_point();
151152
static void reset();
152153
static void invalidate();
153154
static void set_all_mesh_points_to_value(const float);
@@ -246,12 +247,16 @@
246247
*/
247248
inline static float z_correction_for_x_on_horizontal_mesh_line(const float &rx0, const int x1_i, const int yi) {
248249
if (!WITHIN(x1_i, 0, GRID_MAX_POINTS_X - 2) || !WITHIN(yi, 0, GRID_MAX_POINTS_Y - 1)) {
250+
#if ENABLED(DEBUG_LEVELING_FEATURE)
251+
if (DEBUGGING(LEVELING)) {
249252
serialprintPGM( !WITHIN(x1_i, 0, GRID_MAX_POINTS_X - 1) ? PSTR("x1l_i") : PSTR("yi") );
250253
SERIAL_ECHOPAIR(" out of bounds in z_correction_for_x_on_horizontal_mesh_line(rx0=", rx0);
251254
SERIAL_ECHOPAIR(",x1_i=", x1_i);
252255
SERIAL_ECHOPAIR(",yi=", yi);
253256
SERIAL_CHAR(')');
254257
SERIAL_EOL();
258+
}
259+
#endif
255260
return NAN;
256261
}
257262

@@ -266,12 +271,16 @@
266271
//
267272
inline static float z_correction_for_y_on_vertical_mesh_line(const float &ry0, const int xi, const int y1_i) {
268273
if (!WITHIN(xi, 0, GRID_MAX_POINTS_X - 1) || !WITHIN(y1_i, 0, GRID_MAX_POINTS_Y - 2)) {
274+
#if ENABLED(DEBUG_LEVELING_FEATURE)
275+
if (DEBUGGING(LEVELING)) {
269276
serialprintPGM( !WITHIN(xi, 0, GRID_MAX_POINTS_X - 1) ? PSTR("xi") : PSTR("yl_i") );
270277
SERIAL_ECHOPAIR(" out of bounds in z_correction_for_y_on_vertical_mesh_line(ry0=", ry0);
271278
SERIAL_ECHOPAIR(", xi=", xi);
272279
SERIAL_ECHOPAIR(", y1_i=", y1_i);
273280
SERIAL_CHAR(')');
274281
SERIAL_EOL();
282+
}
283+
#endif
275284
return NAN;
276285
}
277286

@@ -365,6 +374,19 @@
365374
static bool prepare_segmented_line_to(const float rtarget[XYZE], const float &feedrate);
366375
static void line_to_destination_cartesian(const float &fr, uint8_t e);
367376

377+
#define _CMPZ(a,b) (z_values[a][b] == z_values[a][b+1])
378+
#define CMPZ(a) (_CMPZ(a, 0) && _CMPZ(a, 1))
379+
#define ZZER(a) (z_values[a][0] == 0)
380+
381+
FORCE_INLINE bool mesh_is_valid() {
382+
return !(
383+
( CMPZ(0) && CMPZ(1) && CMPZ(2) // adjacent z values all equal?
384+
&& ZZER(0) && ZZER(1) && ZZER(2) // all zero at the edge?
385+
)
386+
|| isnan(z_values[0][0])
387+
);
388+
}
389+
368390
}; // class unified_bed_leveling
369391

370392
extern unified_bed_leveling ubl;

0 commit comments

Comments
 (0)