// // FILE: sonar.h // programmer: Dave Hershberger // purpose: sonar interface object for Clem // date started: 1-9-96 #ifndef SONAR_H #define SONAR_H #include "timer.h" // TICKS_PER_SONAR_FIRE is the number of timer ticks between sonar firings. // the value of 8 here should give 35-40 ms. #define TICKS_PER_SONAR_FIRE 8 #define NUM_ULTRASONICS 24 class Sonar { protected: static Sonar *me; static int new_values_available; static float latest_values[NUM_ULTRASONICS]; static int pattern_index; static int firing_on; static long int pattern[8]; friend void sonar_timer_callback(double elapsed_time); public: Sonar(); virtual void start(); // initialize and start ultrasonics firing virtual int new_data_available() { return new_values_available; } virtual void read(float *data); // read ultrasonic values virtual void stop(); // stop ultrasonic firing and shut them down }; #endif // SONAR_H