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)
| 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 | """ |
nothing calls this directly
no test coverage detected