Initialises a :py:class:`~di_sensors.easy_distance_sensor.EasyDistanceSensor` object and then returns it. :param str port = "I2C": The options for this parameter are ``"I2C"`` by default, ``"AD1"``, or ``"AD2"``. :returns: An instance of the :py:class:`~di_sensors.easy_dis
(self, port = "I2C")
| 1109 | return easysensors.Servo(port, self, use_mutex=self.use_mutex) |
| 1110 | |
| 1111 | def init_distance_sensor(self, port = "I2C"): |
| 1112 | """ |
| 1113 | |
| 1114 | Initialises a :py:class:`~di_sensors.easy_distance_sensor.EasyDistanceSensor` object and then returns it. |
| 1115 | |
| 1116 | :param str port = "I2C": The options for this parameter are ``"I2C"`` by default, ``"AD1"``, or ``"AD2"``. |
| 1117 | :returns: An instance of the :py:class:`~di_sensors.easy_distance_sensor.EasyDistanceSensor` class and with the port set to ``port``'s value. |
| 1118 | :raises ImportError: When the :py:mod:`di_sensors` module can't be found. Check the `DI-Sensors`_ documentation on how to install the libraries. |
| 1119 | |
| 1120 | The ports are mapped to the following :ref:`hardware-ports-section`. |
| 1121 | |
| 1122 | The ``use_mutex`` parameter of the :py:meth:`~easygopigo3.EasyGoPiGo3.__init__` constructor is passed down to the constructor of :py:class:`~di_sensors.easy_distance_sensor.EasyDistanceSensor` class. |
| 1123 | |
| 1124 | .. tip:: |
| 1125 | |
| 1126 | | The sensor can be connected to any of the I2C ports. |
| 1127 | | You can connect different I2C devices simultaneously provided that: |
| 1128 | |
| 1129 | * The I2C devices have different addresses. |
| 1130 | * The I2C devices are recognizeable by the `GoPiGo3`_ platform. |
| 1131 | |
| 1132 | | If the devices share the same address, like two distance sensors for example, you can still use them with the GoPiGo3 provided at least one is connected via the ``"AD1"``, or ``"AD2"``, port. |
| 1133 | |
| 1134 | """ |
| 1135 | if di_sensors_available is False: |
| 1136 | raise ImportError("di_sensors library not available") |
| 1137 | |
| 1138 | try: |
| 1139 | d = easy_distance_sensor.EasyDistanceSensor(port=port, use_mutex=self.use_mutex) |
| 1140 | except Exception as e: |
| 1141 | # print(e) |
| 1142 | d = None |
| 1143 | |
| 1144 | return d |
| 1145 | |
| 1146 | |
| 1147 | def init_dht_sensor(self, sensor_type = 0): |
no outgoing calls
no test coverage detected