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

Method read

Software/Python/easysensors.py:1424–1453  ·  view source on GitHub ↗

Reads the numeric code received by the `Infrared Receiver`_. :return: The numeric code of the symbol that was pressed on the `Infrared Remote`_. :rtype: int The numeric code represents the index of the :py:attr:`~easysensors.Remote.keycodes` list. By access

(self)

Source from the content-addressed store, hash-verified

1422 raise
1423
1424 def read(self):
1425 """
1426 Reads the numeric code received by the `Infrared Receiver`_.
1427
1428 :return: The numeric code of the symbol that was pressed on the `Infrared Remote`_.
1429 :rtype: int
1430
1431 The numeric code represents the index of the :py:attr:`~easysensors.Remote.keycodes` list.
1432 By accessing the :py:attr:`~easysensors.Remote.keycodes` elements with the numeric code, you
1433 get the symbol that was pressed on the `Infrared Remote`_.
1434
1435 For only getting the symbol that was pressed on the `Infrared Remote`_, please check the :py:meth:`~easysensors.Remote.get_remote_code` method.
1436
1437 .. warning::
1438
1439 On :py:class:`~gopigo3.SensorError` exception:
1440
1441 * ``"Invalid Reading"`` string is printed in the console.
1442 * The value of **-1** is returned.
1443
1444 """
1445 try:
1446 _ifMutexAcquire(self.use_mutex)
1447 val = self.gpg.get_grove_value(self.get_port_ID())
1448 _ifMutexRelease(self.use_mutex)
1449 return val
1450 except gopigo3.SensorError as e:
1451 print("Invalid Reading")
1452 print(e)
1453 return -1
1454
1455
1456 def get_remote_code(self):

Callers 11

get_remote_codeMethod · 0.95
controllerFunction · 0.45
obstacleFinderFunction · 0.45
take_emotionFunction · 0.45
wait_for_buttonFunction · 0.45
getMouseValuesFunction · 0.45
read_ultrasonicFunction · 0.45
handle_distanceFunction · 0.45
motion_detectedMethod · 0.45
is_button_pressedMethod · 0.45
setup.pyFile · 0.45

Calls 4

_ifMutexAcquireFunction · 0.85
_ifMutexReleaseFunction · 0.85
get_port_IDMethod · 0.80
get_grove_valueMethod · 0.45

Tested by

no test coverage detected