From 5fe5fe313289cc48d3a917f37332515c41695dc4 Mon Sep 17 00:00:00 2001 From: fleur <spacecarrot@fleurshax.net> Date: Wed, 21 Aug 2019 13:58:13 +0000 Subject: [PATCH] docs: Document pride module --- Documentation/index.rst | 1 + Documentation/pycardium/pride.rst | 7 +++++ pycardium/modules/py/pride.py | 46 +++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 Documentation/pycardium/pride.rst diff --git a/Documentation/index.rst b/Documentation/index.rst index 06aa3b7e..0eec748c 100644 --- a/Documentation/index.rst +++ b/Documentation/index.rst @@ -32,6 +32,7 @@ Last but not least, if you want to start hacking the lower-level firmware, the pycardium/personal_state pycardium/utime pycardium/vibra + pycardium/pride .. toctree:: :maxdepth: 1 diff --git a/Documentation/pycardium/pride.rst b/Documentation/pycardium/pride.rst new file mode 100644 index 00000000..7e5de9c9 --- /dev/null +++ b/Documentation/pycardium/pride.rst @@ -0,0 +1,7 @@ +``pride`` - Pride flags +======================= +The ``pride`` module provides an easy interface to print pride flags to the top LEDs and the display. + +.. automodule:: pride + :members: + diff --git a/pycardium/modules/py/pride.py b/pycardium/modules/py/pride.py index d45d675d..3bfb29b6 100644 --- a/pycardium/modules/py/pride.py +++ b/pycardium/modules/py/pride.py @@ -83,6 +83,12 @@ import leds, display, math, utime, ledfx def expand(colors, cutoff=12): + """ + Expands the raw color list to a longer list, for example for the 11 LEDs. + + :param int colors: Color list to be expanded. + :param int cutoff: How long the expanded list is to be. Default = 12 + """ output = [] if len(colors) != 7 or cutoff > 14: leds_per_color = int(cutoff / len(colors)) @@ -95,6 +101,18 @@ def expand(colors, cutoff=12): def show_leds(flag="rainbow", brightness=0.5, gamma=1, cutoff=12, halo=True): + """ + Shows pride flag on the top leds. + + :param str flag: Chooses flag. A list of all available flags is accessible + via print_all(). Default = 'rainbow' + :param float brightness: Set brightness of LEDs. Default = 0.5 + :param float gamma: Apply simple gamma correction to adjust colors. + Default = 1 + :param int cutoff: See expand(). Default = 12 + :param bool halo: Bottom LEDs copy outermost top LEDs if true. + Default = True + """ colors = ledfx.col_cor(flags[flag], brightness, gamma) output = expand(colors, cutoff)[::-1][0:11] if halo: @@ -104,6 +122,15 @@ def show_leds(flag="rainbow", brightness=0.5, gamma=1, cutoff=12, halo=True): def show_display(flag="rainbow", brightness=1, gamma=1): + """ + Shows pride flag on the display. + + :param str flag: Chooses flag. A list of all available flags is accessible + via print_all(). Default = 'rainbow' + :param float brightness: Set brightness of LEDs. Default = 0.5 + :param float gamma: Apply simple gamma correction to adjust colors. + Default = 1 + """ colors = ledfx.col_cor(flags[flag], brightness, gamma) colors = expand(colors, 160) with display.open() as disp: @@ -115,10 +142,29 @@ def show_display(flag="rainbow", brightness=1, gamma=1): def get(flag="rainbow"): + """ + Returns color list of flag. + + :param str flag: Chooses flag. A list of all available flags is accessible + via print_all(). Default = 'rainbow' + """ return flags[flag] +def print_all(): + """ + Prints the names of all available flags on the serial port. + """ + for i in flags: + print(i) + + def demo(s_delay=2): + """ + Demos all available flags on LEDs and display. + + :param int s_delay: How long each flag is shown in seconds. Default = 2 + """ for i in flags: print(i) show_leds(flag=i) -- GitLab