Skip to content

Commit c1e8e40

Browse files
committed
Update color handling.
1 parent 79ca4b0 commit c1e8e40

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

adafruit_clue.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,6 @@ def __init__(self, title="CLUE Sensor Data", title_color=0xFFFFFF, title_scale=1
8686

8787
if not colors:
8888
colors = ((255, 0, 255), (0, 255, 0), (255, 0, 0), (0, 255, 255), (255, 255, 0),
89-
(0, 0, 255), (255, 0, 180), (0, 180, 255), (255, 180, 0), (180, 0, 255),
90-
(255, 0, 255), (0, 255, 0), (255, 0, 0), (0, 255, 255), (255, 255, 0),
9189
(0, 0, 255), (255, 0, 180), (0, 180, 255), (255, 180, 0), (180, 0, 255))
9290

9391
self._label = label
@@ -111,7 +109,7 @@ def __init__(self, title="CLUE Sensor Data", title_color=0xFFFFFF, title_scale=1
111109

112110
self._lines = []
113111
for num in range(num_lines):
114-
self._lines.append(self.add_text_line(color=colors[num]))
112+
self._lines.append(self.add_text_line(color=colors[num % len(colors)]))
115113

116114
def __getitem__(self, item):
117115
"""Fetch the Nth text line Group"""
@@ -814,11 +812,13 @@ def display_clue_data(title="CLUE Sensor Data", title_color=(255, 255, 255), tit
814812
Defaults to 1.
815813
:param str font: The font to use to display the title and data. Defaults to built in
816814
``terminalio.FONT``.
817-
:param colors: A list of colors for the lines of data on the display that must include one
818-
color for each of the lines you intend to display. Default colors are
819-
used if ``colors`` is not set. For example, if creating two lines of data,
820-
``colors=((255, 255, 255), (255, 0, 0))`` would set the first line white
821-
and the second line red.
815+
:param colors: A list of colors for the lines of data on the display. If you provide a
816+
single color, all lines will be that color. Otherwise it will alternate the
817+
list you provide if the list is less than the number of lines displayed.
818+
Default colors are used if ``colors`` is not set. For example, if creating
819+
two lines of data, ``colors=((255, 255, 255), (255, 0, 0))`` would set the
820+
first line white and the second line red, and if you created four lines of
821+
data with the same setup, it would alternate white and red.
822822
823823
.. image :: ../docs/_static/display_clue_data.jpg
824824
:alt: Display Clue Data demo

0 commit comments

Comments
 (0)