SunSPOT API V2.0


com.sun.spot.sensorboard
Class EDemoBoard

java.lang.Object
  extended by com.sun.spot.peripheral.external.ExternalBoard
      extended by com.sun.spot.sensorboard.hardware.AtmegaExternalBoard
          extended by com.sun.spot.sensorboard.EDemoBoard
All Implemented Interfaces:
IExternalBoard, IDriver, IADCController, IGPIOController, ILightSensorController, IServoController, ISwitchController, IToneGeneratorController, ITriColorLEDController, IDemoBoard

public class EDemoBoard
extends AtmegaExternalBoard
implements IDemoBoard

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.

Author:
arshan

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

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

SERIAL_SPEED_57600

public static final int SERIAL_SPEED_57600
See Also:
Constant Field Values

SERIAL_SPEED_115200

public static final int SERIAL_SPEED_115200
See Also:
Constant Field Values

SERIAL_SPEED_250000

public static final int SERIAL_SPEED_250000
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

PART_ID

public static final String PART_ID
Identifier string for demoboard

See Also:
Constant Field Values

LED1

public static final PinDescriptor LED1
3 Color LED Identifier , matches silkscreening on the hardware


LED2

public static final PinDescriptor LED2
3 Color LED Identifier , matches silkscreening on the hardware


LED3

public static final PinDescriptor LED3
3 Color LED Identifier , matches silkscreening on the hardware


LED4

public static final PinDescriptor LED4
3 Color LED Identifier , matches silkscreening on the hardware


LED5

public static final PinDescriptor LED5
3 Color LED Identifier , matches silkscreening on the hardware


LED6

public static final PinDescriptor LED6
3 Color LED Identifier , matches silkscreening on the hardware


LED7

public static final PinDescriptor LED7
3 Color LED Identifier , matches silkscreening on the hardware


LED8

public static final PinDescriptor LED8
3 Color LED Identifier , matches silkscreening on the hardware


A0

public static final PinDescriptor A0
Analog to Digital convertor input pin, matches silkscreening on the hardware


A1

public static final PinDescriptor A1
Analog to Digital convertor input pin, matches silkscreening on the hardware


A2

public static final PinDescriptor A2
Analog to Digital convertor input pin, matches silkscreening on the hardware


A3

public static final PinDescriptor A3
Analog to Digital convertor input pin, matches silkscreening on the hardware


LIGHTSENSOR

public static final PinDescriptor LIGHTSENSOR
Descriptor for LightSensor, this is an internal connection. There is no matching silkscreened value.


ACCEL_X

public static final PinDescriptor ACCEL_X
Descriptor for X Axis accelerometer reading , this is an internal connection. There is no matching silkscreened value.


ACCEL_Y

public static final PinDescriptor ACCEL_Y
Descriptor for Y Axis accelerometer reading , this is an internal connection. There is no matching silkscreened value.


ACCEL_Z

public static final PinDescriptor ACCEL_Z
Descriptor for Z Axis accelerometer reading , this is an internal connection. There is no matching silkscreened value.


H0

public static final PinDescriptor H0
High current output pin, matches silkscreening on the hardware


H1

public static final PinDescriptor H1
High current output pin, matches silkscreening on the hardware


H2

public static final PinDescriptor H2
High current output pin, matches silkscreening on the hardware


H3

public static final PinDescriptor H3
High current output pin, matches silkscreening on the hardware


D0

public static final PinDescriptor D0
TTL level general purpose input/output pin, matches silkscreening on the hardware


D1

public static final PinDescriptor D1
TTL level general purpose input/output pin, matches silkscreening on the hardware


D2

public static final PinDescriptor D2
TTL level general purpose input/output pin, matches silkscreening on the hardware


D3

public static final PinDescriptor D3
TTL level general purpose input/output pin, matches silkscreening on the hardware


D4

public static final PinDescriptor D4
TTL level general purpose input/output pin, matches silkscreening on the hardware


SW1

public static final 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.


SW2

public static final 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.


A4

public static final PinDescriptor A4
Analog to Digital convertor input pin, matches silkscreening on the hardware


A5

public static final PinDescriptor A5
Analog to Digital convertor input pin, matches silkscreening on the hardware


ACCEL_SELFTEST

