sersend.c: Make %d, %ld, %sd print signed values.
dda_lookahead.c: move crossing speed calculation into a dedicated function.

This is mostly a preparation for reverse walks through the movement queue,
where crossing speed calculation is done only once, while actually used
speeds can be raised successively with repeated walks.
look-ahead: change crossing speed calculation algorithm.

The new one solely looks at speed differences of individual axes.
This means individual jerks for each axis (good!) and relative
simple maths (also good!).

For details and maths, see comments in the code and
https://github.com/Traumflug/Teacup_Firmware/issues/45 .
look-ahead: move jerk definitions into config.h templates.
DDA: reduce code duplication and simplify.

There are three locations in the code that repeat a pattern of
"If z=0 then use 2d-approx(dx,dy), else if x==0 && y==0 then use dz,
else use 3d-approx".

Teach approx_distance_3 to detect these conditions for us and apply
the same logic.  Replace the three call locations with a simple call
to approx_distance_3.

Binary size for the LOOKAHEAD case drops by almost 400 bytes:

  old:  FLASH : 21242 bytes          149%       70%        34%       17%
  new:  FLASH : 20844 bytes          146%       68%        33%       17%

The size for non-LOOKAHEAD drops by 40 bytes:

  old:  FLASH : 16592 bytes          116%       55%        27%       13%
  new:  FLASH : 16552 bytes          116%       54%        27%       13%

We can actually do a little better if we consider the zero-ness of all
three axes, but this does make the code a little bit bigger. Another
change will consider that option. This change simply tries to mimic
the existing functionality.
DDA: move dda_find_crossing_speed() to dda.c.

This is a preparation towards going through the existing movement
queue backwards with dda_join_moves() to allow higher feedrates
for lots of short movements.
DDA: use the already calculated distance for crossing speed calculation.
dda_lookahead.c: remember movement distance to avoid recalculation.
dda.c: clear /all/ lookahead variables when starting.

Catched it! :-)

This was causing occasional step losses when a movement with
zero crossF followed a pair with high crossF.
dda.c: describe all lookahead cases in a comment.
DDA: store distance of each movement.

This is required to calculate speeds of individual axes. So far only
in dda_find_crossing_speed(), but soon also in dda_join_moves().
DDA: make a huge comment compact and move it to where it belongs.

Also clarify the acceleration formula.
dda.c: actually reduce endpoint.F for overly fast movement attempts.

This fix was long overdue and is now unavoidable, as the hack with
limiting maximum speed to c_min in dda_clock() conflicts with
lookahead.
dda_lookahead.c: base ramping calculations on the fast axis.

Previously, ramps were calculated with the combined speed,
which can differ from the speed of the fast axis by factor 2.

This solves part 2 of issue #68.
dda.c: base rampup_steps calculation on the fast axis, too.
dda.c: remove the hack for too high rampup steps for lookahead.

Keeping the hack causes the previous move to decelerate, which isn't
intended when movements are joined with lookahead.

Removing only the hack breaks endstop handling on those axes which
set a huuuge number of acceleration steps for the lack of a proper
calculation algorithm. We have this algorithm now, so we can stop
using this kludge.

Solves part 1 of issue #68.
Lookahead: refactored code to compute everything in dda steps.
DDA: remember the fast axis micrometers and save their reconstruction.

No surprise, this saves a whopping 600 bytes.
dda.c: remember steps per m of the fast axis for rampup calculation.

For now this is for the initial rampup calculation, only, notably
for moving the Z axis (which else gets far to few rampup steps on
a typical mendel-like printer).

The used macro was verified with this test code (in mendel.c):

[...]
int main (void) {
  init();

  uint32_t speed, spm;
  char string[128];
  for (spm = 2000; spm < 4099000; spm <<= 1) {
    for (speed = 11; speed < 65536; speed *= 8) {
      sersendf_P(PSTR("spm = %lu  speed %lu ==> macro %lu  "),
                 spm, speed, ACCELERATE_RAMP_LEN_SPM(speed, spm));
      delay_ms(10);
      sprintf(string, "double %f\n",
              (double)speed * (double)speed / ((double)7200000 * (double)ACCELERATION / (double)spm));
      serial_writestr((uint8_t *)string);
      delay_ms(10);
    }
  }
[...]

Note: to link the test code, this linker flag is required to add
      the full printf library (which does print doubles):

  LDFLAGS += -Wl,-u,vfprintf -lprintf_flt -lm
DDA: make macro ACCELERATE_RAMP_LEN_SPM() a function.

This macro is pretty expensive (700 bytes, well, stuff is now
calculated at runtime), so there's no chance to use it in multiple
places and we likely also need this in dda_lookahead.c to achieve
full 4 axis compatibility there.