General
The front-ending provided by the compass package is basically represented by the singleton class InputOutputHandler in combination with the
interface CompassListener and the class CompassBoardReply that represents the actual data and provides methods for extracting it.
InputOutputHandler can be instantiated through the methods getInstance(int) and getInstance(File, boolean).
The package offers three sub-classes of InputOutputHandler of which instances are generated depending on which getInstance
method is used and what arguments are specified. The sub classes are:
- SerialPortInputOutputHandler: reads data from a serial port.
This class is instantiated when getInstance(int) is called. - SerialFileInputOutputHandler: reads data from a linux device (e.g. dev/ttyUSB0).
This class is instantiated when getInstance(File, boolean) is called, where the boolean argument is false. - FileInputOutputHandler: reads data from a file (mainly for testing purposes).
This class is instantiated when getInstance(File, boolean) is called where the boolean argument is true.
Finally, a CompassListener object can be added to the InputOutputHandler by using the method
addCompassListener(CompassListener).
The CompassListener object offers a method handleCompassBoardReply(CompassBoardReply) that is called everytime a data block is received from the compass.
As already mentioned above, the data is stored in objects of the type CompassBoardReply.
The container class CompassBoardReply offers several methods with which the data can be extracted. The methods are as following:
- getDirectionDegrees() : int
- getDirectionMinutes() : int
- getTemperatureDegreesCelsius() : float
- getTemperatureDegreesFahrenheit() : float
- getInclinationX() : int
- getInclinationY() : int
- getBatteryStatus() : int
- getCalibrationStatus() : int
- dump() : String
Additional information is provided by the corresponding javadoc.