Constructor for initializing a :py:class:`~easysensors.ButtonSensor` object for the `Grove Button`_. :param str port = "AD1": Port to which we have the `Grove Button`_ connected to. :param easygopigo3.EasyGoPiGo3 gpg = None: :py:class:`~easygopigo3.EasyGoPiGo3` object used
(self, port="AD1", gpg=None, use_mutex = False)
| 1342 | """ |
| 1343 | |
| 1344 | def __init__(self, port="AD1", gpg=None, use_mutex = False): |
| 1345 | """ |
| 1346 | Constructor for initializing a :py:class:`~easysensors.ButtonSensor` object for the `Grove Button`_. |
| 1347 | |
| 1348 | :param str port = "AD1": Port to which we have the `Grove Button`_ connected to. |
| 1349 | :param easygopigo3.EasyGoPiGo3 gpg = None: :py:class:`~easygopigo3.EasyGoPiGo3` object used for instantiating a :py:class:`~easysensors.Button` object. |
| 1350 | :param bool use_mutex = False: When using multiple threads/processes that access the same resource/device, mutexes should be enabled. |
| 1351 | :raises TypeError: If the ``gpg`` parameter is not a :py:class:`~easygopigo3.EasyGoPiGo3` object. |
| 1352 | |
| 1353 | The ``port`` parameter can take the following values: |
| 1354 | |
| 1355 | * ``"AD1"`` - general purpose input/output port. |
| 1356 | * ``"AD2"`` - general purpose input/output port. |
| 1357 | |
| 1358 | The ports' locations can be seen in the following graphical representation: :ref:`hardware-ports-section`. |
| 1359 | |
| 1360 | """ |
| 1361 | try: |
| 1362 | self.set_descriptor("Button sensor") |
| 1363 | DigitalSensor.__init__(self, port, "DIGITAL_INPUT", gpg, use_mutex) |
| 1364 | self.set_pin(1) |
| 1365 | except Exception as e: |
| 1366 | print("button init: {}".format(e)) |
| 1367 | raise |
| 1368 | |
| 1369 | def is_button_pressed(self): |
| 1370 | """ |
nothing calls this directly
no test coverage detected