diff --git a/doc/api/hubs/movehub.rst b/doc/api/hubs/movehub.rst index a269e04..65e77e4 100644 --- a/doc/api/hubs/movehub.rst +++ b/doc/api/hubs/movehub.rst @@ -19,6 +19,12 @@ Move Hub .. automethod:: pybricks.hubs::MoveHub.light.animate + .. rubric:: Using the IMU + + .. automethod:: pybricks.hubs::MoveHub.imu.up + + .. automethod:: pybricks.hubs::MoveHub.imu.acceleration + .. rubric:: Using the battery .. automethod:: pybricks.hubs::MoveHub.battery.voltage diff --git a/pybricks/_common.py b/pybricks/_common.py index f950008..a413b4b 100644 --- a/pybricks/_common.py +++ b/pybricks/_common.py @@ -715,7 +715,31 @@ class Battery: pass -class Accelerometer: +class SimpleAccelerometer: + """Get measurements from an accelerometer.""" + + def acceleration(self): + """Gets the acceleration of the device. + + Returns: + tuple of :ref:`linacceleration_m`: Acceleration along all three + axes. + """ + pass + + def up(self): + """Checks which side of the hub currently faces upward. + + :returns: + ``Side.TOP``, ``Side.BOTTOM``, ``Side.LEFT``, ``Side.RIGHT``, + ``Side.FRONT`` or ``Side.BACK``. + :rtype: :class:`Side` + + """ + pass + + +class Accelerometer(SimpleAccelerometer): """Get measurements from an accelerometer.""" def neutral(self, top, front): @@ -786,17 +810,6 @@ class Accelerometer: """ pass - def up(self): - """Checks which side of the device or hub currently faces upward. - - :returns: - ``Side.TOP``, ``Side.BOTTOM``, ``Side.LEFT``, ``Side.RIGHT``, - ``Side.FRONT`` or ``Side.BACK``. - :rtype: :class:`Side` - - """ - pass - class IMU(Accelerometer): diff --git a/pybricks/hubs.py b/pybricks/hubs.py index a45fdd2..9df3d89 100644 --- a/pybricks/hubs.py +++ b/pybricks/hubs.py @@ -4,7 +4,8 @@ """LEGO® Programmable Hubs.""" from ._common import (Speaker as _Speaker, Battery as _Battery, ColorLight as _ColorLight, Keypad as _Keypad, - LightMatrix as _LightMatrix, IMU as _IMU) + LightMatrix as _LightMatrix, IMU as _IMU, + SimpleAccelerometer as _SimpleAccelerometer) from .media.ev3dev import Image as _Image from .parameters import Button as _Button from .geometry import Axis as _Axis @@ -35,6 +36,7 @@ class MoveHub: # In reality, they are instance attributes created by __init__. battery = _Battery() light = _ColorLight() + imu = _SimpleAccelerometer() class CityHub: