SunSPOT API V3.0


com.sun.spot.sensorboard
Class EDemoBoard

java.lang.Object
  extended by com.sun.spot.sensorboard.EDemoBoard
All Implemented Interfaces:
IDemoBoard

public class EDemoBoard
extends Object
implements IDemoBoard

This class reflects all of the functionality of the EDemoBoard to a SPOT application. The old methods bindServo() & bindToneGenerator() have been removed. Please now use "new Servo()" & "new ToneGenerator()" passing in the IOutputPin or IOPin that they should use. This is a facade class. All the real work is done in the EDemoController class.

Author:
Ron Goldman

Field Summary
static int A0
          A0 index for array returned by getScalarInputs()
static int A1
          A1 index for array returned by getScalarInputs()
static int A2
          A2 index for array returned by getScalarInputs()
static int A3
          A3 index for array returned by getScalarInputs()
static int A4
          A4 index for array returned by getScalarInputs()
static int A5
          A5 index for array returned by getScalarInputs()
static int D0
          D0 index for array returned by getIOPins()
static int D1
          D1 index for array returned by getIOPins()
static int D2
          D2 index for array returned by getIOPins()
static int D3
          D3 index for array returned by getIOPins()
static int D4
          D4 index for array returned by getIOPins()
static int H0
          H0 index for array returned by getOutputPins()
static int H1
          H1 index for array returned by getOutputPins()
static int H2
          H2 index for array returned by getOutputPins()
static int H3
          H3 index for array returned by getOutputPins()
static int LED1
          LED1 index for array returned by getLEDs()
static int LED2
          LED2 index for array returned by getLEDs()
static int LED3
          LED3 index for array returned by getLEDs()
static int LED4
          LED4 index for array returned by getLEDs()
static int LED5
          LED5 index for array returned by getLEDs()
static int LED6
          LED6 index for array returned by getLEDs()
static int LED7
          LED7 index for array returned by getLEDs()
static int LED8
          LED8 index for array returned by getLEDs()
static String PART_ID
          Identifier string for demoboard
static int SERIAL_SPEED_1200
           
static int SERIAL_SPEED_19200
           
static int SERIAL_SPEED_2400
           
static int SERIAL_SPEED_28800
           
static int SERIAL_SPEED_38400
           
static int SERIAL_SPEED_4800
           
static int SERIAL_SPEED_9600
           
static int SW1
          SW1 index for array returned by getSwitches()
static int SW2
          SW2 index for array returned by getSwitches()
 
Method Summary
 void andRegister(int reg, int val)
          Perform an AND assignment to one of the registers in the Atmega88 controller.
 IAccelerometer3D getAccelerometer()
          Method to return the built in accelerometer.
 IADT7411 getADC()
          Method to get an object that corresponds to the ADC on the EDemoBoard.
 ITemperatureInput getADCTemperature()
          Method to get internal temperature sensor on the ADC from the EDemoBoard.
 EDemoController getEDemoController()
          Return the underlying controller used by this EDemoBoard.
 int[] getFirmwareVersion()
          Get the major and minor version information from the firmware running on the EDemoBoard.
static Properties getInitialProperties()
          Get the correct set of properties for this board for its flash memory
