Class BrickletPiezoSpeaker


  • public class BrickletPiezoSpeaker
    extends Device
    Creates beep with configurable frequency
    • Constructor Detail

      • BrickletPiezoSpeaker

        public BrickletPiezoSpeaker​(java.lang.String uid,
                                    IPConnection ipcon)
        Creates an object with the unique device ID \c uid. and adds it to the IP Connection \c ipcon.
    • Method Detail

      • beep

        public void beep​(long duration,
                         int frequency)
                  throws TinkerforgeException
        Beeps with the given frequency for the given duration. .. 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 Piezo Speaker Bricklet can only approximate the frequency, it will play the best possible match by applying the calibration (see calibrate()).
        Throws:
        TinkerforgeException
      • morseCode

        public void morseCode​(java.lang.String morse,
                              int frequency)
                       throws TinkerforgeException
        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. 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".
        Throws:
        TinkerforgeException
      • calibrate

        public boolean calibrate()
                          throws TinkerforgeException
        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.
        Throws:
        TinkerforgeException
      • getIdentity

        public Device.Identity getIdentity()
                                    throws TinkerforgeException
        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', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port). A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at position 'z'. The device identifier numbers can be found :ref:`here <device_identifier>`. |device_identifier_constant|
        Specified by:
        getIdentity in class Device
        Throws:
        TinkerforgeException