Skip to content

Variable changes for consistency. #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions examples/clue_height_calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,20 @@
# Set to the sea level pressure in hPa at your location for the most accurate altitude measurement.
clue.sea_level_pressure = 1015

clue_data = clue.simple_text_display(text_scale=2, colors=(clue.CYAN, 0, clue.RED, clue.RED, 0,
clue.YELLOW, 0, clue.GREEN))

clue_display = clue.simple_text_display(text_scale=2, colors=(clue.CYAN, 0, clue.RED, clue.RED, 0,
clue.YELLOW, 0, clue.GREEN))

initial_height = clue.altitude

clue_data[0].text = "Calculate height!"
clue_data[2].text = "Press A to reset"
clue_data[3].text = "initial height!"
clue_display[0].text = "Calculate height!"
clue_display[2].text = "Press A to reset"
clue_display[3].text = "initial height!"
while True:
if clue.button_a:
initial_height = clue.altitude
clue.pixel.fill((255, 0, 0))
else:
clue.pixel.fill(0)
clue_data[5].text = "Altitude: {:.1f} m".format(clue.altitude)
clue_data[7].text = "Height: {:.1f} m".format(clue.altitude - initial_height)
clue_data.show()
clue_display[5].text = "Altitude: {:.1f} m".format(clue.altitude)
clue_display[7].text = "Height: {:.1f} m".format(clue.altitude - initial_height)
clue_display.show()
12 changes: 6 additions & 6 deletions examples/clue_spirit_level.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@
import displayio

display = board.DISPLAY
group = displayio.Group(max_size=4)
clue_group = displayio.Group(max_size=4)

outer_circle = Circle(120, 120, 119, outline=clue.WHITE)
middle_circle = Circle(120, 120, 75, outline=clue.YELLOW)
inner_circle = Circle(120, 120, 35, outline=clue.GREEN)
group.append(outer_circle)
group.append(middle_circle)
group.append(inner_circle)
clue_group.append(outer_circle)
clue_group.append(middle_circle)
clue_group.append(inner_circle)

x, y, _ = clue.acceleration
bubble_group = displayio.Group(max_size=1)
level_bubble = Circle(int(x + 120), int(y + 120), 20, fill=clue.RED, outline=clue.RED)
bubble_group.append(level_bubble)

group.append(bubble_group)
display.show(group)
clue_group.append(bubble_group)
display.show(clue_group)

while True:
x, y, _ = clue.acceleration
Expand Down
24 changes: 12 additions & 12 deletions examples/clue_temperature_humidity_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,34 +12,34 @@
# Set to true to enable alarm warning.
alarm_enable = False

data = clue.simple_text_display(text_scale=3, colors=(clue.WHITE,))
clue_display = clue.simple_text_display(text_scale=3, colors=(clue.WHITE,))

data[0].text = "Temperature &"
data[1].text = "Humidity"
clue_display[0].text = "Temperature &"
clue_display[1].text = "Humidity"
while True:
alarm = False
temperature = clue.temperature
humidity = clue.humidity
data[3].text = "Temp: {:.1f} C".format(temperature)
data[5].text = "Humi: {:.1f} %".format(humidity)
clue_display[3].text = "Temp: {:.1f} C".format(temperature)
clue_display[5].text = "Humi: {:.1f} %".format(humidity)
if temperature < min_temp:
data[3].color = clue.BLUE
clue_display[3].color = clue.BLUE
alarm = True
elif temperature > max_temp:
data[3].color = clue.RED
clue_display[3].color = clue.RED
alarm = True
else:
data[3].color = clue.WHITE
clue_display[3].color = clue.WHITE

if humidity < min_humidity:
data[5].color = clue.BLUE
clue_display[5].color = clue.BLUE
alarm = True
elif humidity > max_humidity:
data[5].color = clue.RED
clue_display[5].color = clue.RED
alarm = True
else:
data[5].color = clue.WHITE
data.show()
clue_display[5].color = clue.WHITE
clue_display.show()

if alarm and alarm_enable:
clue.start_tone(2000)
Expand Down