-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils_display.py
More file actions
executable file
·59 lines (48 loc) · 2.04 KB
/
Copy pathutils_display.py
File metadata and controls
executable file
·59 lines (48 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# By @howdymoto / Wright Bagwell
# Inspired by TodBot's circuitpython-tricks: https://github.com/todbot/circuitpython-tricks
# And by Adafruit/Kattni Rembor's CircuitPython Essentials: https://learn.adafruit.com/circuitpython-essentials/circuitpython-essentials
# MIT license
"""Helper functions for your board's built-in display."""
import board
# See if the board has a display. If so, show details.
# Almost always set to board.DISPLAY pin
def get_display_info():
"""Check for a builtin or onboard display, and show its details.
Will not show details about a display that you add yourself."""
print("\n=== Built-in Display info ===\n")
if hasattr(board, "DISPLAY"):
print("board.DISPLAY pin found")
display = board.DISPLAY
print(
f"{"size":<20}",
display.width,
"x",
display.height
)
print(f"{"rotation":<20}", display.rotation)
print(f"{"bus":<20}", display.bus)
# Auto-refresh
# Some displays, like epaper, do not have an auto-refresh property
if hasattr(display, 'auto_refresh'):
auto_refresh_attribute = display.auto_refresh
else:
auto_refresh_attribute = "None (probably e-ink)"
print(f"{"auto_refresh":<20}", auto_refresh_attribute)
# Brightness
# Some displays, like epaper, do not have a brightness property
if hasattr(display, 'brightness'):
brightness_attribute = display.brightness
else:
brightness_attribute = "None (probably e-ink)"
print(f"{"brightness":<20}", brightness_attribute)
else:
print("board.DISPLAY pin not found")
def rotate_display(angle):
"""Rotate the built-in display to a specified angle.
Args:
angle (int): Rotation angle in degrees. Valid values are
typically 0, 90, 180, or 270.
"""
display = board.DISPLAY
display.rotation = angle
print("\nDisplay rotated to", angle)