diff --git a/Documentation/pycardium/leds.rst b/Documentation/pycardium/leds.rst index 892fb07c8872e28978d58e22fc18e01590eb56f2..44af2a6a93d5926f499de0b2c7e7752e038a2c11 100644 --- a/Documentation/pycardium/leds.rst +++ b/Documentation/pycardium/leds.rst @@ -5,16 +5,21 @@ Set one of the card10's RGB LEDs to a certain color. - Example which sets all LEDs on the top to red::: + **Example**: + + .. code-block:: python import leds, color + # Set all of the top LEDs to red for i in range(11): leds.set(i, color.RED) - :param led: Which led to set. 0-10 are the leds on the top and 11-14 are the 4 "ambient" leds. - :param color: What color to set the led to. Should be a :py:class:`color.Color` but any list/tuple - with 3 elements will work just as well. + :param led: Which led to set. 0-10 are the leds on the top + and 11-14 are the 4 "ambient" leds. + :param color: What color to set the led to. Should be a + :py:class:`color.Color` but any list/tuple with 3 elements + will work just as well. .. py:data:: leds.BOTTOM_RIGHT diff --git a/pycardium/modules/py/color.py b/pycardium/modules/py/color.py index 83d4b5a5e1cfaba2eb7737145a5168cec1cc221c..7a64e20adb29898738e29291e6acf8b99dcccd34 100644 --- a/pycardium/modules/py/color.py +++ b/pycardium/modules/py/color.py @@ -32,10 +32,26 @@ class Color(_ColorTuple): @classmethod def from_hex(cls, color): """ - Create a color from a hexadecimal number:: + Create a color from a hexadecimal number. + + This function is available both as a class method and directly inside + the color module: + + **Example**: + + .. code-block:: python + + from color import Color # Magenta Color.from_hex(0xff00ff) + + .. code-block:: python + + import color + + # Cyan + color.from_hex(0x00ffff) """ red = (color & 0xff0000) >> 16 green = (color & 0x00ff00) >> 8