public static final PinDescriptor ACCEL_SELFTEST
Internal pin used to operate the accelerometer. There is no matching mark on the hardware.


ACCEL_FULLSCALE

public static final PinDescriptor ACCEL_FULLSCALE
Internal pin used to operate the accelerometer. There is no matching mark on the hardware.


POWER_ENABLE

public static final PinDescriptor POWER_ENABLE
Method Detail

disableRegistry

public void disableRegistry()
Disable the global pin registry in the EDemoBoard object. This will override the internal system that attempts to keep collisions from occuring during binding of the i/o pins. Using this method is not recommended if you do not clearly understand what you are trying to accomplish. Use at your own risk.


getInstance

public static EDemoBoard getInstance()
return the global singleton for the EDemoBoard at board select zero

Returns:
The singleton instance of EDemoBoard at board select 0.

name

public String name()
Returns the name that should be used by the IDriver subsystem.

Specified by:
name in interface IDriver
Returns:
String value, that is a human readable string identifying the EDemoBoard

tearDown

public boolean tearDown()
Perform any tasks necessary for hibernation.

Specified by:
tearDown in interface IDriver
Returns:
true if successful

setUp

public void setUp()
Perform any tasks necessary for initial setup, and return from hibernation.

Specified by:
setUp in interface IDriver

getADC

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

Returns:
a-to-d converter

bindScalarInput

public IScalarInput bindScalarInput(PinDescriptor pidx)
Registers the use of and return the ScalarInput object that reads from the specified ADC pin. The PinDescriptors that are valid arguments are all statically declared in EDemoBoard.java

Valid PinDescriptor List

EDemoBoard.A0
EDemoBoard.A1
EDemoBoard.A2
EDemoBoard.A3
EDemoBoard.A4
EDemoBoard.A5

Specified by:
bindScalarInput in interface IADCController
Parameters:
pidx - the pin you've connected a voltage to
Returns:
accessor object for ADC

getADCTemperature

public ITemperatureInput getADCTemperature()
Convience Function 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

getScalarValue

public int getScalarValue(PinDescriptor pidx)
Returns a scalar value for indicated pin from the ADC. This method is meant to be used by accessor objects of the IADCController interface. This method results directly in a read from the ADC part on the EDemoboard. This method can be used directly, however this will bypass the sanity checking done by the EDemoBoard class.

Specified by:
getScalarValue in interface IADCController
Parameters:
pidx - pin to probe
Returns:
current value from ADC registers

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

getLED

public ITriColorLED getLED(PinDescriptor pidx)
Convienence method to bind and return the LED that is reqested.

Valid PinDescriptor list
EDemoBoard.LED1
EDemoBoard.LED2
EDemoBoard.LED3
EDemoBoard.LED4
EDemoBoard.LED5
EDemoBoard.LED6
EDemoBoard.LED7
EDemoBoard.LED8

Parameters:
pidx - PinDescriptor to the desired LED
Returns:
LED accessor object

bindLED

public ITriColorLED bindLED(PinDescriptor pidx)
Returns an accessor object to the indicated 3 color LED.

Valid PinDescriptor list
EDemoBoard.LED1
EDemoBoard.LED2
EDemoBoard.LED3
EDemoBoard.LED4
EDemoBoard.LED5
EDemoBoard.LED6
EDemoBoard.LED7
EDemoBoard.LED8

Specified by:
bindLED in interface ITriColorLEDController
Parameters:
pidx - PinDescriptor to the desired LED
Returns:
LED accessor object

getLEDs

public ITriColorLED[] getLEDs()
Convienence method that returns an array of all the built in LEDs.

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

setLEDValue

public void setLEDValue(PinDescriptor pidx,
                        int r,
                        int g,
                        int b)
Set the RGB values of the indicated LED. This method is meant to be used by an accessor object to the ITriColorLEDController. This method bypasses sanity checks and results directly in traffic on the SPI bus to the Atmega microcontroller.

Valid PinDescriptor list
EDemoBoard.LED1
EDemoBoard.LED2
EDemoBoard.LED3
EDemoBoard.LED4
EDemoBoard.LED5
EDemoBoard.LED6
EDemoBoard.LED7
EDemoBoard.LED8

Specified by:
setLEDValue in interface ITriColorLEDController
Parameters:
pidx - Tri Color LED pin
r - value of red segment
g - value of green segment
b - value of blue segment

