dLife Home Page

dlife.robot.finch
Class FinchBuzzer

java.lang.Object
  extended by java.util.Observable
      extended by dlife.robot.Device
          extended by dlife.robot.finch.FinchBuzzer

public class FinchBuzzer
extends Device

A class for controlling the Finch's buzzer. The Finch has a frequency controllable on-board buzzer that can play notes ranging from 100 Hz to 10,000 Hz. The buzzer is initialized to Middle-C.

Version:
Mar 14, 2011
Author:
Grant Braught, Dickinson College

Field Summary
 
Fields inherited from class dlife.robot.Device
DEFAULT_GUI_UPDATE_DELAY, DEFAULT_READ_DELAY, myRobot, readCount
 
Constructor Summary
FinchBuzzer()
          Construct a new FinchBuzzer object.
 
Method Summary
 void buzz(int frequency, int duration)
          Turn the buzzer on at the specified frequency for the specified amount of time.
protected  DeviceDisplay[] createGUIObjects()
          Get the GUI for the FinchBuzzer.
 void freeze()
          Turns off the Buzzer when something unexpected happens or after a single step.
 boolean isOn()
          Check if the buzzer is currently on.
static void main(String[] args)
          A little test program that displays the GUI for the FinchBuzzer and allows it to be used to control the Finch.
 void readStateFromRobot()
          Does nothing.
 void shutDown()
          Turns the buzzer off when disconnecting from the Finch.
 void startUp()
          Turns the buzzer off when connecting to the Finch.
 void turnOff()
          Turn the buzzer off.
 void turnOn(int frequency)
          Turn on the Finch's buzzer at the specified frequency.
 
Methods inherited from class dlife.robot.Device
getAutoRead, getGUI, getGUIUpdateDelay, getReadDelay, getRobot, getSensorReadCount, getSensorReadRate, setAutoRead, setGUIUpdateDelay, setReadDelay, setRobot, startAutoReadTimer, stopAutoReadTimer
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FinchBuzzer

public FinchBuzzer()
Construct a new FinchBuzzer object.

Method Detail

freeze

public void freeze()
Turns off the Buzzer when something unexpected happens or after a single step.

Specified by:
freeze in class Device

startUp

public void startUp()
Turns the buzzer off when connecting to the Finch. It should already be off, but turn it off just in case.

Overrides:
startUp in class Device

shutDown

public void shutDown()
Turns the buzzer off when disconnecting from the Finch.

Overrides:
shutDown in class Device

readStateFromRobot

public void readStateFromRobot()
Does nothing. The Finch does not report the state of its buzzer so this class maintains it internally.

Specified by:
readStateFromRobot in class Device

turnOn

public void turnOn(int frequency)
Turn on the Finch's buzzer at the specified frequency. The buzzer will remain on until it is turned off.

Parameters:
frequency - the frequency of the note to play.

isOn

public boolean isOn()
Check if the buzzer is currently on.

Returns:
true if the buzzer is on.

turnOff

public void turnOff()
Turn the buzzer off. If the buzzer is not on this method has no effect.


buzz

public void buzz(int frequency,
                 int duration)
Turn the buzzer on at the specified frequency for the specified amount of time.

Parameters:
frequency - the frequency of the note to play.
duration - the length of time to play the note (in ms.)

createGUIObjects

protected DeviceDisplay[] createGUIObjects()
Get the GUI for the FinchBuzzer.

Specified by:
createGUIObjects in class Device
Returns:
the GUI for the FinchBuzzer.

main

public static void main(String[] args)
A little test program that displays the GUI for the FinchBuzzer and allows it to be used to control the Finch.

Parameters:
args - none.

dLife Home Page