Class GreenFinch

java.lang.Object
  extended by GreenFinch

public class GreenFinch
extends java.lang.Object

A simplified version of the finch object. If you want the full capabilities of the finch object then you can call the getFinchObject() method which returns the original finch backing this GreenFinch.

This class is a singleton class, you don't create new instances of it since there's only one Greenfinch. Instead, call the get() method like so:

GreenFinch finch = GreenFinch.get();

You can then call any of the desired methods on this finch.


Method Summary
 void buzz(int freq, int duration)
          Tell the finch to buzz at the given frequency for a certain amount of time.
static GreenFinch get()
          Get the instance of the GreenFinch.
 Finch getFinchObject()
          Get the finch object underlying this GreenFinch.
 int getLeftLightLevel()
          Get the left light level as measured by the finch.
 int getLightLevel()
          Get the overall light level as measured by the finch.
 int getRightLightLevel()
          Get the right light level as measured by the finch.
 double getTemperature()
          Get the current temperature as measured by the finch in degrees celcius.
 double getXAcceleration()
          Get the value of the X acceleration the finch is currently experiencing.
 double getYAcceleration()
          Get the value of the Y acceleration the finch is currently experiencing.
 double getZAcceleration()
          Get the value of the Z acceleration the finch is currently experiencing.
 boolean isLeftHit()
          Determine if the left-hand infrared sensor is registering something directly in front of it.
 boolean isRightHit()
          Determine if the right-hand infrared sensor is registering something directly in front of it.
 void setLED(java.awt.Color color)
          Set the LED on board the finch to a certain color.
 void setLED(int red, int green, int blue)
          Set the LED on board the finch to a certain color.
 void setWheelSpeeds(int left, int right)
          Set the left and right wheel speeds of the finch.
protected  void start()
          Start the finch.
protected  void stop()
          Stop the finch.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

get

public static GreenFinch get()
Get the instance of the GreenFinch. Call this instead of using the constructor.

Returns:
the GreenFinch singleton instance.

getXAcceleration

public double getXAcceleration()
Get the value of the X acceleration the finch is currently experiencing.

Returns:
the accelerometer's X value.

getYAcceleration

public double getYAcceleration()
Get the value of the Y acceleration the finch is currently experiencing.

Returns:
the accelerometer's Y value.

getZAcceleration

public double getZAcceleration()
Get the value of the Z acceleration the finch is currently experiencing.

Returns:
the accelerometer's Z value.

isLeftHit

public boolean isLeftHit()
Determine if the left-hand infrared sensor is registering something directly in front of it.

Returns:
true if the left-hand sensor is registering a collision, false otherwise.

isRightHit

public boolean isRightHit()
Determine if the right-hand infrared sensor is registering something directly in front of it.

Returns:
true if the right-hand sensor is registering a collision, false otherwise.

setLED

public void setLED(java.awt.Color color)
Set the LED on board the finch to a certain color.

Parameters:
color - the colour to set the finch's LED to.

setLED

public void setLED(int red,
                   int green,
                   int blue)
Set the LED on board the finch to a certain color.

Parameters:
red - Intensity of the red LED (range is 0-255)
green - Intensity of the green LED (range is 0-255)
blue - Intensity of the blue LED (range is 0-255)

getTemperature

public double getTemperature()
Get the current temperature as measured by the finch in degrees celcius.

Returns:
the finch's temperature.

getLightLevel

public int getLightLevel()
Get the overall light level as measured by the finch.

Returns:
the current light level, between 0 and 100 (0 being very dark and 100 being very light.)

getLeftLightLevel

public int getLeftLightLevel()
Get the left light level as measured by the finch.

Returns:
the current light level, between 0 and 100 (0 being very dark and 100 being very light.)

getRightLightLevel

public int getRightLightLevel()
Get the right light level as measured by the finch.

Returns:
the current light level, between 0 and 100 (0 being very dark and 100 being very light.)

buzz

public void buzz(int freq,
                 int duration)
Tell the finch to buzz at the given frequency for a certain amount of time. The range of human hearing is around 20Hz to 20,000Hz, so pick a value in this range.

Parameters:
frequency - Hz that the finch should buzz at.
duration - length of time the buzz should occur for, in ms (1000ms = 1s.)

setWheelSpeeds

public void setWheelSpeeds(int left,
                           int right)
Set the left and right wheel speeds of the finch. The values are taken between -100 and 100; -100 is full speed backwards, 0 is stopped and 100 is full speed forwards.

Parameters:
left - the speed of the left wheel.
right - the speed of the right wheel.

start

protected void start()
Start the finch.


stop

protected void stop()
Stop the finch.


getFinchObject

public Finch getFinchObject()
Get the finch object underlying this GreenFinch.

Returns:
the raw finch object.