setLEDColorIntensity

public void setLEDColorIntensity(PinDescriptor pidx,
                                 int clr,
                                 int val)
Set the RGB values of the indicated LED. This method is meant to be used by an accessor object to the ITriColorLEDController. This method bypasses sanity checks and results directly in traffic on the SPI bus to the Atmega microcontroller.

Valid PinDescriptor list
EDemoBoard.LED1
EDemoBoard.LED2
EDemoBoard.LED3
EDemoBoard.LED4
EDemoBoard.LED5
EDemoBoard.LED6
EDemoBoard.LED7
EDemoBoard.LED8

Specified by:
setLEDColorIntensity in interface ITriColorLEDController
Parameters:
pidx - Tri Color LED pin
clr - encoded value for color segment see ITriColorLEDController
val - value to set

getSwitch

public ISwitch getSwitch(PinDescriptor pidx)
Register the indicated pin as a switch and return the accessor object for it.

Parameters:
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

Returns:
an ISwitch that is bound to the indicated pin

bindSwitch

public ISwitch bindSwitch(PinDescriptor pidx)
Register the indicated pin as a switch and return the accessor object for it.

Specified by:
bindSwitch in interface ISwitchController
Parameters:
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

Returns:
an ISwitch that is bound to the indicated pin

getSwitches

public ISwitch[] getSwitches()
Return an array of all the built in switches on the board.

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

getSwitchState

public boolean getSwitchState(PinDescriptor pidx)
Get the current state of a switch connected to the indicated pin. This method is meant to be used by classes implementing ISwitch to correspond to their SwitchControllers. This method results in an SPI transaction with the microcontroller on the DemoBoard, and can be called directly if you wish to bypass any state caching done for you, but be careful.

Specified by:
getSwitchState in interface ISwitchController
Parameters:
pidx - pin that switch is connected to
Returns:
value representing the current state of switch

bindOutputPin

public IOutputPin bindOutputPin(PinDescriptor pidx)
Register the use of and return the accessor object for the indicated output pin.

Valid PinDescriptor List
EDemoBoard.D0
EDemoBoard.D1
EDemoBoard.D2
EDemoBoard.D3
EDemoBoard.D4
EDemoBoard.H0
EDemoBoard.H1
EDemoBoard.H2
EDemoBoard.H3

Specified by:
bindOutputPin in interface IGPIOController
Parameters:
pidx - pin that the output is connected to
Returns:
accessor object for the output

bindInputPin

public IInputPin bindInputPin(PinDescriptor pidx)
Register the use of and return the accessor object for the indicated input pin.

Specified by:
bindInputPin in interface IGPIOController
Parameters:
pidx - pin that the input is connected to

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

Returns:
accessor object for input

bindIOPin

public IIOPin bindIOPin(PinDescriptor pidx)
Register the use of and return the accessor object for the indicated I/O pin.

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

Specified by:
bindIOPin in interface IGPIOController
Parameters:
pidx - pin that the input/output is connected to
Returns:
accessor object to the pin

setPinValue

public void setPinValue(PinDescriptor pidx,
                        boolean high)
Set the output value of the indicated pin. This method is meant to be used by accessor objects to the IGPIOController, and bypasses the sanity checks that are assumed to be done by those accessors.

Specified by:
setPinValue in interface IGPIOController
Parameters:
pidx - pin to set the value of
high - value to set the pin to, true sets pin to Vdd

getPinValue

public boolean getPinValue(PinDescriptor pidx)
Returns the value of the pin. This method is meant to be used by accessor objects to the IGPIOController, and bypasses the sanity checks that are assumed to be done by those accessors.

Specified by:
getPinValue in interface IGPIOController
Parameters:
pidx - pin to get the value of
Returns:
current binary value of the pin

enablePinChangeInterrupt

public void enablePinChangeInterrupt(PinDescriptor pidx,
                                     boolean lowToHigh,
                                     boolean highToLow)
Description copied from interface: IGPIOController
Allow the input pin specified to generate pin change interrupts. An interrupt can be generated on a low-to-high transition, a high-to-low transition, or both. After enabling the interrupt use IGPIOController.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.

Specified by:
enablePinChangeInterrupt in interface IGPIOController
Parameters:
pidx - The pin descriptor of the pin
lowToHigh - true if this pin is to generate low-to-high interrupts
highToLow - true if this pin is to generate high-to-low interrupts

