* train <trainpn> step <step>=<speed> <upwait>/<downwait>
* seg <segpn> has [-]<ownerpn>|$
* seg <segpn> at <movposcomb>
+ *
+ * speed is in um/s, upwait and downwait are in us
*/
#include <sys/mman.h>
curvebufsz++;
new->step= step;
- new->speed= speed;
- new->upwait= upw;
- new->downwait= downw;
+ new->speed= speed * 1e-6 * SPEED_UNIT;
+ new->upwait= upw * 1e-3;
+ new->downwait= downw * 1e-3;
}
static int speedcurveentry_compare(const void *av, const void *bv) {
* Distances are in mm.
* Times are in ms.
* Speeds are in fixed point: unit is 1/SPEED_UNIT m/s
+ *
+ * To calculate with speeds and times without using floating point
+ * it turns out that we can cope with distances of up to
+ * 2^(31-SPEED_SHIFT) mm
*/
-#define SPEED_SHIFT 7
+#define SPEED_SHIFT 16 /* units of 15um/s, max distance 2^15mm =~ 32m */
#define SPEED_UNIT (1L<<SPEED_SHIFT) /* ms/mm */
/*========== state of the layout ==========*/