MCPcopy Create free account
hub / github.com/DexterInd/GoPiGo3 / __init__

Method __init__

Software/Python/easysensors.py:1010–1038  ·  view source on GitHub ↗

Constructor for initializing a :py:class:`~easysensors.Buzzer` object for the `Grove Buzzer`_. :param str port = "AD1": Port to which we have the `Grove Buzzer`_ connected to. :param easygopigo3.EasyGoPiGo3 gpg = None: :py:class:`~easygopigo3.EasyGoPiGo3` object used for in

(self, port="AD1", gpg=None, use_mutex = False)

Source from the content-addressed store, hash-verified

1008 "G5#": 831}
1009
1010 def __init__(self, port="AD1", gpg=None, use_mutex = False):
1011 """
1012 Constructor for initializing a :py:class:`~easysensors.Buzzer` object for the `Grove Buzzer`_.
1013
1014 :param str port = "AD1": Port to which we have the `Grove Buzzer`_ connected to.
1015 :param easygopigo3.EasyGoPiGo3 gpg = None: :py:class:`~easygopigo3.EasyGoPiGo3` object used for instantiating a :py:class:`~easysensors.Buzzer` object.
1016 :param bool use_mutex = False: When using multiple threads/processes that access the same resource/device, mutexes should be enabled.
1017 :var int power = 50: Duty cycle of the signal that's put on the buzzer.
1018 :var int freq = 329: Frequency of the signal that's put on the buzzer. 329Hz is synonymous to E4 musical note. See :py:attr:`~.easysensors.Buzzer.scale` for more musical notes.
1019 :raises TypeError: If the ``gpg`` parameter is not a :py:class:`~easygopigo3.EasyGoPiGo3` object.
1020
1021 The ``port`` parameter can take the following values:
1022
1023 * ``"AD1"`` - general purpose input/output port.
1024 * ``"AD2"`` - general purpose input/output port.
1025
1026 The ports' locations can be seen in the following graphical representation: :ref:`hardware-ports-section`.
1027
1028 """
1029
1030 try:
1031 AnalogSensor.__init__(self, port, "OUTPUT", gpg, use_mutex)
1032 self.set_pin(1)
1033 self.set_descriptor("Buzzer")
1034 self.power = 50
1035 self.freq = 329
1036 self.sound_off()
1037 except:
1038 raise
1039
1040 def sound(self, freq):
1041 """

Callers

nothing calls this directly

Calls 4

sound_offMethod · 0.95
set_pinMethod · 0.80
set_descriptorMethod · 0.80
__init__Method · 0.45

Tested by

no test coverage detected