11from .modulino import Modulino
22from lsm6dsox import LSM6DSOX
3+ from collections import namedtuple
4+
5+ MovementValues = namedtuple ('MovementValues' , ['x' , 'y' , 'z' ])
6+ """A named tuple to store the x, y, and z values of the movement sensors."""
37
48class ModulinoMovement (Modulino ):
59 """
@@ -23,17 +27,23 @@ def __init__(self, i2c_bus = None, address: int | None = None) -> None:
2327 self .sensor = LSM6DSOX (self .i2c_bus , address = self .address )
2428
2529 @property
26- def accelerometer (self ) -> tuple [ float , float , float ] :
30+ def accelerometer (self ) -> MovementValues :
2731 """
2832 Returns:
29- tuple[float, float, float]: The acceleration values in the x, y, and z axes.
33+ MovementValues: The acceleration values in the x, y, and z axes.
34+ These values can be accessed as .x, .y, and .z properties
35+ or by using the index operator for tuple unpacking.
3036 """
31- return self .sensor .accel ()
37+ sensor_values = self .sensor .accel ()
38+ return MovementValues (sensor_values [0 ], sensor_values [1 ], sensor_values [2 ])
3239
3340 @property
34- def gyro (self ) -> tuple [ float , float , float ] :
41+ def gyro (self ) -> MovementValues :
3542 """
3643 Returns:
37- tuple[float, float, float]: The angular velocity values in the x, y, and z axes.
44+ MovementValues: The gyroscope values in the x, y, and z axes.
45+ These values can be accessed as .x, .y, and .z properties
46+ or by using the index operator for tuple unpacking.
3847 """
39- return self .sensor .gyro ()
48+ sensor_values = self .sensor .gyro ()
49+ return MovementValues (sensor_values [0 ], sensor_values [1 ], sensor_values [2 ])
0 commit comments