Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
R. Nestler
firmware
Commits
5fe5fe31
Commit
5fe5fe31
authored
5 years ago
by
fleur
Committed by
rahix
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
docs: Document pride module
parent
338132e5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Documentation/index.rst
+1
-0
1 addition, 0 deletions
Documentation/index.rst
Documentation/pycardium/pride.rst
+7
-0
7 additions, 0 deletions
Documentation/pycardium/pride.rst
pycardium/modules/py/pride.py
+46
-0
46 additions, 0 deletions
pycardium/modules/py/pride.py
with
54 additions
and
0 deletions
Documentation/index.rst
+
1
−
0
View file @
5fe5fe31
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
Documentation/pycardium/pride.rst
0 → 100644
+
7
−
0
View file @
5fe5fe31
``pride`` - Pride flags
=======================
The ``pride`` module provides an easy interface to print pride flags to the top LEDs and the display.
.. automodule:: pride
:members:
This diff is collapsed.
Click to expand it.
pycardium/modules/py/pride.py
+
46
−
0
View file @
5fe5fe31
...
...
@@ -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
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment