|
SunSPOT API V6.0 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sun.spot.resources.Resource
com.sun.spot.sensorboard.peripheral.ToneGenerator
public class ToneGenerator
Allows attaching a simple speaker device to an output pin to generate various simple frequencies. Note: the tone will stop during deep sleep and resume when deep sleep is over. The core of the work is done by the microcontroller on the sensorboard. Note: for the eDemoboard the waveform generated for frequencies above 2000 Hz will have increasing jitter. The maximum frequency that can be set is 20,000Hz.
| Field Summary | |
|---|---|
static int |
MAX_FREQUENCY
|
static int |
PERIOD_CONSTANT
Deprecated. |
| Constructor Summary | |
|---|---|
ToneGenerator(IOutputPin pin)
Creates a new instance of ToneGenerator. |
|
| Method Summary | |
|---|---|
void |
beep()
Deprecated. Please use startTone(double hz, int dur) instead |
SensorEvent |
createSensorEvent()
Create a SensorEvent of the appropriate type for this sensor. |
void |
endTone()
Deprecated. Please use stopTone() instead |
String |
getDescription()
This method returns a readable description of the sensor. |
double |
getFrequency()
Deprecated. |
double |
getMaxSamplingRate()
Return the maximum sampling rate per second for this sensor. |
void |
saveEventState(SensorEvent evt)
Save the current sensor state in the specified event. |
void |
setDuration(int ms)
Deprecated. Please use startTone(double hz, int dur) instead |
void |
setFrequency(double hz)
Deprecated. please specify the desired frequency in the call to startTone() |
void |
setPeriod(int p)
Deprecated. please specify the desired frequency in the call to startTone() |
void |
startTone()
Deprecated. Please use startTone(double hz) instead |
void |
startTone(double hz)
start a tone at the specified frequency |
void |
startTone(double hz,
int dur)
start a tone at the specified frequency for the specified duration |
void |
stopTone()
stop current tone |
| Methods inherited from class com.sun.spot.resources.Resource |
|---|
addTag, getTags, getTagValue, hasTag, removeTag |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface com.sun.spot.resources.IResource |
|---|
addTag, getTags, getTagValue, hasTag, removeTag |
| Field Detail |
|---|
public static final int PERIOD_CONSTANT
public static final int MAX_FREQUENCY
| Constructor Detail |
|---|
public ToneGenerator(IOutputPin pin)
pin - where is the output device attached to the spot.| Method Detail |
|---|
public void startTone(double hz)
startTone in interface IToneGeneratorhz - value of frequency in Hertz
public void startTone(double hz,
int dur)
startTone in interface IToneGeneratorhz - value of frequency in Hertzdur - the time of the duration in millisecondspublic void stopTone()
stopTone in interface IToneGeneratorpublic void setFrequency(double hz)
setFrequency in interface IToneGeneratorhz - the frequency to set the tone topublic void setPeriod(int p)
p - the period to set the tone to (in microseconds)public double getFrequency()
getFrequency in interface IToneGeneratorpublic void setDuration(int ms)
setDuration in interface IToneGeneratorms - duration in millisecondspublic void startTone()
startTone in interface IToneGeneratorpublic void endTone()
endTone in interface IToneGeneratorpublic void beep()
beep in interface IToneGeneratorpublic String getDescription()
ITransducer
getDescription in interface ITransducerpublic double getMaxSamplingRate()
ITransducer
getMaxSamplingRate in interface ITransducerpublic SensorEvent createSensorEvent()
ITransducer
createSensorEvent in interface ITransducerpublic void saveEventState(SensorEvent evt)
ITransducer
saveEventState in interface ITransducerevt - the event to store the sensor state in
|
SunSPOT API V6.0 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||