|
SunSPOT API V3.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.sun.spot.peripheral.external.ExternalBoard com.sun.spot.sensorboard.hardware.AtmegaExternalBoard com.sun.spot.sensorboard.EDemoController
public class EDemoController
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 ) Controller interfaces use a model of interaction that allows for behaviours of the controlled functionality to be modified by implementing the accessor interfaces. The end user is meant to request on of these accessor objects and then use their methods to interact with the Controller. The implementor of the Controller should also be responsible for implementing the accessor object as these concrete classes are assumed to be tightly bound. At the same time it is possible to call the methods that actually implement the low level behaviour in the controller, this is generally disuaded, however there are circumstances where the user may want to bypass the sanity checking in order to reduce the latency as much as possible. Note: whenever a servo is active, deep sleep will not happen.
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
Tri-color LED Identifier, matches silkscreening on the hardware |
static PinDescriptor |
LED2
Tri-color LED Identifier, matches silkscreening on the hardware |
static PinDescriptor |
LED3
Tri-color LED Identifier, matches silkscreening on the hardware |
static PinDescriptor |
LED4
Tri-color LED Identifier, matches silkscreening on the hardware |
static PinDescriptor |
LED5
Tri-color LED Identifier, matches silkscreening on the hardware |
static PinDescriptor |
LED6
Tri-color LED Identifier, matches silkscreening on the hardware |
static PinDescriptor |
LED7
Tri-color LED Identifier, matches silkscreening on the hardware |
static PinDescriptor |
LED8
Tri-color LED Identifier, matches silkscreening on the hardware |
static PinDescriptor |
LIGHTSENSOR
Descriptor for LightSensor, this is an internal connection. |
static PinDescriptor |
POWER_ENABLE
Internal pin used to enable the op-amp and shift registers that drive the LEDs. |
static PinDescriptor |
SW1
Switch 0, matches silkscreening on the hardware. |
static PinDescriptor |
SW2
Switch 1, matches silkscreening on the hardware. |
static PinDescriptor |
TEMPERATURE
Descriptor for internal thermometer reading, this is internal to the ADC chip---a virtual pin. |
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 |
Method Summary | |
---|---|
void |
accelerometerScaleChanged(int newScale)
Called by accelerometer when it changes its scale. |
void |
andRegister(int reg,
int val)
Perform an AND assignment to one of the registers in the Atmega88 controller. |
boolean |
areThresholdEventsEnabled(IScalarInput pin)
Return whether threshold events are enabled or disabled. |
void |
disablePinChangeInterrupts(IInputPin pin)
Stop a pin generating pin change interrupts. |
void |
enablePinChangeInterrupts(IInputPin pin)
Allow the input pin specified to generate pin change interrupts. |
void |
enableThresholdEvents(IScalarInput pin,
boolean enable)
Enable or disable threshold events. |
static void |
error(String txt)
Report an error with regard to the EDemoBoard. |
IAccelerometer3D |
getAccelerometer()
Convenience method to return the built in accelerometer. |
IADT7411 |
getADC()
Convenience function to get an object that corresponds to the ADC on the EDemoBoard. |
ITemperatureInput |
getADCTemperature()
Get the internal temperature sensor on the ADC on the EDemoBoard. |
int |
getBlueLEDValue(PinDescriptor pidx)
Get the current blue color value for the indicated LED This method is meant to be used by an accessor object to the ITriColorLEDController. |
String |
getDriverName()
Returns the name that should be used by the IDriver subsystem. |
int[] |
getFirmwareVersion()
Get the major and minor version information from the firmware running on the EDemoBoard. |
int |
getGreenLEDValue(PinDescriptor pidx)
Get the current green color value for the indicated LED This method is meant to be used by an accessor object to the ITriColorLEDController. |
int |
getHighThreshold(IScalarInput pin)
Return the current high threshold value. |
IIOPin[] |
getIOPins()
Method to return an array of the builtin bidirectional digital pins. |
ITriColorLED[] |
getLEDs()
Convienence method that returns an array of all the built in LEDs. |
ILightSensor |
getLightSensor()
Return light sensor object. |
int |
getLightSensorValue(PinDescriptor pidx)
Get the current value of a lightsensor accessor connected to a particular pin. |
int |
getLowThreshold(IScalarInput pin)
Return the current low threshold value. |
IOutputPin[] |
getOutputPins()
Method to return an array of the builtin high current output pins. |
boolean |
getPinDirection(PinDescriptor pidx)
Get the current direction for the specified input/output pin. |
boolean |
getPinValue(PinDescriptor pidx)
Returns the value of the pin. |
int |
getPulse(PinDescriptor pidx,
boolean dir,
int timeout)
Ask the controller for a measurement of an incoming pulse on some input pin. |
int |
getRedLEDValue(PinDescriptor pidx)
Get the current red color value for the indicated LED This method is meant to be used by an accessor object to the ITriColorLEDController. |
int |
getRegister(int reg)
Peek method for the atmega firmware. |
IScalarInput[] |
getScalarInputs()
Method to return an array of the builtin analog input pins. |
int |
getScalarValue(PinDescriptor pidx)
Returns a scalar value for indicated pin from the ADC. |
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 |
handleLifecycleListenerEvent(Isolate iso,
int eventKind)
This method will be called when the lifecycle event occurs on the isolate that this listener was registered for using addLifecycleListener . |
void |
initUART(int baud,
boolean two_stopbit)
Initialize the UART module, set the speed and select the number of stop bits. |
boolean |
isOnLED(PinDescriptor pidx)
Return if the LED is on or off. |
static void |
main(String[] args)
Called by Spot class when master isolate is started up. |
static void |
msg(String txt)
Deliver message to user. |
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 |
setLEDValue(PinDescriptor pidx,
int r,
int g,
int b)
Set the RGB values of the indicated LED. |
void |
setOnLED(PinDescriptor pidx,
boolean on)
Turn the LED on or off |
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. |
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 |
setThresholdValues(IScalarInput ipin,
int low,
int high)
Set the low and high threshold values for this scalar input. |
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 |
shutDown()
Notify the driver that the VM is about to exit. |
void |
startPulse(PinDescriptor pidx,
boolean dir,
int usec)
Ask the controller to issue a pulse on the indicated pin. |
boolean |
supportsThresholdEvents(PinDescriptor pidx)
Returns whether the underlying hardware supports threshold events. |
boolean |
tearDown()
Record interrupt state so it can be restored later. |
int |
UARTAvailable()
|
static 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 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 TEMPERATURE
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 static void main(String[] args)
args
- ignoredpublic void enablePinChangeInterrupts(IInputPin pin)
synchronized(pin.getIndex()) { pin.getIndex().wait(); }to wait for it. Enabling a pin change interrupt does not inhibit deep sleep. Note: only the master isolate actually interacts with the hardware. Any child isolates send a request to enable interrupts to the master isolate. Upon an interrupt the master isolate will send a message to the child isolate.
enablePinChangeInterrupts
in interface IGPIOController
pin
- the input pinpublic void disablePinChangeInterrupts(IInputPin pin)
disablePinChangeInterrupts
in interface IGPIOController
pin
- the input pinpublic void handleLifecycleListenerEvent(Isolate iso, int eventKind)
Isolate.LifecycleListener
addLifecycleListener
.
handleLifecycleListenerEvent
in interface Isolate.LifecycleListener
iso
- the isolate that had the lifecycle eventeventKind
- the lifecycle event that occurred.
One of Isolate.SHUTDOWN_EVENT_MASK
, Isolate.HIBERNATE_EVENT_MASK
, or Isolate.UNHIBERNATE_EVENT_MASK
Isolate.addLifecycleListener(com.sun.squawk.Isolate.LifecycleListener, int)
,
Isolate.exit(int)
,
Isolate.hibernate()
,
Isolate.unhibernate()
public String getDriverName()
getDriverName
in interface IDriver
public boolean tearDown()
tearDown
in interface IDriver
public void shutDown()
IDriver
shutDown
in interface IDriver
public void setUp()
setUp
in interface IDriver
public int[] getFirmwareVersion()
public IADT7411 getADC()
public ITemperatureInput getADCTemperature()
public IScalarInput[] getScalarInputs()
public int getScalarValue(PinDescriptor pidx)
getScalarValue
in interface IADCController
pidx
- pin to probe
public boolean supportsThresholdEvents(PinDescriptor pidx)
supportsThresholdEvents
in interface IADCController
public void setThresholdValues(IScalarInput ipin, int low, int high)
setThresholdValues
in interface IADCController
ipin
- pin to be readlow
- the new low threshold value.high
- the new high threshold value.public int getLowThreshold(IScalarInput pin)
getLowThreshold
in interface IADCController
pin
- pin to be read
public int getHighThreshold(IScalarInput pin)
getHighThreshold
in interface IADCController
pin
- pin to be read
public void enableThresholdEvents(IScalarInput pin, boolean enable)
enableThresholdEvents
in interface IADCController
pin
- the pin to be readenable
- if true then listeners will be notified if the scalar input
reading goes above the high threshold or below the low threshold.public boolean areThresholdEventsEnabled(IScalarInput pin)
areThresholdEventsEnabled
in interface IADCController
pin
- pin to be read
public ILightSensor getLightSensor()
public int getLightSensorValue(PinDescriptor pidx)
getLightSensorValue
in interface ILightSensorController
pidx
- pin that the sensor is attached to
public ITriColorLED[] getLEDs()
public void setOnLED(PinDescriptor pidx, boolean on)
setOnLED
in interface ITriColorLEDController
pidx
- desired LED descriptoron
- turn LED on if truepublic boolean isOnLED(PinDescriptor pidx)
isOnLED
in interface ITriColorLEDController
pidx
- desired LED descriptor
public void setLEDValue(PinDescriptor pidx, int r, int g, int b)
setLEDValue
in interface ITriColorLEDController
pidx
- Tri Color LED pinr
- value of red segmentg
- value of green segmentb
- value of blue segmentpublic int getRedLEDValue(PinDescriptor pidx)
getRedLEDValue
in interface ITriColorLEDController
pidx
- desired LED descriptor
public int getGreenLEDValue(PinDescriptor pidx)
getGreenLEDValue
in interface ITriColorLEDController
pidx
- desired LED descriptor
public int getBlueLEDValue(PinDescriptor pidx)
getBlueLEDValue
in interface ITriColorLEDController
pidx
- desired LED descriptor
public ISwitch[] getSwitches()
public boolean getSwitchState(PinDescriptor pidx)
getSwitchState
in interface ISwitchController
pidx
- pin that switch is connected to
public IIOPin[] getIOPins()
public IOutputPin[] getOutputPins()
public void setPinValue(PinDescriptor pidx, boolean high)
setPinValue
in interface IGPIOController
pidx
- pin to set the value ofhigh
- value to set the pin to, true sets pin to Vddpublic boolean getPinValue(PinDescriptor pidx)
getPinValue
in interface IGPIOController
pidx
- pin to get the value of
public void setPinDirection(PinDescriptor pidx, boolean output) throws IOPinException
setPinDirection
in interface IGPIOController
pidx
- pin to be modifiedoutput
- true if user wants the pin to be an output
IOPinException
- attempt to set pin to illegal directionpublic boolean getPinDirection(PinDescriptor pidx)
getPinDirection
in interface IGPIOController
pidx
- pin to be modified
public void startPulse(PinDescriptor pidx, boolean dir, int usec)
pidx
- pin to issure pulse ondir
- direction of desired pulse, true = high, false = lowusec
- length of pulse in microseconds [1:65535]public int getPulse(PinDescriptor pidx, boolean dir, int timeout)
pidx
- pin to measure pulse ondir
- direction of desired pulse, true = high, false = lowtimeout
- how many milliseconds to wait for start of pulse (set to 0 for no timeout)
public IAccelerometer3D getAccelerometer()
public void accelerometerScaleChanged(int newScale)
newScale
- the new scalepublic void setServoPulseWidth(PinDescriptor pidx, int usec)
setServoPulseWidth
in interface IServoController
pidx
- pin that the servo is connected tousec
- length of servo pulse in micro secondspublic void setPWM(PinDescriptor pidx, int duty)
startPulse
method.
Note: that the pwm signal will stop during deep sleep and resume
when deep sleep is over.
pidx
- pin to intiate PWM onduty
- duty cycle out of 255 slicespublic void setTone(PinDescriptor pidx, int period)
setTone
in interface IToneGeneratorController
pidx
- pin to generate tone onperiod
- period of the tone generated, this is modified by internal divisors.public void setRegister(int reg, int val)
reg
- Register to set value of, use only those defined statically by Atmega[88].javaval
- value to setpublic void orRegister(int reg, int val)
reg
- register to set value ofval
- value to use in operationpublic 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 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 uartpublic int UARTAvailable()
public byte receiveUART() throws IOException
IOException
- there are no available bytes on the UARTprotected void setDebugLevel(int x)
x
- desired verbosity settingpublic static void error(String txt)
txt
- text of error messagepublic static void warning(String txt)
txt
- Text content of warning message.public static void msg(String txt)
txt
- Text content of message.
|
SunSPOT API V3.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |