Prusa MINI Firmware overview
|
#include <ubl.h>
|
static void | echo_name () |
|
static void | report_current_mesh () |
|
static void | report_state () |
|
static void | save_ubl_active_state_and_disable () |
|
static void | restore_ubl_active_state_and_leave () |
|
static void | display_map (const int) _O0 |
|
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 mesh_index_pair | find_furthest_invalid_mesh_point () _O0 |
|
static void | reset () |
|
static void | invalidate () |
|
static void | set_all_mesh_points_to_value (const float value) |
|
static void | adjust_mesh_to_mean (const bool cflag, const float value) |
|
static bool | sanity_check () |
|
static void | G29 () _O0 |
|
static void | smart_fill_wlsf (const float &) _O2 |
|
static FORCE_INLINE void | set_z (const int8_t px, const int8_t py, const float &z) |
|
static int8_t | cell_index_x (const float &x) |
|
static int8_t | cell_index_y (const float &y) |
|
static xy_int8_t | cell_indexes (const float &x, const float &y) |
|
static xy_int8_t | cell_indexes (const xy_pos_t &xy) |
|
static int8_t | closest_x_index (const float &x) |
|
static int8_t | closest_y_index (const float &y) |
|
static xy_int8_t | closest_indexes (const xy_pos_t &xy) |
|
static FORCE_INLINE float | calc_z0 (const float &a0, const float &a1, const float &z1, const float &a2, const float &z2) |
|
static float | z_correction_for_x_on_horizontal_mesh_line (const float &rx0, const int x1_i, const int yi) |
|
static float | z_correction_for_y_on_vertical_mesh_line (const float &ry0, const int xi, const int y1_i) |
|
static float | get_z_correction (const float &rx0, const float &ry0) |
|
static float | get_z_correction (const xy_pos_t &pos) |
|
static float | mesh_index_to_xpos (const uint8_t i) |
|
static float | mesh_index_to_ypos (const uint8_t i) |
|
static void | line_to_destination_cartesian (const feedRate_t &scaled_fr_mm_s, const uint8_t e) |
|
static bool | mesh_is_valid () |
|
◆ unified_bed_leveling()
unified_bed_leveling::unified_bed_leveling |
( |
| ) |
|
◆ echo_name()
static void unified_bed_leveling::echo_name |
( |
| ) |
|
|
static |
◆ report_current_mesh()
static void unified_bed_leveling::report_current_mesh |
( |
| ) |
|
|
static |
◆ report_state()
static void unified_bed_leveling::report_state |
( |
| ) |
|
|
static |
◆ save_ubl_active_state_and_disable()
static void unified_bed_leveling::save_ubl_active_state_and_disable |
( |
| ) |
|
|
static |
◆ restore_ubl_active_state_and_leave()
static void unified_bed_leveling::restore_ubl_active_state_and_leave |
( |
| ) |
|
|
static |
◆ display_map()
static void unified_bed_leveling::display_map |
( |
const int |
| ) |
|
|
static |
◆ find_closest_mesh_point_of_type()
static mesh_index_pair unified_bed_leveling::find_closest_mesh_point_of_type |
( |
const |
MeshPointType, |
|
|
const xy_pos_t & |
, |
|
|
const bool |
= false , |
|
|
MeshFlags * |
done_flags = nullptr |
|
) |
| |
|
static |
◆ find_furthest_invalid_mesh_point()
static mesh_index_pair unified_bed_leveling::find_furthest_invalid_mesh_point |
( |
| ) |
|
|
static |
◆ reset()
static void unified_bed_leveling::reset |
( |
| ) |
|
|
static |
◆ invalidate()
static void unified_bed_leveling::invalidate |
( |
| ) |
|
|
static |
◆ set_all_mesh_points_to_value()
static void unified_bed_leveling::set_all_mesh_points_to_value |
( |
const float |
value | ) |
|
|
static |
◆ adjust_mesh_to_mean()
static void unified_bed_leveling::adjust_mesh_to_mean |
( |
const bool |
cflag, |
|
|
const float |
value |
|
) |
| |
|
static |
◆ sanity_check()
static bool unified_bed_leveling::sanity_check |
( |
| ) |
|
|
static |
◆ G29()
static void unified_bed_leveling::G29 |
( |
| ) |
|
|
static |
◆ smart_fill_wlsf()
static void unified_bed_leveling::smart_fill_wlsf |
( |
const float & |
| ) |
|
|
static |
◆ set_z()
◆ cell_index_x()
static int8_t unified_bed_leveling::cell_index_x |
( |
const float & |
x | ) |
|
|
static |
124 return constrain(cx, 0, (GRID_MAX_POINTS_X) - 1);
◆ cell_index_y()
static int8_t unified_bed_leveling::cell_index_y |
( |
const float & |
y | ) |
|
|
static |
131 return constrain(cy, 0, (GRID_MAX_POINTS_Y) - 1);
◆ cell_indexes() [1/2]
◆ cell_indexes() [2/2]
◆ closest_x_index()
static int8_t unified_bed_leveling::closest_x_index |
( |
const float & |
x | ) |
|
|
static |
144 return WITHIN(px, 0, GRID_MAX_POINTS_X - 1) ? px : -1;
◆ closest_y_index()
static int8_t unified_bed_leveling::closest_y_index |
( |
const float & |
y | ) |
|
|
static |
148 return WITHIN(py, 0, GRID_MAX_POINTS_Y - 1) ? py : -1;
◆ closest_indexes()
◆ calc_z0()
z2 --|
z0 | |
| | + (z2-z1)
z1 | | | —+----------—+-----—+– –| a1 a0 a2 |<—delta_a-------—>|
calc_z0 is the basis for all the Mesh Based correction. It is used to find the expected Z Height at a position between two known Z-Height locations.
It is fairly expensive with its 4 floating point additions and 2 floating point multiplications.
170 return z1 + (z2 - z1) * (a0 - a1) / (a2 - a1);
◆ z_correction_for_x_on_horizontal_mesh_line()
static float unified_bed_leveling::z_correction_for_x_on_horizontal_mesh_line |
( |
const float & |
rx0, |
|
|
const int |
x1_i, |
|
|
const int |
yi |
|
) |
| |
|
static |
z_correction_for_x_on_horizontal_mesh_line is an optimization for the case where the printer is making a vertical line that only crosses horizontal mesh lines.
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);
◆ z_correction_for_y_on_vertical_mesh_line()
static float unified_bed_leveling::z_correction_for_y_on_vertical_mesh_line |
( |
const float & |
ry0, |
|
|
const int |
xi, |
|
|
const int |
y1_i |
|
) |
| |
|
static |
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);
◆ get_z_correction() [1/2]
static float unified_bed_leveling::get_z_correction |
( |
const float & |
rx0, |
|
|
const float & |
ry0 |
|
) |
| |
|
static |
This is the generic Z-Correction. It works anywhere within a Mesh Cell. It first does a linear interpolation along both of the bounding X-Mesh-Lines to find the Z-Height at both ends. Then it does a linear interpolation of these heights based on the Y position within the cell.
Check if the requested location is off the mesh. If so, and UBL_Z_RAISE_WHEN_OFF_MESH is specified, that value is returned.
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;
◆ get_z_correction() [2/2]
static float unified_bed_leveling::get_z_correction |
( |
const xy_pos_t & |
pos | ) |
|
|
static |
◆ mesh_index_to_xpos()
static float unified_bed_leveling::mesh_index_to_xpos |
( |
const uint8_t |
i | ) |
|
|
static |
◆ mesh_index_to_ypos()
static float unified_bed_leveling::mesh_index_to_ypos |
( |
const uint8_t |
i | ) |
|
|
static |
◆ line_to_destination_cartesian()
◆ mesh_is_valid()
static bool unified_bed_leveling::mesh_is_valid |
( |
| ) |
|
|
static |
301 for (
uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
302 for (
uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
◆ storage_slot
int8_t unified_bed_leveling::storage_slot |
|
static |
◆ z_values
bed_mesh_t unified_bed_leveling::z_values |
|
static |
◆ _mesh_index_to_xpos
const float unified_bed_leveling::_mesh_index_to_xpos[GRID_MAX_POINTS_X] |
|
static |
◆ _mesh_index_to_ypos
const float unified_bed_leveling::_mesh_index_to_ypos[GRID_MAX_POINTS_Y] |
|
static |
◆ encoder_diff
volatile int unified_bed_leveling::encoder_diff |
|
static |
#define WITHIN(N, L, H)
Definition: macros.h:195
static float mesh_index_to_ypos(const uint8_t i)
Definition: ubl.h:290
#define RECIPROCAL(x)
Definition: macros.h:273
#define DEBUG_EOL()
Definition: debug_out.h:86
uint8_t i
Definition: screen_test_graph.c:72
#define _MIN(V...)
Definition: macros.h:333
#define DEBUG_ECHOLNPAIR(...)
Definition: debug_out.h:82
static float mesh_index_to_xpos(const uint8_t i)
Definition: ubl.h:287
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 const float _mesh_index_to_xpos[GRID_MAX_POINTS_X]
Definition: ubl.h:109
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
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 pgm_read_float(addr)
Definition: pgmspace.h:109
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 DEBUG_ECHO(...)
Definition: debug_out.h:75
#define DEBUG_ECHOPAIR_F(...)
Definition: debug_out.h:81
#define DEBUGGING(F)
Definition: serial.h:47
#define DEBUG_ECHOPAIR(...)
Definition: debug_out.h:80
T y
Definition: types.h:185
#define DEBUG_CHAR(...)
Definition: debug_out.h:74
static int8_t cell_index_y(const float &y)
Definition: ubl.h:129
static bed_mesh_t z_values
Definition: ubl.h:108