Skip to content

Commit

Permalink
api: add PrimeHub
Browse files Browse the repository at this point in the history
  • Loading branch information
laurensvalk committed Oct 9, 2020
1 parent 90bea73 commit d4c44a2
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
8 changes: 8 additions & 0 deletions doc/api/hubs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ Technic Hub (Technic)

.. include:: hubs_technichub.inc

Prime Hub (SPIKE)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. figure:: ../api/images/primehub.png
:height: 15 em

.. include:: hubs_primehub.inc

Move Hub (BOOST)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Expand Down
42 changes: 42 additions & 0 deletions doc/api/hubs_primehub.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
.. autoclass:: pybricks.hubs.PrimeHub
:no-members:

.. rubric:: Using the hub status light

.. toggle-header::
:header: **Show/hide examples**

**Example 1: Turning the light on and off**

.. literalinclude::
../../pybricks-projects/snippets/pup/hub_primehub/light_off.py

**Example 2: Changing brightness and using custom colors**

.. literalinclude::
../../pybricks-projects/snippets/pup/hub_primehub/light_hsv.py

**Example 3: Making the light blink**

.. literalinclude::
../../pybricks-projects/snippets/pup/hub_primehub/light_blink.py

**Example 4: Creating light animations**

.. literalinclude::
../../pybricks-projects/snippets/pup/hub_primehub/light_animate.py

.. automethod:: pybricks.hubs::PrimeHub.light.on

.. automethod:: pybricks.hubs::PrimeHub.light.off

.. automethod:: pybricks.hubs::PrimeHub.light.blink

.. automethod:: pybricks.hubs::PrimeHub.light.animate

.. rubric:: Using the battery

.. automethod:: pybricks.hubs::PrimeHub.battery.voltage

.. automethod:: pybricks.hubs::PrimeHub.battery.current

6 changes: 6 additions & 0 deletions pybricks/hubs.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,9 @@ class TechnicHub:
"""LEGO® Technic Hub."""
battery = _Battery()
light = _ColorLight()


class PrimeHub:
"""LEGO® SPIKE Prime Hub."""
battery = _Battery()
light = _ColorLight()

0 comments on commit d4c44a2

Please sign in to comment.