|
SunSPOT API V2.0 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sun.spot.peripheral.external.ExternalBoard
com.sun.spot.sensorboard.hardware.AtmegaExternalBoard
com.sun.spot.sensorboard.EDemoBoard
public class EDemoBoard
This class manages the SPI interfaces and communications to the reachable parts on the EDemoBoard, namely the Atmega88, the Analog to Digital Converter, and the flash eeprom. ( some of this is done by superclasses ) Meant to be used in a singleton manner, this class reflects all of the functionality of the EDemoBoard to the java library space.
| Field Summary | |
|---|---|
static PinDescriptor |
A0
Analog to Digital convertor input pin, matches silkscreening on the hardware |
static PinDescriptor |
A1
Analog to Digital convertor input pin, matches silkscreening on the hardware |
static PinDescriptor |
A2
Analog to Digital convertor input pin, matches silkscreening on the hardware |
static PinDescriptor |
A3
Analog to Digital convertor input pin, matches silkscreening on the hardware |
static PinDescriptor |
A4
Analog to Digital convertor input pin, matches silkscreening on the hardware |
static PinDescriptor |
A5
Analog to Digital convertor input pin, matches silkscreening on the hardware |
static PinDescriptor |
ACCEL_FULLSCALE
Internal pin used to operate the accelerometer. |
static PinDescriptor |
ACCEL_SELFTEST
Internal pin used to operate the accelerometer. |
static PinDescriptor |
ACCEL_X
Descriptor for X Axis accelerometer reading , this is an internal connection. |
static PinDescriptor |
ACCEL_Y
Descriptor for Y Axis accelerometer reading , this is an internal connection. |
static PinDescriptor |
ACCEL_Z
Descriptor for Z Axis accelerometer reading , this is an internal connection. |
static PinDescriptor |
D0
TTL level general purpose input/output pin, matches silkscreening on the hardware |
static PinDescriptor |
D1
TTL level general purpose input/output pin, matches silkscreening on the hardware |
static PinDescriptor |
D2
TTL level general purpose input/output pin, matches silkscreening on the hardware |
static PinDescriptor |
D3
TTL level general purpose input/output pin, matches silkscreening on the hardware |
static PinDescriptor |
D4
TTL level general purpose input/output pin, matches silkscreening on the hardware |
static PinDescriptor |
H0
High current output pin, matches silkscreening on the hardware |
static PinDescriptor |
H1
High current output pin, matches silkscreening on the hardware |
static PinDescriptor |
H2
High current output pin, matches silkscreening on the hardware |
static PinDescriptor |
H3
High current output pin, matches silkscreening on the hardware |
static PinDescriptor |
LED1
3 Color LED Identifier , matches silkscreening on the hardware |
static PinDescriptor |
LED2
3 Color LED Identifier , matches silkscreening on the hardware |
static PinDescriptor |
LED3
3 Color LED Identifier , matches silkscreening on the hardware |
static PinDescriptor |
LED4
3 Color LED Identifier , matches silkscreening on the hardware |
static PinDescriptor |
LED5
3 Color LED Identifier , matches silkscreening on the hardware |
static PinDescriptor |
LED6
3 Color LED Identifier , matches silkscreening on the hardware |
static PinDescriptor |
LED7
3 Color LED Identifier , matches silkscreening on the hardware |
static PinDescriptor |
LED8
3 Color LED Identifier , matches silkscreening on the hardware |
static PinDescriptor |
LIGHTSENSOR
Descriptor for LightSensor, this is an internal connection. |
static String |
PART_ID
Identifier string for demoboard |
static PinDescriptor |
POWER_ENABLE
|
static int |
SERIAL_SPEED_115200
|
static int |
SERIAL_SPEED_19200
|
static int |
SERIAL_SPEED_2400
|
static int |
SERIAL_SPEED_250000
|
static int |
SERIAL_SPEED_28800
|
static int |
SERIAL_SPEED_38400
|
static int |
SERIAL_SPEED_4800
|
static int |
SERIAL_SPEED_57600
|
static int |
SERIAL_SPEED_9600
|
static PinDescriptor |
SW1
Switch 0, matches silkscreening on the hardware This switch can also be driven by an external switch by using the SW1 pin on the header. |
static PinDescriptor |
SW2
Switch 1, matches silkscreening on the hardware This switch can also be driven by an external switch by using the SW2 pin on the header. |
| Fields inherited from class com.sun.spot.sensorboard.hardware.AtmegaExternalBoard |
|---|
atmega |
| Fields inherited from class com.sun.spot.peripheral.external.ExternalBoard |
|---|
BOARD_MAGIC_WORD, ID_PROPERTY_NAME |
| Fields inherited from interface com.sun.spot.sensorboard.capabilities.ITriColorLEDController |
|---|
BLUE, GREEN, RED |
| Method Summary | |
|---|---|
void |
andRegister(int reg,
int val)
Perform an AND assignment to one of the registers in the Atmega88 controller. |
IInputPin |
bindInputPin(PinDescriptor pidx)
Register the use of and return the accessor object for the indicated input pin. |
IIOPin |
bindIOPin(PinDescriptor pidx)
Register the use of and return the accessor object for the indicated I/O pin. |
ITriColorLED |
bindLED(PinDescriptor pidx)
Returns an accessor object to the indicated 3 color LED. |
ILightSensor |
bindLightSensor(PinDescriptor pidx)
Register the use of and return the accessor object to a lightsensor connected to a scalar input pin. |
IOutputPin |
bindOutputPin(PinDescriptor pidx)
Register the use of and return the accessor object for the indicated output pin. |
IScalarInput |
bindScalarInput(PinDescriptor pidx)
Registers the use of and return the ScalarInput object that reads from the specified ADC pin. |
IServo |
bindServo(PinDescriptor pidx)
Register the pin and return an accessor object to control an attached Servo. |
ISwitch |
bindSwitch(PinDescriptor pidx)
Register the indicated pin as a switch and return the accessor object for it. |
IToneGenerator |
bindToneGenerator(PinDescriptor pidx)
Register and return accessor object for ToneGenerator on indicated pin. |
void |
disablePinChangeInterrupt(PinDescriptor pidx)
Stop a pin generating pin change interrupts |
void |
disableRegistry()
Disable the global pin registry in the EDemoBoard object. |
void |
enablePinChangeInterrupt(PinDescriptor pidx,
boolean lowToHigh,
boolean highToLow)
Allow the input pin specified to generate pin change interrupts. |
void |
error(String txt)
Report an error with regard to the EDemoBoard. |
IAccelerometer3D |
getAccelerometer()
Convenience method to return the built in accelerometer. |
IADT7411 |
getADC()
Convience function to get an object that corresponds to the ADC on the EDemoBoard. |
ITemperatureInput |
getADCTemperature()
Convience Function to get internal temperature sensor on the ADC from the 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 to its flash memory |
static EDemoBoard |
getInstance()
return the global singleton for the EDemoBoard at board select zero |
ITriColorLED |
getLED(PinDescriptor pidx)
Convienence method to bind and return the LED that is reqested. |
ITriColorLED[] |
getLEDs()
Convienence method that returns an array of all the built in LEDs. |
ILightSensor |
getLightSensor()
Convenience function to return lightsensor object. |
int |
getLightSensorValue(PinDescriptor pidx)
Get the current value of a lightsensor accessor connected to a particular pin. |
boolean |
getPinValue(PinDescriptor pidx)
Returns the value of the pin. |
int |
getPulse(PinDescriptor pidx,
int dir)
Ask the controller for a measurement of an incoming pulse on some pin. |
int |
getRegister(int reg)
Peek method for the atmega firmware. |
int |
getScalarValue(PinDescriptor pidx)
Returns a scalar value for indicated pin from the ADC. |
ISwitch |
getSwitch(PinDescriptor pidx)
Register the indicated pin as a switch and return the accessor object for it. |
ISwitch[] |
getSwitches()
Return an array of all the built in switches on the board. |
boolean |
getSwitchState(PinDescriptor pidx)
Get the current state of a switch connected to the indicated pin. |
void |
initUART(int baud,
boolean two_stopbit)
Initialize the UART module, sets the speed and selects number of stop bits |
void |
msg(String txt)
Deliver message to user. |
String |
name()
Returns the name that should be used by the IDriver subsystem. |
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 |
protected void |
setDebugLevel(int x)
Change the verbosity of the EDemoBoard. |
void |
setLEDColorIntensity(PinDescriptor pidx,
int clr,
int val)
Set the RGB values of the indicated LED. |
void |
setLEDValue(PinDescriptor pidx,
int r,
int g,
int b)
Set the RGB values of the indicated LED. |
void |
setPinDirection(PinDescriptor pidx,
boolean output)
Set the mask for the indicated pin to the indicated direction. |
void |
setPinValue(PinDescriptor pidx,
boolean high)
Set the output value of the indicated pin. |
void |
setPWM(PinDescriptor pidx,
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. |
void |
setRegister(int reg,
int val)
Poke method for the Atmega88 controller, allows user to set low level registers on the part. |
void |
setServoPulseWidth(PinDescriptor pidx,
int usec)
Ask the controller to maintain a servo pulsewidth of some length. |
void |
setTone(PinDescriptor pidx,
int period)
Ask the controller to start a tone on the indicated pin. |
void |
setUp()
Perform any tasks necessary for initial setup, and return from hibernation. |
void |
startPulse(PinDescriptor pidx,
int dir,
int usec)
Ask the controller to issue a pulse on the indicated pin. |
boolean |
tearDown()
Perform any tasks necessary for hibernation. |
PinDescriptor[] |
waitForPinChange()
Wait for a pin change interrupt. |
void |
warning(String txt)
Report a warning with regard to the EDemoBoard. |
| Methods inherited from class com.sun.spot.sensorboard.hardware.AtmegaExternalBoard |
|---|
getAtmega, getAtmegaSPI, getProgrammingSPI, setAtmega |
| Methods inherited from class com.sun.spot.peripheral.external.ExternalBoard |
|---|
forceChipSelectPin, getBoardIndex, getProperties, getSerialFlash, hardwareNotValid, isInstalled, newBoardDeviceSPI, setProperties |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int SERIAL_SPEED_9600
public static final int SERIAL_SPEED_19200
public static final int SERIAL_SPEED_28800
public static final int SERIAL_SPEED_38400
public static final int SERIAL_SPEED_57600
public static final int SERIAL_SPEED_115200
public static final int SERIAL_SPEED_250000
public static final int SERIAL_SPEED_2400
public static final int SERIAL_SPEED_4800
public static final String PART_ID
public static final PinDescriptor LED1
public static final PinDescriptor LED2
public static final PinDescriptor LED3
public static final PinDescriptor LED4
public static final PinDescriptor LED5
public static final PinDescriptor LED6
public static final PinDescriptor LED7
public static final PinDescriptor LED8
public static final PinDescriptor A0
public static final PinDescriptor A1
public static final PinDescriptor A2
public static final PinDescriptor A3
public static final PinDescriptor LIGHTSENSOR
public static final PinDescriptor ACCEL_X
public static final PinDescriptor ACCEL_Y
public static final PinDescriptor ACCEL_Z
public static final PinDescriptor H0
public static final PinDescriptor H1
public static final PinDescriptor H2
public static final PinDescriptor H3
public static final PinDescriptor D0
public static final PinDescriptor D1
public static final PinDescriptor D2
public static final PinDescriptor D3
public static final PinDescriptor D4
public static final PinDescriptor SW1
public static final PinDescriptor SW2
public static final PinDescriptor A4
public static final PinDescriptor A5
public static final PinDescriptor ACCEL_SELFTEST
public static final PinDescriptor ACCEL_FULLSCALE
public static final PinDescriptor POWER_ENABLE
| Method Detail |
|---|
public void disableRegistry()
public static EDemoBoard getInstance()
public String name()
name in interface IDriverpublic boolean tearDown()
tearDown in interface IDriverpublic void setUp()
setUp in interface IDriverpublic IADT7411 getADC()
public IScalarInput bindScalarInput(PinDescriptor pidx)
EDemoBoard.A0 EDemoBoard.A1 EDemoBoard.A2 EDemoBoard.A3 EDemoBoard.A4 EDemoBoard.A5
bindScalarInput in interface IADCControllerpidx - the pin you've connected a voltage to
public ITemperatureInput getADCTemperature()
getADCTemperature in interface IDemoBoardpublic int getScalarValue(PinDescriptor pidx)
getScalarValue in interface IADCControllerpidx - pin to probe
public int[] getFirmwareVersion()
public ITriColorLED getLED(PinDescriptor pidx)
Valid PinDescriptor list
EDemoBoard.LED1
EDemoBoard.LED2
EDemoBoard.LED3
EDemoBoard.LED4
EDemoBoard.LED5
EDemoBoard.LED6
EDemoBoard.LED7
EDemoBoard.LED8
pidx - PinDescriptor to the desired LED
public ITriColorLED bindLED(PinDescriptor pidx)
Valid PinDescriptor list
EDemoBoard.LED1
EDemoBoard.LED2
EDemoBoard.LED3
EDemoBoard.LED4
EDemoBoard.LED5
EDemoBoard.LED6
EDemoBoard.LED7
EDemoBoard.LED8
bindLED in interface ITriColorLEDControllerpidx - PinDescriptor to the desired LED
public ITriColorLED[] getLEDs()
getLEDs in interface IDemoBoard
public void setLEDValue(PinDescriptor pidx,
int r,
int g,
int b)
Valid PinDescriptor list
EDemoBoard.LED1
EDemoBoard.LED2
EDemoBoard.LED3
EDemoBoard.LED4
EDemoBoard.LED5
EDemoBoard.LED6
EDemoBoard.LED7
EDemoBoard.LED8
setLEDValue in interface ITriColorLEDControllerpidx - Tri Color LED pinr - value of red segmentg - value of green segmentb - value of blue segment
public void setLEDColorIntensity(PinDescriptor pidx,
int clr,
int val)
Valid PinDescriptor list
EDemoBoard.LED1
EDemoBoard.LED2
EDemoBoard.LED3
EDemoBoard.LED4
EDemoBoard.LED5
EDemoBoard.LED6
EDemoBoard.LED7
EDemoBoard.LED8
setLEDColorIntensity in interface ITriColorLEDControllerpidx - Tri Color LED pinclr - encoded value for color segment see ITriColorLEDControllerval - value to setpublic ISwitch getSwitch(PinDescriptor pidx)
pidx - pin that the switch is connected to
Valid PinDescriptor List
EDemoBoard.SW1 BUILT-IN
EDemoBoard.SW2 BUILT-IN
EDemoBoard.D0
EDemoBoard.D1
EDemoBoard.D2
EDemoBoard.D3
EDemoBoard.D4
EDemoBoard.A0
EDemoBoard.A1
EDemoBoard.A2
EDemoBoard.A3
EDemoBoard.A4
EDemoBoard.A5
public ISwitch bindSwitch(PinDescriptor pidx)
bindSwitch in interface ISwitchControllerpidx - pin that the switch is connected to
Valid PinDescriptor List
EDemoBoard.SW1 BUILT-IN
EDemoBoard.SW2 BUILT-IN
EDemoBoard.D0
EDemoBoard.D1
EDemoBoard.D2
EDemoBoard.D3
EDemoBoard.D4
EDemoBoard.A0
EDemoBoard.A1
EDemoBoard.A2
EDemoBoard.A3
EDemoBoard.A4
EDemoBoard.A5
public ISwitch[] getSwitches()
getSwitches in interface IDemoBoardpublic boolean getSwitchState(PinDescriptor pidx)
getSwitchState in interface ISwitchControllerpidx - pin that switch is connected to
public IOutputPin bindOutputPin(PinDescriptor pidx)
Valid PinDescriptor List
EDemoBoard.D0
EDemoBoard.D1
EDemoBoard.D2
EDemoBoard.D3
EDemoBoard.D4
EDemoBoard.H0
EDemoBoard.H1
EDemoBoard.H2
EDemoBoard.H3
bindOutputPin in interface IGPIOControllerpidx - pin that the output is connected to
public IInputPin bindInputPin(PinDescriptor pidx)
bindInputPin in interface IGPIOControllerpidx - pin that the input is connected to
EDemoBoard.D0 EDemoBoard.D1 EDemoBoard.D2 EDemoBoard.D3 EDemoBoard.D4 EDemoBoard.A0 EDemoBoard.A1 EDemoBoard.A2 EDemoBoard.A3 EDemoBoard.A4 EDemoBoard.A5
public IIOPin bindIOPin(PinDescriptor pidx)
Valid PinDescriptor List
EDemoBoard.D0
EDemoBoard.D1
EDemoBoard.D2
EDemoBoard.D3
EDemoBoard.D4
EDemoBoard.A0
EDemoBoard.A1
EDemoBoard.A2
EDemoBoard.A3
EDemoBoard.A4
EDemoBoard.A5
EDemoBoard.H0 output only
EDemoBoard.H1 output only
EDemoBoard.H2 output only
EDemoBoard.H3 output only
bindIOPin in interface IGPIOControllerpidx - pin that the input/output is connected to
public void setPinValue(PinDescriptor pidx,
boolean high)
setPinValue in interface IGPIOControllerpidx - pin to set the value ofhigh - value to set the pin to, true sets pin to Vddpublic boolean getPinValue(PinDescriptor pidx)
getPinValue in interface IGPIOControllerpidx - pin to get the value of
public void enablePinChangeInterrupt(PinDescriptor pidx,
boolean lowToHigh,
boolean highToLow)
IGPIOControllerIGPIOController.waitForPinChange() to wait for it. Enabling a
pin change interrupt does not inhibit deep sleep.
IMPORTANT: only one isolate at a time can use the pin change interrupt facility.
enablePinChangeInterrupt in interface IGPIOControllerpidx - The pin descriptor of the pinlowToHigh - true if this pin is to generate low-to-high interruptshighToLow - true if this pin is to generate high-to-low interruptspublic void disablePinChangeInterrupt(PinDescriptor pidx)
IGPIOController
disablePinChangeInterrupt in interface IGPIOControllerpidx - The pin descriptor of the pinpublic PinDescriptor[] waitForPinChange()
IGPIOControllerIGPIOController.enablePinChangeInterrupt(PinDescriptor, boolean, boolean)
changes state. Blocking on this call does not inhibit deep sleep. On return the
result array contains the pin descriptor(s) of the pin(s) that changed state.
IMPORTANT: only one isolate at a time can use the pin change interrupt facility.
waitForPinChange in interface IGPIOController
public void setPinDirection(PinDescriptor pidx,
boolean output)
throws IOPinException
setPinDirection in interface IGPIOControllerpidx - pin to be modifiedoutput - true if user wants the pin to be an output
IOPinException - attempt to set pin to illegal directionpublic ILightSensor getLightSensor()
getLightSensor in interface IDemoBoardpublic ILightSensor bindLightSensor(PinDescriptor pidx)
LIGHTSENSOR pin.
EDemoBoard.LIGHTSENSOR EDemoBoard.A0 EDemoBoard.A1 EDemoBoard.A2 EDemoBoard.A3 EDemoBoard.A4 EDemoBoard.A5
bindLightSensor in interface ILightSensorControllerpidx - pin that sensor is bound to
public int getLightSensorValue(PinDescriptor pidx)
getLightSensorValue in interface ILightSensorControllerpidx - pin that the sensor is attached to
public IAccelerometer3D getAccelerometer()
getAccelerometer in interface IDemoBoardpublic IServo bindServo(PinDescriptor pidx)
bindServo in interface IServoControllerpidx - pin servo data pin is attached to
public void setRegister(int reg,
int val)
reg - Register to set value of, use only those defined statically by Atmega[88].javaval - value to set
public void orRegister(int reg,
int val)
reg - register to set value ofval - value to use in operation
public void andRegister(int reg,
int val)
reg - register to set value ofval - value to use in operationpublic int getRegister(int reg)
reg - Register to read value from
public void startPulse(PinDescriptor pidx,
int dir,
int usec)
pidx - pin to issure pulse ondir - direction of desired pulse , 1 = high , 0 = lowusec - length of pulse in micro seconds
public void setServoPulseWidth(PinDescriptor pidx,
int usec)
setServoPulseWidth in interface IServoControllerpidx - pin that the servo is connected tousec - length of servo pulse in micro seconds
public int getPulse(PinDescriptor pidx,
int dir)
pidx - pin to measure pulse ondir - direction of desired pulse
public void setPWM(PinDescriptor pidx,
int duty)
startPulse method.
pidx - pin to intiate PWM onduty - duty cycle out of 255 slices
public void initUART(int baud,
boolean two_stopbit)
baud - baud speed to set module to, supported speeds are 2400,4800,9600,19200,28800,38400 and 57600two_stopbit - set to true if you want the module setup to send 2 stop bitspublic void sendUART(byte val)
val - the value to send over the uart
public byte receiveUART()
throws IOException
IOException - there are no available bytes on the UARTpublic IToneGenerator bindToneGenerator(PinDescriptor pidx)
bindToneGenerator in interface IToneGeneratorControllerpidx - pin to bind ToneGenerator to
public void setTone(PinDescriptor pidx,
int period)
setTone in interface IToneGeneratorControllerpidx - pin to generate tone onperiod - period of the tone generated, this is modified by internal divisors.public static Properties getInitialProperties()
protected void setDebugLevel(int x)
x - desired verbosity settingpublic void error(String txt)
txt - text of error messagepublic void warning(String txt)
txt - Text content of warning message.public void msg(String txt)
txt - Text content of message.
|
SunSPOT API V2.0 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||