disablePinChangeInterrupt

public void disablePinChangeInterrupt(PinDescriptor pidx)
Description copied from interface: IGPIOController
Stop a pin generating pin change interrupts

Specified by:
disablePinChangeInterrupt in interface IGPIOController
Parameters:
pidx - The pin descriptor of the pin

waitForPinChange

public PinDescriptor[] waitForPinChange()
Description copied from interface: IGPIOController
Wait for a pin change interrupt. This call will block until one of the pins previously enabled with IGPIOController.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.

Specified by:
waitForPinChange in interface IGPIOController
Returns:
the pins that have changed state

setPinDirection

public void setPinDirection(PinDescriptor pidx,
                            boolean output)
                     throws IOPinException
Set the mask for the indicated pin to the indicated direction. This method is meant to be used by accessor objects to the IGPIOController, and bypasses the sanity checks that are assumed to be done by those accessors.

Specified by:
setPinDirection in interface IGPIOController
Parameters:
pidx - pin to be modified
output - true if user wants the pin to be an output
Throws:
IOPinException - attempt to set pin to illegal direction

getLightSensor

public ILightSensor getLightSensor()
Convenience function to return lightsensor object.

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

bindLightSensor

public ILightSensor bindLightSensor(PinDescriptor pidx)
Register the use of and return the accessor object to a lightsensor connected to a scalar input pin. Includes the built in light sensor which is connected to the LIGHTSENSOR pin.

Valid PinDescriptor List

EDemoBoard.LIGHTSENSOR
EDemoBoard.A0
EDemoBoard.A1
EDemoBoard.A2
EDemoBoard.A3
EDemoBoard.A4
EDemoBoard.A5

Specified by:
bindLightSensor in interface ILightSensorController
Parameters:
pidx - pin that sensor is bound to
Returns:
valid accessor object

getLightSensorValue

public int getLightSensorValue(PinDescriptor pidx)
Get the current value of a lightsensor accessor connected to a particular pin. This method is meant to be used by accessor objects to the ILightSensorController interface. It bypasses the sanity checks that are assumed to be done by the accessors and results directly in traffic on the SPI bus.

Specified by:
getLightSensorValue in interface ILightSensorController
Parameters:
pidx - pin that the sensor is attached to
Returns:
current value for sensor as reported by ADC

getAccelerometer

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

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

bindServo

public IServo bindServo(PinDescriptor pidx)
Register the pin and return an accessor object to control an attached Servo.

Specified by:
bindServo in interface IServoController
Parameters:
pidx - pin servo data pin is attached to
Returns:
accessor object for servo.

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

startPulse

public void startPulse(PinDescriptor pidx,
                       int dir,
                       int usec)
Ask the controller to issue a pulse on the indicated pin. The pulse is accurate in terms of micro seconds but the start time of the pulse may be affected by a bit of latency.

Parameters:
pidx - pin to issure pulse on
dir - direction of desired pulse , 1 = high , 0 = low
usec - length of pulse in micro seconds

setServoPulseWidth

public void setServoPulseWidth(PinDescriptor pidx,
                               int usec)
Ask the controller to maintain a servo pulsewidth of some length. The controller will assure that the pulses are generated regularly enough to maintain stable control of a servo. This method is meant to be used by servo accessor objects, using this directly will bypass the sanity checks that are done by the servo object.

Specified by:
setServoPulseWidth in interface IServoController
Parameters:
pidx - pin that the servo is connected to
usec - length of servo pulse in micro seconds

getPulse

public int getPulse(PinDescriptor pidx,
                    int dir)
Ask the controller for a measurement of an incoming pulse on some pin. Will begin timing at edge of pulse in indicated direction and stop timing when the opposing edge is seen. If timing is not started in time for first edge, the result is invalid.

Parameters:
pidx - pin to measure pulse on
dir - direction of desired pulse
Returns:
length of measured pulse

setPWM

public 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. The control of this pulse generation is coarser then that available using the startPulse method.

Parameters:
pidx - pin to intiate PWM on
duty - duty cycle out of 255 slices

initUART

public void initUART(int baud,
                     boolean two_stopbit)
Initialize the UART module, sets the speed and selects 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