|  | 
| 81 | 81 | BNO_REPORT_LINEAR_ACCELERATION = const(0x04) | 
| 82 | 82 | # Rotation Vector | 
| 83 | 83 | BNO_REPORT_ROTATION_VECTOR = const(0x05) | 
|  | 84 | +# Gravity Vector (m/s2). Vector direction of gravity | 
|  | 85 | +BNO_REPORT_GRAVITY = const(0x06) | 
|  | 86 | +# Game Rotation Vector | 
| 84 | 87 | BNO_REPORT_GAME_ROTATION_VECTOR = const(0x08) | 
| 85 | 88 | 
 | 
| 86 | 89 | BNO_REPORT_GEOMAGNETIC_ROTATION_VECTOR = const(0x09) | 
|  | 
| 139 | 142 | } | 
| 140 | 143 | _AVAIL_SENSOR_REPORTS = { | 
| 141 | 144 |     BNO_REPORT_ACCELEROMETER: (_Q_POINT_8_SCALAR, 3, 10), | 
|  | 145 | +    BNO_REPORT_GRAVITY: (_Q_POINT_8_SCALAR, 3, 10), | 
| 142 | 146 |     BNO_REPORT_GYROSCOPE: (_Q_POINT_9_SCALAR, 3, 10), | 
| 143 | 147 |     BNO_REPORT_MAGNETOMETER: (_Q_POINT_4_SCALAR, 3, 10), | 
| 144 | 148 |     BNO_REPORT_LINEAR_ACCELERATION: (_Q_POINT_8_SCALAR, 3, 10), | 
| @@ -370,15 +374,6 @@ def _separate_batch(packet, report_slices): | 
| 370 | 374 |         next_byte_index = next_byte_index + required_bytes | 
| 371 | 375 | 
 | 
| 372 | 376 | 
 | 
| 373 |  | -# class Report: | 
| 374 |  | -#     _buffer = bytearray(DATA_BUFFER_SIZE) | 
| 375 |  | -#     _report_obj = Report(_buffer) | 
| 376 |  | - | 
| 377 |  | -#     @classmethod | 
| 378 |  | -#     def get_report(cls) | 
| 379 |  | -#         return cls._report_obj | 
| 380 |  | - | 
| 381 |  | - | 
| 382 | 377 | class Packet: | 
| 383 | 378 |     """A class representing a Hillcrest LaboratorySensor Hub Transport packet""" | 
| 384 | 379 | 
 | 
| @@ -597,6 +592,16 @@ def acceleration(self): | 
| 597 | 592 |         except KeyError: | 
| 598 | 593 |             raise RuntimeError("No accel report found, is it enabled?") from None | 
| 599 | 594 | 
 | 
|  | 595 | +    @property | 
|  | 596 | +    def gravity(self): | 
|  | 597 | +        """A tuple representing the gravity vector in the X, Y, and Z components | 
|  | 598 | +        axes in meters per second squared""" | 
|  | 599 | +        self._process_available_packets() | 
|  | 600 | +        try: | 
|  | 601 | +            return self._readings[BNO_REPORT_GRAVITY] | 
|  | 602 | +        except KeyError: | 
|  | 603 | +            raise RuntimeError("No gravity report found, is it enabled?") from None | 
|  | 604 | + | 
| 600 | 605 |     @property | 
| 601 | 606 |     def gyro(self): | 
| 602 | 607 |         """A tuple representing Gyro's rotation measurements on the X, Y, and Z | 
|  | 
0 commit comments