|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
cork.module.devantech.SRF04
Software driver for the Devontech SRF04 Range Finder.
in order to improve accuracy, the you may set the air temperature that the
range finder is working in. If you don't set it, it will default to 25
degrees celsius which will be an average comfortable household temperature
for most people.
The ping() method will block for aproximatly 360 milliseconds to allow the
ranger to take 10 reading to the target, this will be used to find the
average variation which was noted to exist during testing of the original
example code from Systronix Inc.
Example of usage:
SRF04Ultrasonic sonar = new SRF04Ultrasonic(0); sonar.setAirTemperature(15); while(true){ sonar.ping(); int range = sonar.getRangeInCentimetres(); ... do something with the range ... }
This class is heavily based on example code provided my Systronix Inc. The original example was written by John Hartogh, with modifications by Bruce Boyes.
Field Summary | |
static double |
AIR_TEMPERATURE_CELSIUS_0
The 0 degrees celsius (C) for speed-of-sound calculations: 0C Water freezes at 0C. |
static double |
AIR_TEMPERATURE_CELSIUS_100
The 100 degrees celsius (C) for speed-of-sound calculations: 0C Water boils at 0C (at sea level). |
static double |
DEFAULT_AIR_TEMPERATURE_CELSIUS
The default air temperature in celsius (C) for speed-of-sound calculations: 25C |
Constructor Summary | |
SRF04(int timerId)
Constructor for the SRF04Ultrasonic object |
Method Summary | |
void |
addResouceDevice(Device device)
Adds another device to this so that device so that this device can use it's resources. |
double |
getAirTemperature()
The speed of sound in air are is effected by many variables, among them is the temperature of the air. |
java.lang.String |
getDeviceDestription()
Gets the destription attribute of the Device object |
java.lang.String |
getDeviceName()
Gets the title attribute of the Device object |
int |
getEchoTimeInMicroseconds()
Gets the round-trip echo time in microseconds attribute of the SRF04 object |
int |
getRangeInCentimetres()
Gets the range from the SRF04 to the target in centimetres (cm). |
int |
getRangeInCentimetres(double temperatureInC)
Gets the range from the SRF04 to the target in centimetres calculated with the termperature supplied. |
int |
getRangeMaximumInCentimetres()
Gets the maximum range measured in centimetres out of 10 pulses. |
int |
getRangeMinimumInCentimetres()
Gets the minimum range measured in centimetres out of 10 pulses. |
double |
getRangeVariationInCentimetres()
Gets the error variation that was observed in centimetres. |
int |
getTimerID()
Gets the Timer ID of the SRF04 object. |
void |
interruptEvent()
Internal use only! The event handler, triggered by the trailing edge of the echo pulse. |
boolean |
isDebugMode()
Gets the debugMode attribute of the ConsoleDebug object |
boolean |
isOutputOnLineA()
Gets the outputOnLineA attribute of the SRF04Ultrasonic object |
boolean |
isOutputOnLineB()
Gets the outputOnLineB attribute of the SRF04Ultrasonic object |
boolean |
isResourceDevice(Device device)
Checks to see if a device has already been bound to this device. |
boolean |
ping()
Use this method to "ping" a target. |
boolean |
pingAndListen()
This method does nothing. |
void |
removeResouceDevice(Device device)
Removes another device from this device so that this device can no longer use it's resources. |
void |
setAirTemperature(double temperature)
The speed of sound in air are is effected by many variables, among them is the temperature of the air. |
void |
setDebugMode(boolean debug)
Sets the debugMode attribute of the ConsoleDebug object. |
void |
setOutputOnLineA()
Sets the outputOnLineA attribute of the SRF04Ultrasonic object |
void |
setOutputOnLineB()
Sets the outputOnLineB attribute of the SRF04Ultrasonic object |
Field Detail |
public static final double DEFAULT_AIR_TEMPERATURE_CELSIUS
public static final double AIR_TEMPERATURE_CELSIUS_0
public static final double AIR_TEMPERATURE_CELSIUS_100
Constructor Detail |
public SRF04(int timerId)
timerId
- The ID of the timer we're going to use [0|1]Method Detail |
public void interruptEvent()
public boolean ping()
public boolean pingAndListen()
public void addResouceDevice(Device device)
device
- the device to add to this device.public void removeResouceDevice(Device device)
device
- the device to remove.public boolean isDebugMode()
public final int getTimerID()
public final double getAirTemperature()
public int getEchoTimeInMicroseconds()
public final int getRangeMaximumInCentimetres()
public final int getRangeMinimumInCentimetres()
public final double getRangeVariationInCentimetres()
public int getRangeInCentimetres()
public int getRangeInCentimetres(double temperatureInC)
temperatureInC
- the temperature of the air in degrees celsius.public final boolean isOutputOnLineB()
public final boolean isOutputOnLineA()
public java.lang.String getDeviceName()
getDeviceName
in interface Device
public java.lang.String getDeviceDestription()
getDeviceDestription
in interface Device
public boolean isResourceDevice(Device device)
device
- The device to check.public final void setAirTemperature(double temperature)
temperature
- The temperature of the air in degrees celsius.public void setDebugMode(boolean debug)
debug
- boolean true the class will print to the console any debug
messages at its discretion, false to turn off the debug messages.public final void setOutputOnLineB()
public final void setOutputOnLineA()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |