dLife Home Page

dlife.robot.scribbler
Class ScribblerSpeaker

java.lang.Object
  extended by java.util.Observable
      extended by dlife.robot.Device
          extended by dlife.robot.scribbler.ScribblerSpeaker

public class ScribblerSpeaker
extends Device

Device for controlling the speaker on the Scribbler. The Scribbler's speaker can play two notes simultaneously. The notes are played for a specified duration.

Note: The Scribbler is not able to accept any other commands while the speaker is playing. Thus, all sensor updates are suspended while the speaker is playing and are restarted when it completes.

Version:
Mar 13, 2012
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
ScribblerSpeaker()
          Construct a new ScribblerSpeaker device.
 
Method Summary
protected  DeviceDisplay[] createGUIObjects()
          Get the GUI for this ScribblerSpeaker device.
 void freeze()
          Does nothing.
 int getDuration()
          The duration for which the note/notes was/were played.
 int getNoteOneFrequency()
          Get the frequency of note one.
 int getNoteTwoFrequency()
          Get the frequency of note two.
 void playNote(int noteFrequency, int duration)
          Play the specified note for the specified duration.
 void playNotes(int noteOneFrequency, int noteTwoFrequency, int duration)
          Play the specified pair of notes for the specified duration.
 void readStateFromRobot()
          This method does nothing for the ScribblerSpeaker.
 void startUp()
          Startup the ScribblerSpeaker device.
 
Methods inherited from class dlife.robot.Device
getAutoRead, getGUI, getGUIUpdateDelay, getReadDelay, getRobot, getSensorReadCount, getSensorReadRate, setAutoRead, setGUIUpdateDelay, setReadDelay, setRobot, shutDown, 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

ScribblerSpeaker

public ScribblerSpeaker()
Construct a new ScribblerSpeaker device.

Method Detail

startUp

public void startUp()
Startup the ScribblerSpeaker device. Starting the device enables the speaker.

Overrides:
startUp in class Device

freeze

public void freeze()
Does nothing. Ideally this would silence the speaker but there is no way to do that because the robot does not accept any commands while the speaker is playing a tone.

Specified by:
freeze in class Device

readStateFromRobot

public void readStateFromRobot()
This method does nothing for the ScribblerSpeaker.

Specified by:
readStateFromRobot in class Device

playNote

public void playNote(int noteFrequency,
                     int duration)
Play the specified note for the specified duration.

Parameters:
noteFrequency - the frequency of the note to be played.
duration - the duration (in ms) that the note should be played.

playNotes

public void playNotes(int noteOneFrequency,
                      int noteTwoFrequency,
                      int duration)
Play the specified pair of notes for the specified duration.

Parameters:
noteOneFrequency - the frequency of one of the notes to be played.
noteTwoFrequency - the frequency of the other note to be played.
duration - the duration (in ms) that the notes should be played.

getNoteOneFrequency

public int getNoteOneFrequency()
Get the frequency of note one.

Returns:
frequency of note one.

getNoteTwoFrequency

public int getNoteTwoFrequency()
Get the frequency of note two.

Returns:
frequency of note two.

getDuration

public int getDuration()
The duration for which the note/notes was/were played.

Returns:
the duration (in ms).

createGUIObjects

protected DeviceDisplay[] createGUIObjects()
Get the GUI for this ScribblerSpeaker device.

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

dLife Home Page