The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Tinkerforge::BrickletPiezoSpeaker - Creates beep with configurable frequency

CONSTANTS

DEVICE_IDENTIFIER

This constant is used to identify a Piezo Speaker Bricklet.

The get_identity() subroutine and the CALLBACK_ENUMERATE callback of the IP Connection have a device_identifier parameter to specify the Brick's or Bricklet's type.

DEVICE_DISPLAY_NAME

This constant represents the display name of a Piezo Speaker Bricklet.

CALLBACK_BEEP_FINISHED

This constant is used with the register_callback() subroutine to specify the CALLBACK_BEEP_FINISHED callback.

CALLBACK_MORSE_CODE_FINISHED

This constant is used with the register_callback() subroutine to specify the CALLBACK_MORSE_CODE_FINISHED callback.

FUNCTION_BEEP

This constant is used with the get_response_expected(), set_response_expected() and set_response_expected_all() subroutines.

FUNCTION_MORSE_CODE

This constant is used with the get_response_expected(), set_response_expected() and set_response_expected_all() subroutines.

FUNCTION_CALIBRATE

This constant is used with the get_response_expected(), set_response_expected() and set_response_expected_all() subroutines.

FUNCTION_GET_IDENTITY

This constant is used with the get_response_expected(), set_response_expected() and set_response_expected_all() subroutines.

FUNCTIONS

new()

Creates an object with the unique device ID *uid* and adds it to the IP Connection *ipcon*.

beep()

Beeps with the given frequency for the duration in ms. For example: If you set a duration of 1000, with a frequency value of 2000 the piezo buzzer will beep for one second with a frequency of approximately 2 kHz.

.. versionchanged:: 2.0.2$nbsp;(Plugin) A duration of 0 stops the current beep if any, the frequency parameter is ignored. A duration of 4294967295 results in an infinite beep.

The *frequency* parameter can be set between 585 and 7100.

The Piezo Speaker Bricklet can only approximate the frequency, it will play the best possible match by applying the calibration (see :func:`Calibrate`).

morse_code()

Sets morse code that will be played by the piezo buzzer. The morse code is given as a string consisting of "." (dot), "-" (minus) and " " (space) for *dits*, *dahs* and *pauses*. Every other character is ignored. The second parameter is the frequency (see :func:`Beep`).

For example: If you set the string "...---...", the piezo buzzer will beep nine times with the durations "short short short long long long short short short".

The maximum string size is 60.

calibrate()

The Piezo Speaker Bricklet can play 512 different tones. This function plays each tone and measures the exact frequency back. The result is a mapping between setting value and frequency. This mapping is stored in the EEPROM and loaded on startup.

The Bricklet should come calibrated, you only need to call this function (once) every time you reflash the Bricklet plugin.

Returns *true* after the calibration finishes.

get_identity()

Returns the UID, the UID where the Bricklet is connected to, the position, the hardware and firmware version as well as the device identifier.

The position can be 'a', 'b', 'c' or 'd'.

The device identifier numbers can be found :ref:`here <device_identifier>`. |device_identifier_constant|