CoreXY, dda.c: calculate delta steps separately.

This will allow us to use it's sign to set direction.

No binary size increase, optimizer can handle this.
This commit is contained in:
Markus Hitter 2014-10-16 21:04:34 +02:00
parent 41bf99c1aa
commit 12f01a783a
1 changed files with 8 additions and 2 deletions

10
dda.c
View File

@ -190,10 +190,13 @@ void dda_create(DDA *dda, TARGET *target) {
#endif #endif
for (i = X; i < E; i++) { for (i = X; i < E; i++) {
int32_t delta_steps;
delta_um[i] = (uint32_t)abs32(target->axis[i] - startpoint.axis[i]); delta_um[i] = (uint32_t)abs32(target->axis[i] - startpoint.axis[i]);
steps[i] = um_to_steps(target->axis[i], i); steps[i] = um_to_steps(target->axis[i], i);
dda->delta[i] = (uint32_t)abs32(steps[i] - startpoint_steps.axis[i]); delta_steps = steps[i] - startpoint_steps.axis[i];
dda->delta[i] = (uint32_t)abs32(delta_steps);
startpoint_steps.axis[i] = steps[i]; startpoint_steps.axis[i] = steps[i];
set_direction(dda, i, (target->axis[i] >= startpoint.axis[i])?1:0); set_direction(dda, i, (target->axis[i] >= startpoint.axis[i])?1:0);
@ -208,10 +211,13 @@ void dda_create(DDA *dda, TARGET *target) {
} }
if ( ! target->e_relative) { if ( ! target->e_relative) {
int32_t delta_steps;
delta_um[E] = (uint32_t)abs32(target->axis[E] - startpoint.axis[E]); delta_um[E] = (uint32_t)abs32(target->axis[E] - startpoint.axis[E]);
steps[E] = um_to_steps(target->axis[E], E); steps[E] = um_to_steps(target->axis[E], E);
dda->delta[E] = (uint32_t)abs32(steps[E] - startpoint_steps.axis[E]); delta_steps = steps[E] - startpoint_steps.axis[E];
dda->delta[E] = (uint32_t)abs32(delta_steps);
startpoint_steps.axis[E] = steps[E]; startpoint_steps.axis[E] = steps[E];
set_direction(dda, E, (target->axis[E] >= startpoint.axis[E]) ? 1 : 0); set_direction(dda, E, (target->axis[E] >= startpoint.axis[E]) ? 1 : 0);