static EDemoBoard getInstance()
          Return the global singleton for the EDemoBoard.
 IIOPin[] getIOPins()
          Method to return an array of the built in bidirectional digital pins.
 ITriColorLED[] getLEDs()
          Method that returns an array of all the built in LEDs.
 ILightSensor getLightSensor()
          Method to return the built in light sensor object.
 IOutputPin[] getOutputPins()
          Method to return an array of the built in high current output pins.
 Properties getProperties()
          Get the properties of this board.
 int getPulse(IInputPin pin, boolean dir, int timeout)
          Ask the controller for a measurement of an incoming pulse on some input pin.
 int getRegister(int reg)
          Peek method for the atmega firmware.
 IScalarInput[] getScalarInputs()
          Method to return an array of the built in analog input pins.
 ISwitch[] getSwitches()
          Method to return an array of all the built in switches on the board.
 void initUART(int baud, boolean two_stopbit)
          Initialize the UART module, set the speed and select the number of stop bits.
 void orRegister(int reg, int val)
          Perform an OR assignment to one of the registers in the Atmega88 controller.
 byte receiveUART()
          Get the next byte from the UART.
 void sendUART(byte val)
          Send a byte over the UART.
 void setProperties(Properties p)
          Set the properties of this board
 void setPWM(IOutputPin pin, int duty)
          Request the controller maintain a pwm signal on a gpio pin.
 void setRegister(int reg, int val)
          Poke method for the Atmega88 controller, allows user to set low level registers on the part.
 void startPulse(IOutputPin pin, boolean dir, int usec)
          Ask the controller to issue a pulse on the indicated pin.
 int UARTAvailable()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SERIAL_SPEED_1200

public static final int SERIAL_SPEED_1200
See Also:
Constant Field Values

SERIAL_SPEED_2400

public static final int SERIAL_SPEED_2400
See Also:
Constant Field Values

SERIAL_SPEED_4800

public static final int SERIAL_SPEED_4800
See Also:
Constant Field Values

SERIAL_SPEED_9600

public static final int SERIAL_SPEED_9600
See Also:
Constant Field Values

SERIAL_SPEED_19200

public static final int SERIAL_SPEED_19200
See Also:
Constant Field Values

SERIAL_SPEED_28800

public static final int SERIAL_SPEED_28800
See Also:
Constant Field Values

SERIAL_SPEED_38400

public static final int SERIAL_SPEED_38400
See Also:
Constant Field Values

SW1

public static final int SW1
SW1 index for array returned by getSwitches()

See Also:
Constant Field Values

SW2

public static final int SW2
SW2 index for array returned by getSwitches()

See Also:
Constant Field Values

D0

public static final int D0
D0 index for array returned by getIOPins()

See Also:
Constant Field Values

D1

public static final int D1
D1 index for array returned by getIOPins()

See Also:
Constant Field Values

D2

public static final int D2
D2 index for array returned by getIOPins()

See Also:
Constant Field Values

D3

public static final int D3
D3 index for array returned by getIOPins()

See Also:
Constant Field Values

D4

public static final int D4
D4 index for array returned by getIOPins()

See Also:
Constant Field Values

H0

public static final int H0
H0 index for array returned by getOutputPins()

See Also:
Constant Field Values

H1

public static final int H1
H1 index for array returned by getOutputPins()

See Also:
Constant Field Values

H2

public static final int H2
H2 index for array returned by getOutputPins()

See Also:
Constant Field Values

H3

public static final int H3
H3 index for array returned by getOutputPins()

See Also:
Constant Field Values

A0

public static final int A0
A0 index for array returned by getScalarInputs()

See Also:
Constant Field Values

A1

public static final int A1
A1 index for array returned by getScalarInputs()

See Also:
Constant Field Values

A2

public static final int A2
A2 index for array returned by getScalarInputs()

See Also:
Constant Field Values

A3

public static final int A3
A3 index for array returned by getScalarInputs()

See Also:
Constant Field Values

A4

public static final int A4
A4 index for array returned by getScalarInputs()

See Also:
Constant Field Values

A5

public static final int A5
A5 index for array returned by getScalarInputs()

See Also:
Constant Field Values

LED1

public static final int LED1
LED1 index for array returned by getLEDs()

See Also:
Constant Field Values

LED2

public static final int LED2
LED2 index for array returned by getLEDs()

See Also:
Constant Field Values

LED3

public static final int LED3
LED3 index for array returned by getLEDs()

See Also:
Constant Field Values

LED4

public static final int LED4
LED4 index for array returned by getLEDs()

