Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
marlin-anet-a8
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jonas Leder
marlin-anet-a8
Commits
bc5a547d
Commit
bc5a547d
authored
9 years ago
by
Scott Lahteine
Browse files
Options
Downloads
Patches
Plain Diff
More robust MBL index / point conversion
parent
a3520b6f
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
Marlin/mesh_bed_leveling.cpp
+2
-2
2 additions, 2 deletions
Marlin/mesh_bed_leveling.cpp
Marlin/mesh_bed_leveling.h
+18
-15
18 additions, 15 deletions
Marlin/mesh_bed_leveling.h
with
20 additions
and
17 deletions
Marlin/mesh_bed_leveling.cpp
+
2
−
2
View file @
bc5a547d
...
...
@@ -31,8 +31,8 @@
void
mesh_bed_leveling
::
reset
()
{
active
=
0
;
z_offset
=
0
;
for
(
int
y
=
0
;
y
<
MESH_NUM_Y_POINTS
;
y
++
)
for
(
int
x
=
0
;
x
<
MESH_NUM_X_POINTS
;
x
++
)
for
(
int
8_t
y
=
MESH_NUM_Y_POINTS
;
y
--
;
)
for
(
int
8_t
x
=
MESH_NUM_X_POINTS
;
x
--
;
)
z_values
[
y
][
x
]
=
0
;
}
...
...
This diff is collapsed.
Click to expand it.
Marlin/mesh_bed_leveling.h
+
18
−
15
View file @
bc5a547d
...
...
@@ -37,32 +37,34 @@
void
reset
();
float
get_x
(
int
i
)
{
return
MESH_MIN_X
+
(
MESH_X_DIST
)
*
i
;
}
float
get_y
(
int
i
)
{
return
MESH_MIN_Y
+
(
MESH_Y_DIST
)
*
i
;
}
void
set_z
(
int
ix
,
int
iy
,
float
z
)
{
z_values
[
iy
][
ix
]
=
z
;
}
static
FORCE_INLINE
float
get_x
(
int
8_t
i
)
{
return
MESH_MIN_X
+
(
MESH_X_DIST
)
*
i
;
}
static
FORCE_INLINE
float
get_y
(
int
8_t
i
)
{
return
MESH_MIN_Y
+
(
MESH_Y_DIST
)
*
i
;
}
void
set_z
(
int
8_t
ix
,
int
8_t
iy
,
float
z
)
{
z_values
[
iy
][
ix
]
=
z
;
}
inline
void
zigzag
(
int
index
,
int
&
ix
,
int
&
iy
)
{
inline
void
zigzag
(
int
8_t
index
,
int
8_t
&
ix
,
int
8_t
&
iy
)
{
ix
=
index
%
(
MESH_NUM_X_POINTS
);
iy
=
index
/
(
MESH_NUM_X_POINTS
);
if
(
iy
&
1
)
ix
=
(
MESH_NUM_X_POINTS
-
1
)
-
ix
;
// Zig zag
}
void
set_zigzag_z
(
int
index
,
float
z
)
{
void
set_zigzag_z
(
int
8_t
index
,
float
z
)
{
int
ix
,
iy
;
zigzag
(
index
,
ix
,
iy
);
set_z
(
ix
,
iy
,
z
);
}
int
select_x_index
(
float
x
)
{
int
i
=
1
;
while
(
x
>
get_x
(
i
)
&&
i
<
MESH_NUM_X_POINTS
-
1
)
i
++
;
return
i
-
1
;
int8_t
select_x_index
(
float
x
)
{
for
(
uint8_t
i
=
MESH_NUM_X_POINTS
;
i
--
;)
if
(
fabs
(
x
-
get_x
(
i
))
<=
(
MESH_X_DIST
)
/
2
)
return
i
;
return
-
1
;
}
int
select_y_index
(
float
y
)
{
int
i
=
1
;
while
(
y
>
get_y
(
i
)
&&
i
<
MESH_NUM_Y_POINTS
-
1
)
i
++
;
return
i
-
1
;
int8_t
select_y_index
(
float
y
)
{
for
(
uint8_t
i
=
MESH_NUM_Y_POINTS
;
i
--
;)
if
(
fabs
(
y
-
get_y
(
i
))
<=
(
MESH_Y_DIST
)
/
2
)
return
i
;
return
-
1
;
}
float
calc_z0
(
float
a0
,
float
a1
,
float
z1
,
float
a2
,
float
z2
)
{
...
...
@@ -72,8 +74,9 @@
}
float
get_z
(
float
x0
,
float
y0
)
{
int
x_index
=
select_x_index
(
x0
);
int
y_index
=
select_y_index
(
y0
);
int8_t
x_index
=
select_x_index
(
x0
);
int8_t
y_index
=
select_y_index
(
y0
);
if
(
x_index
<
0
||
y_index
<
0
)
return
z_offset
;
float
z1
=
calc_z0
(
x0
,
get_x
(
x_index
),
z_values
[
y_index
][
x_index
],
get_x
(
x_index
+
1
),
z_values
[
y_index
][
x_index
+
1
]);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment