Prusa MINI Firmware overview
|
Go to the documentation of this file.
26 #include "../../../module/motion.h"
28 #define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
29 #include "../../../core/debug_out.h"
31 #define UBL_VERSION "1.01"
39 struct mesh_index_pair;
41 #define MESH_X_DIST (float(MESH_MAX_X - (MESH_MIN_X)) / float(GRID_MAX_POINTS_X - 1))
42 #define MESH_Y_DIST (float(MESH_MAX_Y - (MESH_MIN_Y)) / float(GRID_MAX_POINTS_Y - 1))
47 static int g29_verbose_level,
52 static bool g29_c_flag;
53 static float g29_card_thickness,
59 static int g29_grid_size;
63 static void move_z_with_encoder(
const float &multiplier);
64 static float measure_point_with_encoder();
65 static float measure_business_card_thickness(
float in_height);
66 static void manually_probe_remaining_mesh(
const xy_pos_t&,
const float&,
const float&,
const bool)
_O0;
67 static void fine_tune_mesh(
const xy_pos_t &pos,
const bool do_ubl_mesh_map)
_O0;
70 static bool g29_parameter_parsing()
_O0;
71 static void shift_mesh_height();
72 static void probe_entire_mesh(
const xy_pos_t &near,
const bool do_ubl_mesh_map,
const bool stow_probe,
const bool do_furthest)
_O0;
73 static void tilt_mesh_based_on_3pts(
const float &z1,
const float &z2,
const float &z3);
74 static void tilt_mesh_based_on_probed_grid(
const bool do_ubl_mesh_map);
75 static bool smart_fill_one(
const uint8_t x,
const uint8_t y,
const int8_t xdir,
const int8_t ydir);
77 return smart_fill_one(pos.
x, pos.
y, dir.
x, dir.
y);
79 static void smart_fill_mesh();
81 #if ENABLED(UBL_DEVEL_DEBUGGING)
82 static void g29_what_command();
83 static void g29_eeprom_dump();
84 static void g29_compare_current_mesh_to_stored_mesh();
113 static bool lcd_map_control;
124 return constrain(cx, 0, (GRID_MAX_POINTS_X) - 1);
131 return constrain(cy, 0, (GRID_MAX_POINTS_Y) - 1);
144 return WITHIN(px, 0, GRID_MAX_POINTS_X - 1) ? px : -1;
148 return WITHIN(py, 0, GRID_MAX_POINTS_Y - 1) ? py : -1;
169 FORCE_INLINE static float calc_z0(
const float &a0,
const float &a1,
const float &z1,
const float &a2,
const float &z2) {
170 return z1 + (z2 - z1) * (a0 - a1) / (a2 - a1);
178 if (!
WITHIN(x1_i, 0, GRID_MAX_POINTS_X - 1) || !
WITHIN(yi, 0, GRID_MAX_POINTS_Y - 1)) {
182 DEBUG_ECHOLNPAIR(
" out of bounds in z_correction_for_x_on_horizontal_mesh_line(rx0=", rx0,
",x1_i=", x1_i,
",yi=", yi,
")");
187 #ifdef UBL_Z_RAISE_WHEN_OFF_MESH
188 UBL_Z_RAISE_WHEN_OFF_MESH
198 return z1 + xratio * (
z_values[
_MIN(x1_i, GRID_MAX_POINTS_X - 2) + 1][yi] - z1);
207 if (!
WITHIN(xi, 0, GRID_MAX_POINTS_X - 1) || !
WITHIN(y1_i, 0, GRID_MAX_POINTS_Y - 1)) {
211 DEBUG_ECHOLNPAIR(
" out of bounds in z_correction_for_y_on_vertical_mesh_line(ry0=", ry0,
", xi=", xi,
", y1_i=", y1_i,
")");
216 #ifdef UBL_Z_RAISE_WHEN_OFF_MESH
217 UBL_Z_RAISE_WHEN_OFF_MESH
227 return z1 + yratio * (
z_values[xi][
_MIN(y1_i, GRID_MAX_POINTS_Y - 2) + 1] - z1);
245 #ifdef UBL_Z_RAISE_WHEN_OFF_MESH
246 if (!
WITHIN(rx0, MESH_MIN_X, MESH_MAX_X) || !
WITHIN(ry0, MESH_MIN_Y, MESH_MAX_Y))
247 return UBL_Z_RAISE_WHEN_OFF_MESH;
295 static bool line_to_destination_segmented(
const feedRate_t &scaled_fr_mm_s);
301 for (
uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
302 for (
uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
311 #define _GET_MESH_X(I) ubl.mesh_index_to_xpos(I)
312 #define _GET_MESH_Y(J) ubl.mesh_index_to_ypos(J)
313 #define Z_VALUES_ARR ubl.z_values
316 #include "../../../core/debug_out.h"
#define WITHIN(N, L, H)
Definition: macros.h:195
#define SERIAL_ECHO_TERNARY(TF, PRE, ON, OFF, POST)
Definition: serial.h:188
#define SERIAL_CHAR(x)
Definition: serial.h:69
#define _O2
Definition: macros.h:45
static float z_correction_for_y_on_vertical_mesh_line(const float &ry0, const int xi, const int y1_i)
Definition: ubl.h:206
#define SERIAL_ECHO(x)
Definition: serial.h:70
static float mesh_index_to_ypos(const uint8_t i)
Definition: ubl.h:290
static void adjust_mesh_to_mean(const bool cflag, const float value)
constexpr xyz_pos_t probe_offset
Definition: probe.h:58
static float get_z_correction(const xy_pos_t &pos)
Definition: ubl.h:285
static float z_correction_for_x_on_horizontal_mesh_line(const float &rx0, const int x1_i, const int yi)
Definition: ubl.h:177
#define PROGMEM
Definition: pgmspace.h:29
MarlinSettings settings
Definition: configuration_store.cpp:344
static void display_map(const int) _O0
#define RECIPROCAL(x)
Definition: macros.h:273
static void report_state()
#define DEBUG_EOL()
Definition: debug_out.h:86
static bool leveling_active
Definition: planner.h:276
#define SERIAL_ECHOPAIR(V...)
Definition: serial.h:114
uint8_t i
Definition: screen_test_graph.c:72
#define SERIAL_ECHOLNPAIR_F(V...)
Definition: serial.h:177
static int8_t storage_slot
Definition: ubl.h:106
#define _MIN(V...)
Definition: macros.h:333
Definition: L6470_Marlin.h:30
static void line_to_destination_cartesian(const feedRate_t &scaled_fr_mm_s, const uint8_t e)
static void restore_ubl_active_state_and_leave()
xy_float_t xy_pos_t
Definition: types.h:159
static xy_int8_t closest_indexes(const xy_pos_t &xy)
Definition: ubl.h:150
#define DEBUG_ECHOLNPAIR(...)
Definition: debug_out.h:82
static float mesh_index_to_xpos(const uint8_t i)
Definition: ubl.h:287
#define SERIAL_ECHO_START()
Definition: serial.h:179
float feedRate_t
Definition: types.h:80
#define SERIAL_ECHO_SP(C)
Definition: serial.h:186
static bool sanity_check()
static int8_t closest_x_index(const float &x)
Definition: ubl.h:142
#define DEBUG_ECHOPGM(...)
Definition: debug_out.h:78
static FORCE_INLINE float calc_z0(const float &a0, const float &a1, const float &z1, const float &a2, const float &z2)
Definition: ubl.h:169
#define MESH_Y_DIST
Definition: ubl.h:42
#define DEBUG_ECHOLNPAIR_F(...)
Definition: debug_out.h:83
#define MESH_X_DIST
Definition: ubl.h:41
static xy_int8_t cell_indexes(const xy_pos_t &xy)
Definition: ubl.h:140
static mesh_index_pair find_closest_mesh_point_of_type(const MeshPointType, const xy_pos_t &, const bool=false, MeshFlags *done_flags=nullptr) _O0
static const float _mesh_index_to_xpos[GRID_MAX_POINTS_X]
Definition: ubl.h:109
#define ZERO(a)
Definition: macros.h:201
#define FORCE_INLINE
Definition: macros.h:40
#define SERIAL_ECHO_MSG(S)
Definition: serial.h:183
#define PSTR(str)
Definition: pgmspace.h:31
void set_bed_leveling_enabled(const bool enable=true)
xyze_pos_t current_position
Definition: motion.cpp:102
static const float _mesh_index_to_ypos[GRID_MAX_POINTS_Y]
Definition: ubl.h:109
static int8_t cell_index_x(const float &x)
Definition: ubl.h:122
#define isnan
Definition: Arduino.h:55
void onMeshUpdate(const uint8_t xpos, const uint8_t ypos, const float zval)
Definition: marlin_server.cpp:945
static mesh_index_pair find_furthest_invalid_mesh_point() _O0
static xy_int8_t cell_indexes(const float &x, const float &y)
Definition: ubl.h:137
#define constrain(amt, low, high)
Definition: wiring_constants.h:79
#define SERIAL_ECHO_F(V...)
Definition: serial.h:71
#define pgm_read_float(addr)
Definition: pgmspace.h:109
#define SERIAL_ECHOPGM(S)
Definition: serial.h:173
static float get_z_correction(const float &rx0, const float &ry0)
Definition: ubl.h:238
T x
Definition: types.h:185
const uint8_t[]
Definition: 404_html.c:3
static int8_t closest_y_index(const float &y)
Definition: ubl.h:146
#define UBL_VERSION
Definition: ubl.h:31
static bool mesh_is_valid()
Definition: ubl.h:300
#define DEBUG_ECHO(...)
Definition: debug_out.h:75
#define DEBUG_ECHOPAIR_F(...)
Definition: debug_out.h:81
#define _O0
Definition: macros.h:42
static void set_all_mesh_points_to_value(const float value)
#define DEBUGGING(F)
Definition: serial.h:47
void report_current_position()
Definition: motion.cpp:199
static void report_current_mesh()
static void smart_fill_wlsf(const float &) _O2
#define ARRAY_N(N, V...)
Definition: macros.h:227
static volatile int encoder_diff
Definition: ubl.h:116
MeshPointType
Definition: ubl.h:35
#define SERIAL_EOL()
Definition: serial.h:181
#define DEBUG_ECHOPAIR(...)
Definition: debug_out.h:80
#define SERIAL_FLUSHTX()
Definition: serial.h:81
T y
Definition: types.h:185
void serial_delay(const millis_t ms)
Definition: utility.h:31
void serialprintPGM(PGM_P str)
Definition: serial.cpp:35
#define SERIAL_ECHOLNPGM(S)
Definition: serial.h:174
#define DEBUG_CHAR(...)
Definition: debug_out.h:74
Definition: L6470_Marlin.h:30
static FORCE_INLINE void set_z(const int8_t px, const int8_t py, const float &z)
Definition: ubl.h:120
void idle()
Definition: Marlin.cpp:629
static void save_ubl_active_state_and_disable()
static int8_t cell_index_y(const float &y)
Definition: ubl.h:129
static bed_mesh_t z_values
Definition: ubl.h:108
bool suspend_auto_report
Definition: Marlin.cpp:192
Planner planner
Definition: planner.cpp:111