See Also:
Constant Field Values

LED5

public static final int LED5
LED5 index for array returned by getLEDs()

See Also:
Constant Field Values

LED6

public static final int LED6
LED6 index for array returned by getLEDs()

See Also:
Constant Field Values

LED7

public static final int LED7
LED7 index for array returned by getLEDs()

See Also:
Constant Field Values

LED8

public static final int LED8
LED8 index for array returned by getLEDs()

See Also:
Constant Field Values

PART_ID

public static final String PART_ID
Identifier string for demoboard

See Also:
Constant Field Values
Method Detail

getInstance

public static EDemoBoard getInstance()
Return the global singleton for the EDemoBoard.

Returns:
the singleton instance of EDemoBoard.

getEDemoController

public EDemoController getEDemoController()
Return the underlying controller used by this EDemoBoard.

Returns:
the underlying controller

getADC

public IADT7411 getADC()
Method to get an object that corresponds to the ADC on the EDemoBoard.

Returns:
a-to-d converter

getADCTemperature

public ITemperatureInput getADCTemperature()
Method to get internal temperature sensor on the ADC from the EDemoBoard.

Specified by:
getADCTemperature in interface IDemoBoard
Returns:
accessor object for ADC internal temperature sensor

getLEDs

public ITriColorLED[] getLEDs()
Method that returns an array of all the built in LEDs. Note that this is only those that are actually built into the edemo board

Specified by:
getLEDs in interface IDemoBoard
Returns:
ITriColorLED array that can control all built in LEDs

getSwitches

public ISwitch[] getSwitches()
Method to return an array of all the built in switches on the board. Note this is only the switches, SW1 & SW2, that are built into the edemo board

Specified by:
getSwitches in interface IDemoBoard
Returns:
An ISwitch array of all built in switches

getLightSensor

public ILightSensor getLightSensor()
Method to return the built in light sensor object.

Specified by:
getLightSensor in interface IDemoBoard
Returns:
accessor object to built in light sensor

getAccelerometer

public IAccelerometer3D getAccelerometer()
Method to return the built in accelerometer.

Specified by:
getAccelerometer in interface IDemoBoard
Returns:
valid IAccelerometer3D accessor object

getIOPins

public IIOPin[] getIOPins()
Method to return an array of the built in bidirectional digital pins. Note this is only the bidirectional digital pins, D0-D4, that are built into the edemo board

Specified by:
getIOPins in interface IDemoBoard
Returns:
IIOPin array of all built in bidirectional digital pins

getOutputPins

public IOutputPin[] getOutputPins()
Method to return an array of the built in high current output pins. Note this is only the high current output pins, H0-H3, that are built into the edemo board

Specified by:
getOutputPins in interface IDemoBoard
Returns:
IOutputPin array of all built in high current output pins

getScalarInputs

public IScalarInput[] getScalarInputs()
Method to return an array of the built in analog input pins. Note this is only the analog input pins, A0-A5, that are built into the edemo board

Specified by:
getScalarInputs in interface IDemoBoard
Returns:
IScalarInput array of all built in analog input pins

setPWM

public void setPWM(IOutputPin pin,
                   int duty)
Request the controller maintain a pwm signal on a gpio pin. Set the duty to 0, to turn off an existing pwm signal. The control of this pulse generation is coarser then that available using the startPulse method. Note: that the pwm signal will stop during deep sleep and resume when deep sleep is over.

Parameters:
pin - output pin to send PWM signal to
duty - duty cycle out of 255 slices

startPulse

public void startPulse(IOutputPin pin,
                       boolean dir,
                       int usec)
Ask the controller to issue a pulse on the indicated pin. The pulse is accurate in terms of microseconds but the start time of the pulse may be affected by a bit of latency. Only one pulse may be active at a time. Minimum pulse length is about 25usec.

Parameters:
pin - output pin to issue pulse on
dir - direction of desired pulse: true = high, false = low
usec - length of pulse in microseconds [1:65535]

