public class YBuzzer extends YFunction
Modifier and Type | Class and Description |
---|---|
static interface |
YBuzzer.TimedReportCallback
TimedReportCallback for Buzzer
|
static interface |
YBuzzer.UpdateCallback
Deprecated UpdateCallback for Buzzer
|
Modifier and Type | Field and Description |
---|---|
protected String |
_command |
protected double |
_frequency |
protected int |
_playSeqMaxSize |
protected int |
_playSeqSignature |
protected int |
_playSeqSize |
protected YBuzzer.UpdateCallback |
_valueCallbackBuzzer |
protected int |
_volume |
static String |
COMMAND_INVALID
invalid command value
|
static double |
FREQUENCY_INVALID
invalid frequency value
|
static int |
PLAYSEQMAXSIZE_INVALID
invalid playSeqMaxSize value
|
static int |
PLAYSEQSIGNATURE_INVALID
invalid playSeqSignature value
|
static int |
PLAYSEQSIZE_INVALID
invalid playSeqSize value
|
static int |
VOLUME_INVALID
invalid volume value
|
_advertisedValue, _cacheExpiration, _className, _dataStreams, _func, _funId, _hwId, _lastErrorMsg, _lastErrorType, _logicalName, _serial, _userData, _valueCallbackFunction, _yapi, ADVERTISEDVALUE_INVALID, FUNCTIONDESCRIPTOR_INVALID, LOGICALNAME_INVALID
Modifier | Constructor and Description |
---|---|
protected |
YBuzzer(String func) |
protected |
YBuzzer(YAPIContext ctx,
String func) |
Modifier and Type | Method and Description |
---|---|
int |
_invokeValueCallback(String value) |
protected void |
_parseAttr(com.yoctopuce.YoctoAPI.YJSONObject json_val) |
int |
addFreqMoveToPlaySeq(int freq,
int msDelay)
Adds a new frequency transition to the playing sequence.
|
int |
addNotesToPlaySeq(String notes)
Adds notes to the playing sequence.
|
int |
addPulseToPlaySeq(int freq,
int msDuration)
Adds a pulse to the playing sequence.
|
int |
addVolMoveToPlaySeq(int volume,
int msDuration)
Adds a new volume transition to the playing sequence.
|
static YBuzzer |
FindBuzzer(String func)
Retrieves a buzzer for a given identifier.
|
static YBuzzer |
FindBuzzerInContext(YAPIContext yctx,
String func)
Retrieves a buzzer for a given identifier in a YAPI context.
|
static YBuzzer |
FirstBuzzer()
Starts the enumeration of buzzers currently accessible.
|
static YBuzzer |
FirstBuzzerInContext(YAPIContext yctx)
Starts the enumeration of buzzers currently accessible.
|
int |
freqMove(int frequency,
int duration)
Makes the buzzer frequency change over a period of time.
|
String |
get_command() |
double |
get_frequency()
Returns the frequency of the signal sent to the buzzer/speaker.
|
int |
get_playSeqMaxSize()
Returns the maximum length of the playing sequence.
|
int |
get_playSeqSignature()
Returns the playing sequence signature.
|
int |
get_playSeqSize()
Returns the current length of the playing sequence.
|
int |
get_volume()
Returns the volume of the signal sent to the buzzer/speaker.
|
double |
getFrequency()
Returns the frequency of the signal sent to the buzzer/speaker.
|
int |
getPlaySeqMaxSize()
Returns the maximum length of the playing sequence.
|
int |
getPlaySeqSignature()
Returns the playing sequence signature.
|
int |
getPlaySeqSize()
Returns the current length of the playing sequence.
|
int |
getVolume()
Returns the volume of the signal sent to the buzzer/speaker.
|
YBuzzer |
nextBuzzer()
Continues the enumeration of buzzers started using yFirstBuzzer().
|
int |
oncePlaySeq()
Starts the preprogrammed playing sequence and run it once only.
|
int |
playNotes(String notes)
Immediately play a note sequence.
|
int |
pulse(int frequency,
int duration)
Activates the buzzer for a short duration.
|
int |
registerValueCallback(YBuzzer.UpdateCallback callback)
Registers the callback function that is invoked on every change of advertised value.
|
int |
reloadPlaySeq()
Reloads the preprogrammed playing sequence from the flash memory.
|
int |
resetPlaySeq()
Resets the preprogrammed playing sequence and sets the frequency to zero.
|
int |
savePlaySeq()
Saves the preprogrammed playing sequence to flash memory.
|
int |
sendCommand(String command) |
int |
set_command(String newval) |
int |
set_frequency(double newval)
Changes the frequency of the signal sent to the buzzer.
|
int |
set_volume(int newval)
Changes the volume of the signal sent to the buzzer/speaker.
|
int |
setFrequency(double newval)
Changes the frequency of the signal sent to the buzzer.
|
int |
setVolume(int newval)
Changes the volume of the signal sent to the buzzer/speaker.
|
int |
startPlaySeq()
Starts the preprogrammed playing sequence.
|
int |
stopPlaySeq()
Stops the preprogrammed playing sequence and sets the frequency to zero.
|
int |
volumeMove(int volume,
int duration)
Makes the buzzer volume change over a period of time, frequency stays untouched.
|
_AddToCache, _clearDataStreamCache, _download, _escapeAttr, _FindFromCache, _FindFromCacheInContext, _get_json_path_struct, _get_json_path, _json_get_array, _json_get_key, _json_get_string, _parse, _parserHelper, _setAttr, _throw, _UpdateTimedReportCallbackList, _UpdateValueCallbackList, _upload, _upload, _uploadEx, clearCache, describe, errMessage, errorMessage, errorType, errType, FindFunction, FindFunctionInContext, FirstFunction, FirstFunctionInContext, functionDescriptor, get_advertisedValue, get_errorMessage, get_errorType, get_friendlyName, get_functionDescriptor, get_functionId, get_hardwareId, get_logicalName, get_module, get_serialNumber, get_userData, getAdvertisedValue, getErrorMessage, getErrorType, getFriendlyName, getFunctionDescriptor, getFunctionId, getHardwareId, getLogicalName, getModule, getUserData, isOnline, isReadOnly, load, loadAttribute, module, muteValueCallbacks, nextFunction, registerValueCallback, set_advertisedValue, set_logicalName, set_userData, setLogicalName, setUserData, toString, unmuteValueCallbacks, userData
public static final double FREQUENCY_INVALID
public static final int VOLUME_INVALID
public static final int PLAYSEQSIZE_INVALID
public static final int PLAYSEQMAXSIZE_INVALID
public static final int PLAYSEQSIGNATURE_INVALID
public static final String COMMAND_INVALID
protected double _frequency
protected int _volume
protected int _playSeqSize
protected int _playSeqMaxSize
protected int _playSeqSignature
protected String _command
protected YBuzzer.UpdateCallback _valueCallbackBuzzer
protected YBuzzer(YAPIContext ctx, String func)
func
- : functionidprotected YBuzzer(String func)
func
- : functionidprotected void _parseAttr(com.yoctopuce.YoctoAPI.YJSONObject json_val) throws Exception
_parseAttr
in class YFunction
Exception
public int set_frequency(double newval) throws YAPI_Exception
newval
- : a floating point number corresponding to the frequency of the signal sent to the buzzerYAPI_Exception
- on errorpublic int setFrequency(double newval) throws YAPI_Exception
newval
- : a floating point number corresponding to the frequency of the signal sent to the buzzerYAPI_Exception
- on errorpublic double get_frequency() throws YAPI_Exception
YAPI_Exception
- on errorpublic double getFrequency() throws YAPI_Exception
YAPI_Exception
- on errorpublic int get_volume() throws YAPI_Exception
YAPI_Exception
- on errorpublic int getVolume() throws YAPI_Exception
YAPI_Exception
- on errorpublic int set_volume(int newval) throws YAPI_Exception
newval
- : an integer corresponding to the volume of the signal sent to the buzzer/speakerYAPI_Exception
- on errorpublic int setVolume(int newval) throws YAPI_Exception
newval
- : an integer corresponding to the volume of the signal sent to the buzzer/speakerYAPI_Exception
- on errorpublic int get_playSeqSize() throws YAPI_Exception
YAPI_Exception
- on errorpublic int getPlaySeqSize() throws YAPI_Exception
YAPI_Exception
- on errorpublic int get_playSeqMaxSize() throws YAPI_Exception
YAPI_Exception
- on errorpublic int getPlaySeqMaxSize() throws YAPI_Exception
YAPI_Exception
- on errorpublic int get_playSeqSignature() throws YAPI_Exception
YAPI_Exception
- on errorpublic int getPlaySeqSignature() throws YAPI_Exception
YAPI_Exception
- on errorpublic String get_command() throws YAPI_Exception
YAPI_Exception
public int set_command(String newval) throws YAPI_Exception
YAPI_Exception
public static YBuzzer FindBuzzer(String func)
func
- : a string that uniquely characterizes the buzzer, for instance
YBUZZER2.buzzer.public static YBuzzer FindBuzzerInContext(YAPIContext yctx, String func)
yctx
- : a YAPI contextfunc
- : a string that uniquely characterizes the buzzer, for instance
YBUZZER2.buzzer.public int registerValueCallback(YBuzzer.UpdateCallback callback)
callback
- : the callback function to call, or a null pointer. The callback function should take two
arguments: the function object of which the value has changed, and the character string describing
the new advertised value.public int _invokeValueCallback(String value)
_invokeValueCallback
in class YFunction
public int sendCommand(String command) throws YAPI_Exception
YAPI_Exception
public int addFreqMoveToPlaySeq(int freq, int msDelay) throws YAPI_Exception
freq
- : desired frequency when the transition is completed, in HzmsDelay
- : duration of the frequency transition, in milliseconds.YAPI_Exception
- on errorpublic int addPulseToPlaySeq(int freq, int msDuration) throws YAPI_Exception
freq
- : pulse frequency, in HzmsDuration
- : pulse duration, in milliseconds.YAPI_Exception
- on errorpublic int addVolMoveToPlaySeq(int volume, int msDuration) throws YAPI_Exception
volume
- : desired volume when the transition is completed, as a percentage.msDuration
- : duration of the volume transition, in milliseconds.YAPI_Exception
- on errorpublic int addNotesToPlaySeq(String notes) throws YAPI_Exception
notes
- : notes to be played, as a text string.YAPI_Exception
- on errorpublic int startPlaySeq() throws YAPI_Exception
YAPI_Exception
- on errorpublic int stopPlaySeq() throws YAPI_Exception
YAPI_Exception
- on errorpublic int resetPlaySeq() throws YAPI_Exception
YAPI_Exception
- on errorpublic int oncePlaySeq() throws YAPI_Exception
YAPI_Exception
- on errorpublic int savePlaySeq() throws YAPI_Exception
YAPI_Exception
- on errorpublic int reloadPlaySeq() throws YAPI_Exception
YAPI_Exception
- on errorpublic int pulse(int frequency, int duration) throws YAPI_Exception
frequency
- : pulse frequency, in hertzduration
- : pulse duration in millisecondsYAPI_Exception
- on errorpublic int freqMove(int frequency, int duration) throws YAPI_Exception
frequency
- : frequency to reach, in hertz. A frequency under 25Hz stops the buzzer.duration
- : pulse duration in millisecondsYAPI_Exception
- on errorpublic int volumeMove(int volume, int duration) throws YAPI_Exception
volume
- : volume to reach in %duration
- : change duration in millisecondsYAPI_Exception
- on errorpublic int playNotes(String notes) throws YAPI_Exception
notes
- : notes to be played, as a text string.YAPI_Exception
- on errorpublic YBuzzer nextBuzzer()
public static YBuzzer FirstBuzzer()
public static YBuzzer FirstBuzzerInContext(YAPIContext yctx)
yctx
- : a YAPI context.Copyright © 2022. All rights reserved.