public class PiezoTonePlayer extends LegoService
Modifier and Type | Class and Description |
---|---|
static class |
PiezoTonePlayer.PiezoTonePlayerNote
Tones that can be played using the PiezoTonePlayer
|
Modifier and Type | Field and Description |
---|---|
static int |
PIEZO_TONE_MAX_DURATION |
static int |
PIEZO_TONE_MAX_FREQUENCY |
callbackHelper, connectInfo, inputFormat, io
Modifier | Constructor and Description |
---|---|
protected |
PiezoTonePlayer(ConnectInfo connectInfo,
IO io) |
Modifier and Type | Method and Description |
---|---|
static PiezoTonePlayer |
createService(ConnectInfo connectInfo,
IO io) |
java.lang.String |
getServiceName() |
void |
playFrequency(int frequency,
int duration)
Play a frequency for the given duration in ms
|
void |
playNote(PiezoTonePlayer.PiezoTonePlayerNote note,
int octave,
int duration)
Play a note.
|
void |
stopPlaying()
Stop playing any currently playing tone.
|
addValidDataFormat, didReceiveInputFormat, didReceiveValueData, didRequestConnectInfo, equals, getConnectInfo, getDefaultInputFormat, getDevice, getFloatFromData, getInputFormat, getInputFormatMode, getIntegerFromData, getIo, getNumberFromValueData, getNumberFromValueData, getNumbersFromValueDataSet, getNumbersFromValueDataSet, getValidDataFormats, getValueAsFloat, getValueAsInteger, getValueData, handleUpdatedInputFormat, handleUpdatedValueData, hashCode, isInternalService, registerCallbackListener, removeValidDataFormat, sendReadValueRequest, sendResetStateRequest, setDevice, unregisterCallbackListener, updateCurrentInputFormatWithNewMode, updateInputFormat, writeData
public static final int PIEZO_TONE_MAX_FREQUENCY
public static final int PIEZO_TONE_MAX_DURATION
protected PiezoTonePlayer(ConnectInfo connectInfo, IO io)
public static PiezoTonePlayer createService(ConnectInfo connectInfo, IO io)
public java.lang.String getServiceName()
getServiceName
in class LegoService
public void playFrequency(int frequency, int duration)
frequency
- The frequency to play (max allowed frequency is 1500)duration
- The duration to play (max supported is 65536 milliseconds).public void playNote(PiezoTonePlayer.PiezoTonePlayerNote note, int octave, int duration)
note
- The note to playoctave
- The octave in which to play the noteduration
- The duration to play (max supported is 65536 milli seconds).public void stopPlaying()