Skip to content

Commit ee9954a

Browse files
committed
Add color variables, update alarm.
1 parent 1014132 commit ee9954a

File tree

4 files changed

+42
-18
lines changed

4 files changed

+42
-18
lines changed

adafruit_clue.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ def __init__(self, title=None, title_color=0xFFFFFF, title_scale=1, # pylint:
8585
from adafruit_display_text import label
8686

8787
if not colors:
88-
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))
88+
colors = (Clue.VIOLET, Clue.GREEN, Clue.RED, Clue.CYAN, Clue.ORANGE,
89+
Clue.BLUE, Clue.MAGENTA, Clue.SKY, Clue.YELLOW, Clue.PURPLE)
9090

9191
self._colors = colors
9292
self._label = label
@@ -143,6 +143,30 @@ def show_terminal(self):
143143

144144
class Clue: # pylint: disable=too-many-instance-attributes, too-many-public-methods
145145
"""Represents a single CLUE."""
146+
147+
# Color variables available for import.
148+
RED = (255, 0, 0)
149+
YELLOW = (255, 255, 0)
150+
ORANGE = (255, 150, 0)
151+
GREEN = (0, 255, 0)
152+
TEAL = (0, 255, 120)
153+
CYAN = (0, 255, 255)
154+
BLUE = (0, 0, 255)
155+
PURPLE = (180, 0, 255)
156+
MAGENTA = (255, 0, 150)
157+
WHITE = (255, 255, 255)
158+
BLACK = (0, 0, 0)
159+
160+
GOLD = (255, 222, 30)
161+
PINK = (242, 90, 255)
162+
AQUA = (50, 255, 255)
163+
JADE = (0, 255, 40)
164+
AMBER = (255, 100, 0)
165+
VIOLET = (255, 0, 255)
166+
SKY = (0, 180, 255)
167+
168+
RAINBOW = (RED, ORANGE, YELLOW, GREEN, BLUE, PURPLE)
169+
146170
def __init__(self):
147171
# Define I2C:
148172
self._i2c = board.I2C()

examples/clue_height_calculator.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
# Set to the sea level pressure in hPa at your location for the most accurate altitude measurement.
66
clue.sea_level_pressure = 1015
77

8-
clue_data = clue.simple_text_display(text_scale=2, colors=((0, 255, 255), 0, (255, 0, 0),
9-
(255, 0, 0), 0, (255, 255, 0), 0,
10-
(0, 255, 0)))
8+
clue_data = clue.simple_text_display(text_scale=2, colors=(clue.CYAN, 0, clue.RED, clue.RED, 0,
9+
clue.YELLOW, 0, clue.GREEN))
10+
1111

1212
initial_height = clue.altitude
1313

examples/clue_spirit_level.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@
77
display = board.DISPLAY
88
group = displayio.Group(max_size=4)
99

10-
outer_circle = Circle(120, 120, 119, outline=(255, 255, 255))
11-
middle_circle = Circle(120, 120, 75, outline=(255, 255, 0))
12-
inner_circle = Circle(120, 120, 35, outline=(0, 255, 0))
10+
outer_circle = Circle(120, 120, 119, outline=clue.WHITE)
11+
middle_circle = Circle(120, 120, 75, outline=clue.YELLOW)
12+
inner_circle = Circle(120, 120, 35, outline=clue.GREEN)
1313
group.append(outer_circle)
1414
group.append(middle_circle)
1515
group.append(inner_circle)
1616

1717
x, y, _ = clue.acceleration
1818
bubble_group = displayio.Group(max_size=1)
19-
level_bubble = Circle(int(x + 120), int(y + 120), 20, fill=(255, 0, 0), outline=(255, 0, 0))
19+
level_bubble = Circle(int(x + 120), int(y + 120), 20, fill=clue.RED, outline=clue.RED)
2020
bubble_group.append(level_bubble)
2121

2222
group.append(bubble_group)

examples/clue_temperature_humidity_monitor.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
max_humidity = 65
1111

1212
# Set to true to enable alarm warning.
13-
alarm = False
13+
alarm_enable = False
1414

15-
data = clue.simple_text_display(text_scale=3, colors=((255, 255, 255),))
15+
data = clue.simple_text_display(text_scale=3, colors=(clue.WHITE,))
1616

1717
data[0].text = "Temperature &"
1818
data[1].text = "Humidity"
@@ -23,25 +23,25 @@
2323
data[3].text = "Temp: {:.1f} C".format(temperature)
2424
data[5].text = "Humi: {:.1f} %".format(humidity)
2525
if temperature < min_temp:
26-
data[3].color = (0, 0, 255)
26+
data[3].color = clue.BLUE
2727
alarm = True
2828
elif temperature > max_temp:
29-
data[3].color = (255, 0, 0)
29+
data[3].color = clue.RED
3030
alarm = True
3131
else:
32-
data[3].color = (255, 255, 255)
32+
data[3].color = clue.WHITE
3333

3434
if humidity < min_humidity:
35-
data[5].color = (0, 0, 255)
35+
data[5].color = clue.BLUE
3636
alarm = True
3737
elif humidity > max_humidity:
38-
data[5].color = (255, 0, 0)
38+
data[5].color = clue.RED
3939
alarm = True
4040
else:
41-
data[5].color = (255, 255, 255)
41+
data[5].color = clue.WHITE
4242
data.show()
4343

44-
if alarm:
44+
if alarm and alarm_enable:
4545
clue.start_tone(2000)
4646
else:
4747
clue.stop_tone()

0 commit comments

Comments
 (0)