- /* process angle from laserdiff time */
-#ifdef SPEED_10RPS
- /* timer = 2Mhz */
- a = ((double)laserdiff / (2000000./10.)) * 2. * M_PI;
-#else
- /* timer = 16Mhz */
- a = ((double)laserdiff / (16000000./40.)) * 2. * M_PI;
-#endif
- /* get distance from angle */
- d = LASER_DIST / sin(a/2);
-
- /* scale it between 0 and 511 */
- if (d <= MIN_DIST)
- return 0;
- if (d >= MAX_DIST)
- return 0;
- d -= MIN_DIST;
- d /= (MAX_DIST-MIN_DIST);
- d *= 512;
- frame_dist = (uint16_t)d;
- if (frame_dist >= 512) /* should not happen... */
- return 0;