RoboJDETM v2.0

com.ridgesoft.intellibrain
Class IntelliBrainDigitalIO

java.lang.Object
  extended by com.ridgesoft.intellibrain.IntelliBrainPinPort
      extended by com.ridgesoft.intellibrain.IntelliBrainDigitalIO
All Implemented Interfaces:
DigitalInput, DigitalOutput, PulseInput, PulseOutput
Direct Known Subclasses:
IntelliBrainExpDigitalIO

public class IntelliBrainDigitalIO
extends IntelliBrainPinPort
implements PulseInput, PulseOutput

Class representing a single digital input/output port.

The digital ports may be used as digital inputs or digital outputs.

Pulse input measurement is supported on ports 3 through 6.

Pulse output is supported on any digital port, even when configured as an input.

By default the port is configured as a digital input.


Method Summary
 void clear()
          Clears the digital output (sets it low) if the port is configured as an output.
 void enablePulseMeasurement(boolean enable)
          Enables pulse measurement.
 boolean isSet()
          Samples the state of the port's signal pin.
 void pulse(int duration)
          Outputs a pulse to the digital port signal pin.
 void pulse(int duration, boolean highPulse)
          Outputs a pulse to the digital port signal pin.
 int readEdgeCount()
          Gets the count of rising and falling edges detected on this input since pulse measurement was enabled.
 int readPulseDuration()
          Gets the duration of the last high pulse.
 int readPulseDuration(boolean highPulse)
          Gets the duration of the last high or low pulse.
 void set()
          Sets the digital ouput high if the port is configured as an output.
 void setDirection(boolean isOutput)
          Configures the port as an input or output.
 void toggle()
          Toggles the digital output.
 String toString()
          Samples the port and returns the String "true" if the digital is set and "false" if it is clear.
 
Methods inherited from class com.ridgesoft.intellibrain.IntelliBrainPinPort
setPullUp
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait
 

Method Detail

clear

public void clear()
Clears the digital output (sets it low) if the port is configured as an output.

Does nothing if the port is configured as an input.

Specified by:
clear in interface DigitalOutput

enablePulseMeasurement

public void enablePulseMeasurement(boolean enable)
Enables pulse measurement.

Digital IO ports 3 through 6 support pulse measurement.

Specified by:
enablePulseMeasurement in interface PulseInput
Parameters:
enable - true enables pulse measurement, false disables pulse measurement
Throws:
UnsupportedOperationException - if the port does not support pulse measurement

isSet

public boolean isSet()
Samples the state of the port's signal pin.

Specified by:
isSet in interface DigitalInput
Specified by:
isSet in interface DigitalOutput
Overrides:
isSet in class IntelliBrainPinPort
Returns:
true if the pin is high, false if the pin is low

pulse

public void pulse(int duration)
Outputs a pulse to the digital port signal pin.

If the port is configured as an input port it will be reconfigured to an output for the duration of the pulse.

The IntelliBrain robotics controller supports durations up to about 140 milliseconds.

Specified by:
pulse in interface PulseOutput
Parameters:
duration - duration of the pulse in microseconds

pulse

public void pulse(int duration,
                  boolean highPulse)
Outputs a pulse to the digital port signal pin.

If the port is configured as an input port it will be reconfigured to an output for the duration of the pulse.

The IntelliBrain robotics controller supports durations up to about 140 milliseconds.

Parameters:
duration - duration of the pulse in microseconds
highPulse - generates a high pulse if true and a low pulse if false

readEdgeCount

public int readEdgeCount()
Gets the count of rising and falling edges detected on this input since pulse measurement was enabled.

Pulse measurement must be enabled using the enablePulseMeasurement method.

Specified by:
readEdgeCount in interface PulseInput
Returns:
count of rising and falling edges detected on this input since pulse measurement was enabled

readPulseDuration

public int readPulseDuration()
Gets the duration of the last high pulse.

The resolution is about 4 microseconds and the maximum pulse duration is about 250 milliseconds.

The method enablePulseMeasurement must be called prior to calling this method.

Specified by:
readPulseDuration in interface PulseInput
Returns:
duration of last pulse in microseconds, or -1 if a full pulse has not occurred since the last read.

readPulseDuration

public int readPulseDuration(boolean highPulse)
Gets the duration of the last high or low pulse.

The resolution is about 4 microseconds and the maximum pulse duration is about 250 milliseconds.

The method enablePulseMeasurement must be called prior to calling this method.

Specified by:
readPulseDuration in interface PulseInput
Parameters:
highPulse - true to read the duration of the last high pulse, false to read the duration of the last low pulse
Returns:
duration of last pulse in microseconds, or -1 if a full pulse has not occurred since the last read

set

public void set()
Sets the digital ouput high if the port is configured as an output.

Does nothing if the port is configured as an input.

Specified by:
set in interface DigitalOutput

setDirection

public void setDirection(boolean isOutput)
Configures the port as an input or output.

When configuring a port to be an input, its value is cleared.

When configuring a port to be an output, the pull-up resistor is disabled.

By default digital ports are configured as inputs.

Parameters:
isOutput - true if the port is to be configured as an output, false if it is to be configured as an input

toggle

public void toggle()
Toggles the digital output.

Specified by:
toggle in interface DigitalOutput

toString

public String toString()
Samples the port and returns the String "true" if the digital is set and "false" if it is clear.

Overrides:
toString in class Object
Returns:
String object indicating the state of the port

RoboJDETM v2.0

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