getPulse

public int getPulse(IInputPin pin,
                    boolean dir,
                    int timeout)
Ask the controller for a measurement of an incoming pulse on some input pin. The pulse width can range from 25usec to 65536usec. Pulses longer than 65536usec will be recorded as 65536usec. Timing will begin at the edge of the pulse in the indicated direction and timing will stop when the opposing edge is seen. If timing is not started in time for first edge, the next pulse will be the one measured. Only one pulse measurement may be active at one time. Calling getPulse() again while a previous call was still pending will terminate the old call and may introduce additional latency before checking for the initial edge begins.

Parameters:
pin - input pin to measure pulse on
dir - direction of desired pulse: true = high, false = low
timeout - how many milliseconds to wait for start of pulse (set to 0 for no timeout)
Returns:
length of measured pulse in microseconds or zero if no pulse seen before timeout

initUART

public void initUART(int baud,
                     boolean two_stopbit)
Initialize the UART module, set the speed and select the number of stop bits.

Parameters:
baud - baud speed to set module to, supported speeds are 2400, 4800, 9600, 19200, 28800, 38400 and 57600
two_stopbit - set to true if you want the module setup to send 2 stop bits

sendUART

public void sendUART(byte val)
Send a byte over the UART.

Parameters:
val - the value to send over the uart

receiveUART

public byte receiveUART()
                 throws IOException
Get the next byte from the UART.

Returns:
the next currently available byte
Throws:
IOException - there are no available bytes on the UART

UARTAvailable

public int UARTAvailable()
Returns:
number of bytes available in the UART buffer

getInitialProperties

public static Properties getInitialProperties()
Get the correct set of properties for this board for its flash memory

Returns:
Properties object as intialized by part.

getProperties

public Properties getProperties()
Get the properties of this board.

Returns:
The properties which will be empty if unable to read them

setProperties

public void setProperties(Properties p)
                   throws IOException
Set the properties of this board

Parameters:
p - The properties to set.
Throws:
IOException

getFirmwareVersion

public int[] getFirmwareVersion()
Get the major and minor version information from the firmware running on the EDemoBoard. The array will have the major revision at position 0 and minor revision at position 1.

Returns:
major and minor version information

setRegister

public void setRegister(int reg,
                        int val)
Poke method for the Atmega88 controller, allows user to set low level registers on the part. Note that this is a dangerous thing to do, you can in fact change something that is unrecoverable. You should only use these functions if you know what you are doing, and you should not use register values that are not defined in Atmega.java

Parameters:
reg - Register to set value of, use only those defined statically by Atmega[88].java
val - value to set

orRegister

public void orRegister(int reg,
                       int val)
Perform an OR assignment to one of the registers in the Atmega88 controller. This method will result in a '|=' of the value passed in with the current value in the register. Note that this is a dangerous thing to do, you can in fact change something that is unrecoverable. You should only use these functions if you know what you are doing, and you should not use register values that are not defined in Atmega.java

Parameters:
reg - register to set value of
val - value to use in operation

andRegister

public void andRegister(int reg,
                        int val)
Perform an AND assignment to one of the registers in the Atmega88 controller. This method will result in a '&=' of the value passed in with the current value in the register. Note that this is a dangerous thing to do, you can in fact change something that is unrecoverable. You should only use these functions if you know what you are doing, and you should not use register values that are not defined in Atmega.java

Parameters:
reg - register to set value of
val - value to use in operation

getRegister

public int getRegister(int reg)
Peek method for the atmega firmware. This method allows for reading values straight out of the low level control registers on the microcontroller. Use only the register values as defined statically in the Atmega.java and Atmega88.java files.

Parameters:
reg - Register to read value from
Returns:
current register value

SunSPOT API V3.0


Copyright © 2006, 2007 Sun Microsystems, Inc. All Rights Reserved.