This repository has been archived by the owner on Aug 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 199
/
dda_kinematics.c
56 lines (45 loc) · 1.86 KB
/
dda_kinematics.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include "dda_kinematics.h"
/** \file G-code axis system to stepper motor axis system conversion.
*/
#include <stdlib.h>
#include "dda_maths.h"
#include "bed_leveling.h"
void
carthesian_to_carthesian(const TARGET *startpoint, const TARGET *target,
axes_uint32_t delta_um, axes_int32_t steps) {
delta_um[X] = (uint32_t)labs(target->axis[X] - startpoint->axis[X]);
delta_um[Y] = (uint32_t)labs(target->axis[Y] - startpoint->axis[Y]);
delta_um[Z] = (uint32_t)labs(target->axis[Z] - startpoint->axis[Z]);
axes_um_to_steps_cartesian(target->axis, steps);
}
void
carthesian_to_corexy(const TARGET *startpoint, const TARGET *target,
axes_uint32_t delta_um, axes_int32_t steps) {
delta_um[X] = (uint32_t)labs((target->axis[X] - startpoint->axis[X]) +
(target->axis[Y] - startpoint->axis[Y]));
delta_um[Y] = (uint32_t)labs((target->axis[X] - startpoint->axis[X]) -
(target->axis[Y] - startpoint->axis[Y]));
delta_um[Z] = (uint32_t)labs(target->axis[Z] - startpoint->axis[Z]);
axes_um_to_steps_corexy(target->axis, steps);
}
void axes_um_to_steps_cartesian(const axes_int32_t um, axes_int32_t steps) {
steps[X] = um_to_steps(um[X], X);
steps[Y] = um_to_steps(um[Y], Y);
steps[Z] = um_to_steps(um[Z] + bed_level_offset(um), Z);
}
void axes_um_to_steps_corexy(const axes_int32_t um, axes_int32_t steps) {
steps[X] = um_to_steps(um[X] + um[Y], X);
steps[Y] = um_to_steps(um[X] - um[Y], Y);
steps[Z] = um_to_steps(um[Z] + bed_level_offset(um), Z);
}
void delta_to_axes_cartesian(axes_int32_t delta) {
// nothing to do for cartesian
}
void delta_to_axes_corexy(axes_int32_t delta) {
// recalculate only dedicated axes
int32_t x_axis, y_axis;
x_axis = (delta[X] + delta[Y]) / 2;
y_axis = (delta[X] - delta[Y]) / 2;
delta[X] = x_axis;
delta[Y] = y_axis;
}