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

Method __init__

Software/Python/easysensors.py:687–712  ·  view source on GitHub ↗

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

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

Source from the content-addressed store, hash-verified

685
686 """
687 def __init__(self, port="AD1", gpg=None, use_mutex=False):
688 """
689 Constructor for initializing a :py:class:`~easysensors.LoudnessSensor` object for the `Grove Loudness Sensor`_.
690
691 :param str port = "AD1": Port to which we have the `Grove Loudness Sensor`_ connected to.
692 :param easygopigo3.EasyGoPiGo3 gpg = None: :py:class:`~easygopigo3.EasyGoPiGo3` object used for instantiating a :py:class:`~easysensors.LoudnessSensor` object.
693 :param bool use_mutex = False: When using multiple threads/processes that access the same resource/device, mutexes should be enabled.
694 :raises TypeError: If the ``gpg`` parameter is not a :py:class:`~easygopigo3.EasyGoPiGo3` object.
695
696 The ``port`` parameter can take the following values:
697
698 * ``"AD1"`` - general purpose input/output port.
699 * ``"AD2"`` - general purpose input/output port.
700
701 The ports' locations can be seen in the following graphical representation: :ref:`hardware-ports-section`.
702
703 """
704 debug("Loudness Sensor on port " + port)
705 self.set_descriptor("Loudness sensor")
706 try:
707 AnalogSensor.__init__(self, port, "INPUT", gpg, use_mutex)
708 except:
709 raise
710 # time.sleep(0.2)
711 self.set_pin(1)
712 self._max_value = 1024 # based on empirical tests
713
714##########################
715

Callers

nothing calls this directly

Calls 4

set_descriptorMethod · 0.80
set_pinMethod · 0.80
debugFunction · 0.70
__init__Method · 0.45

Tested by

no test coverage detected