RoboJDETM v2.0

com.ridgesoft.robotics
Class Compass

java.lang.Object
  extended by com.ridgesoft.robotics.Compass
Direct Known Subclasses:
DevantechCMPS03, DevantechCMPS03I2C

public abstract class Compass
extends Object

Abstract base class for a compass sensor.


Constructor Summary
protected Compass()
          Constructs a Compass.
 
Method Summary
 String direction()
          Gets a String indicating the current compass direction.
static String direction(int heading)
          Converts a compass heading to a String indicating a compass direction.
abstract  int heading()
          Reads the current heading from the compass.
 String toString()
          Returns a String containing the current heading in degrees.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait
 

Constructor Detail

Compass

protected Compass()
Constructs a Compass.

Method Detail

direction

public String direction()
Gets a String indicating the current compass direction.

The returned String will be one of the following: "N", "NE", "E", "SE", "S", "SW", "W", "NW" or "--". The string "--" indicates the heading is not valid.

Returns:
direction string

direction

public static String direction(int heading)
Converts a compass heading to a String indicating a compass direction.

The returned String will be one of the following: "N", "NE", "E", "SE", "S", "SW", "W", "NW" or "--". The string "--" indicates the heading is not valid.

Parameters:
heading - compass heading in degrees (0 - 359)
Returns:
direction string

heading

public abstract int heading()
Reads the current heading from the compass.

Returns:
heading in degrees (0 - 359) or -1 if compass is not providing valid data

toString

public String toString()
Returns a String containing the current heading in degrees.

Overrides:
toString in class Object
Returns:
heading in degrees or "---" if the compass is not providing valid data

RoboJDETM v2.0

Copyright (c) 2003-2009 RidgeSoft, LLC. All rights reserved.
www.ridgesoft.com