This abstract class defines the interface that all sonars must provide. Sonars are assumed to be input pins but may use the IOPin functions to briefly change themselves to output for ping transmission.
The interface implemented by all sonars is:
uint16_t read(); // read the 'raw' value from the sonar. Different makes may return different values for the same distance.
uint16_t read_cm(bool useSmoothing=false); // This will return a value in 'cm' regardless of make. If useSmoothing is true then the driver will attempt to return a 'smoothed out' value in order to prevent any spurious spikes. Each actual driver may choose to ignore this parameter or it may implement it in a different way.
bool isReadyToRead(); // Since a sonar ping can echo around for a while then it is best to wait for a while before taking the next reading so as not to get echos from the previous ping. This method will return 'false' if the last ping is still echoing or if there is any other reason as to why a new 'read' command should not be performed.
At the moment the only concrete class is: Sonar\Devantech\SRF05.hpp
but, by examining its code, then it should be very easy to implement other sonars such as the Ping.