Prusa MINI Firmware overview
mesh_bed_leveling Class Reference

#include <mesh_bed_leveling.h>

Collaboration diagram for mesh_bed_leveling:

Public Member Functions

 mesh_bed_leveling ()
 

Static Public Member Functions

static void report_mesh ()
 
static void reset ()
 
static FORCE_INLINE bool has_mesh ()
 
static void set_z (const int8_t px, const int8_t py, const float &z)
 
static void zigzag (const int8_t index, int8_t &px, int8_t &py)
 
static void set_zigzag_z (const int8_t index, 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 probe_index_x (const float &x)
 
static int8_t probe_index_y (const float &y)
 
static xy_int8_t probe_indexes (const float &x, const float &y)
 
static xy_int8_t probe_indexes (const xy_pos_t &xy)
 
static float calc_z0 (const float &a0, const float &a1, const float &z1, const float &a2, const float &z2)
 
static float get_z (const xy_pos_t &pos)
 
static void line_to_destination (const feedRate_t &scaled_fr_mm_s, uint8_t x_splits=0xFF, uint8_t y_splits=0xFF)
 

Static Public Attributes

static float z_offset
 
static float z_values [GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y]
 
static float index_to_xpos [GRID_MAX_POINTS_X]
 
static float index_to_ypos [GRID_MAX_POINTS_Y]
 

Constructor & Destructor Documentation

◆ mesh_bed_leveling()

mesh_bed_leveling::mesh_bed_leveling ( )

Member Function Documentation

◆ report_mesh()

static void mesh_bed_leveling::report_mesh ( )
static

◆ reset()

static void mesh_bed_leveling::reset ( )
static

◆ has_mesh()

static FORCE_INLINE bool mesh_bed_leveling::has_mesh ( )
static
54  {
55  for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
56  for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
57  if (z_values[x][y]) return true;
58  return false;
59  }

◆ set_z()

static void mesh_bed_leveling::set_z ( const int8_t  px,
const int8_t  py,
const float &  z 
)
static
61 { z_values[px][py] = z; }
Here is the caller graph for this function:

◆ zigzag()

static void mesh_bed_leveling::zigzag ( const int8_t  index,
int8_t &  px,
int8_t &  py 
)
static
63  {
64  px = index % (GRID_MAX_POINTS_X);
65  py = index / (GRID_MAX_POINTS_X);
66  if (py & 1) px = (GRID_MAX_POINTS_X - 1) - px; // Zig zag
67  }
Here is the caller graph for this function:

◆ set_zigzag_z()

static void mesh_bed_leveling::set_zigzag_z ( const int8_t  index,
const float &  z 
)
static
69  {
70  int8_t px, py;
71  zigzag(index, px, py);
72  set_z(px, py, z);
73  }
Here is the call graph for this function:

◆ cell_index_x()

static int8_t mesh_bed_leveling::cell_index_x ( const float &  x)
static
75  {
76  int8_t cx = (x - (MESH_MIN_X)) * RECIPROCAL(MESH_X_DIST);
77  return constrain(cx, 0, (GRID_MAX_POINTS_X) - 2);
78  }
Here is the caller graph for this function:

◆ cell_index_y()

static int8_t mesh_bed_leveling::cell_index_y ( const float &  y)
static
79  {
80  int8_t cy = (y - (MESH_MIN_Y)) * RECIPROCAL(MESH_Y_DIST);
81  return constrain(cy, 0, (GRID_MAX_POINTS_Y) - 2);
82  }
Here is the caller graph for this function:

◆ cell_indexes() [1/2]

static xy_int8_t mesh_bed_leveling::cell_indexes ( const float &  x,
const float &  y 
)
static
83  {
84  return { cell_index_x(x), cell_index_y(y) };
85  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cell_indexes() [2/2]

static xy_int8_t mesh_bed_leveling::cell_indexes ( const xy_pos_t xy)
static
86 { return cell_indexes(xy.x, xy.y); }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ probe_index_x()

static int8_t mesh_bed_leveling::probe_index_x ( const float &  x)
static
88  {
89  int8_t px = (x - (MESH_MIN_X) + 0.5f * (MESH_X_DIST)) * RECIPROCAL(MESH_X_DIST);
90  return WITHIN(px, 0, GRID_MAX_POINTS_X - 1) ? px : -1;
91  }
Here is the caller graph for this function:

◆ probe_index_y()

static int8_t mesh_bed_leveling::probe_index_y ( const float &  y)
static
92  {
93  int8_t py = (y - (MESH_MIN_Y) + 0.5f * (MESH_Y_DIST)) * RECIPROCAL(MESH_Y_DIST);
94  return WITHIN(py, 0, GRID_MAX_POINTS_Y - 1) ? py : -1;
95  }
Here is the caller graph for this function:

◆ probe_indexes() [1/2]

static xy_int8_t mesh_bed_leveling::probe_indexes ( const float &  x,
const float &  y 
)
static
96  {
97  return { probe_index_x(x), probe_index_y(y) };
98  }
Here is the call graph for this function:

◆ probe_indexes() [2/2]

static xy_int8_t mesh_bed_leveling::probe_indexes ( const xy_pos_t xy)
static
99 { return probe_indexes(xy.x, xy.y); }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ calc_z0()

static float mesh_bed_leveling::calc_z0 ( const float &  a0,
const float &  a1,
const float &  z1,
const float &  a2,
const float &  z2 
)
static
101  {
102  const float delta_z = (z2 - z1) / (a2 - a1),
103  delta_a = a0 - a1;
104  return z1 + delta_a * delta_z;
105  }
Here is the caller graph for this function:

◆ get_z()

static float mesh_bed_leveling::get_z ( const xy_pos_t pos)
static
111  {
112  #if DISABLED(ENABLE_LEVELING_FADE_HEIGHT)
113  constexpr float factor = 1.0f;
114  #endif
115  const xy_int8_t ind = cell_indexes(pos);
116  const float x1 = index_to_xpos[ind.x], x2 = index_to_xpos[ind.x+1],
117  y1 = index_to_xpos[ind.y], y2 = index_to_xpos[ind.y+1],
118  z1 = calc_z0(pos.x, x1, z_values[ind.x][ind.y ], x2, z_values[ind.x+1][ind.y ]),
119  z2 = calc_z0(pos.x, x1, z_values[ind.x][ind.y+1], x2, z_values[ind.x+1][ind.y+1]);
120 
121  return z_offset + calc_z0(pos.y, y1, z1, y2, z2) * factor;
122  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ line_to_destination()

static void mesh_bed_leveling::line_to_destination ( const feedRate_t scaled_fr_mm_s,
uint8_t  x_splits = 0xFF,
uint8_t  y_splits = 0xFF 
)
static
Here is the caller graph for this function:

Member Data Documentation

◆ z_offset

float mesh_bed_leveling::z_offset
static

◆ z_values

float mesh_bed_leveling::z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y]
static

◆ index_to_xpos

float mesh_bed_leveling::index_to_xpos[GRID_MAX_POINTS_X]
static

◆ index_to_ypos

float mesh_bed_leveling::index_to_ypos[GRID_MAX_POINTS_Y]
static
WITHIN
#define WITHIN(N, L, H)
Definition: macros.h:195
mesh_bed_leveling::index_to_xpos
static float index_to_xpos[GRID_MAX_POINTS_X]
Definition: mesh_bed_leveling.h:43
RECIPROCAL
#define RECIPROCAL(x)
Definition: macros.h:273
mesh_bed_leveling::probe_index_x
static int8_t probe_index_x(const float &x)
Definition: mesh_bed_leveling.h:88
mesh_bed_leveling::zigzag
static void zigzag(const int8_t index, int8_t &px, int8_t &py)
Definition: mesh_bed_leveling.h:63
mesh_bed_leveling::cell_index_y
static int8_t cell_index_y(const float &y)
Definition: mesh_bed_leveling.h:79
mesh_bed_leveling::probe_indexes
static xy_int8_t probe_indexes(const float &x, const float &y)
Definition: mesh_bed_leveling.h:96
mesh_bed_leveling::z_values
static float z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y]
Definition: mesh_bed_leveling.h:43
mesh_bed_leveling::cell_index_x
static int8_t cell_index_x(const float &x)
Definition: mesh_bed_leveling.h:75
constrain
#define constrain(amt, low, high)
Definition: wiring_constants.h:79
mesh_bed_leveling::set_z
static void set_z(const int8_t px, const int8_t py, const float &z)
Definition: mesh_bed_leveling.h:61
XYval
Definition: types.h:99
MESH_X_DIST
#define MESH_X_DIST
Definition: mesh_bed_leveling.h:35
XYval::x
T x
Definition: types.h:185
MESH_Y_DIST
#define MESH_Y_DIST
Definition: mesh_bed_leveling.h:36
uint8_t
const uint8_t[]
Definition: 404_html.c:3
mesh_bed_leveling::z_offset
static float z_offset
Definition: mesh_bed_leveling.h:43
mesh_bed_leveling::probe_index_y
static int8_t probe_index_y(const float &y)
Definition: mesh_bed_leveling.h:92
mesh_bed_leveling::calc_z0
static float calc_z0(const float &a0, const float &a1, const float &z1, const float &a2, const float &z2)
Definition: mesh_bed_leveling.h:101
XYval::y
T y
Definition: types.h:185
mesh_bed_leveling::cell_indexes
static xy_int8_t cell_indexes(const float &x, const float &y)
Definition: mesh_bed_leveling.h:83