Skip to content

Commit a805d08

Browse files
authored
Merge pull request #45 from lastcoolnameleft/patch-1
Update readme with simpler Hello World
2 parents b4253b4 + ca5cafc commit a805d08

File tree

1 file changed

+18
-37
lines changed

1 file changed

+18
-37
lines changed

README.rst

Lines changed: 18 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -41,51 +41,32 @@ Usage Example
4141
import terminalio
4242
from adafruit_matrixportal.matrixportal import MatrixPortal
4343
44-
# You can display in 'GBP', 'EUR' or 'USD'
45-
CURRENCY = "USD"
46-
# Set up where we'll be fetching data from
47-
DATA_SOURCE = "https://api.coindesk.com/v1/bpi/currentprice.json"
48-
DATA_LOCATION = ["bpi", CURRENCY, "rate_float"]
49-
50-
51-
def text_transform(val):
52-
if CURRENCY == "USD":
53-
return "$%d" % val
54-
if CURRENCY == "EUR":
55-
return "‎€%d" % val
56-
if CURRENCY == "GBP":
57-
return "£%d" % val
58-
return "%d" % val
59-
60-
61-
# the current working directory (where this file is)
62-
cwd = ("/" + __file__).rsplit("/", 1)[0]
63-
64-
matrixportal = MatrixPortal(
65-
url=DATA_SOURCE,
66-
json_path=DATA_LOCATION,
67-
status_neopixel=board.NEOPIXEL,
68-
debug=True,
69-
)
44+
# --- Display setup ---
45+
matrixportal = MatrixPortal(status_neopixel=board.NEOPIXEL, debug=True)
7046
47+
# Create a new label with the color and text selected
7148
matrixportal.add_text(
7249
text_font=terminalio.FONT,
73-
text_position=(16, 16),
74-
text_color=0xFFFFFF,
75-
text_transform=text_transform,
50+
text_position=(0, (matrixportal.graphics.display.height // 2) - 1),
51+
scrolling=True,
7652
)
77-
matrixportal.preload_font(b"$012345789") # preload numbers
78-
matrixportal.preload_font((0x00A3, 0x20AC)) # preload gbp/euro symbol
53+
54+
SCROLL_DELAY = 0.03
55+
56+
contents = [
57+
{ 'text': 'THIS IS RED', 'color': '#cf2727'},
58+
{ 'text': 'THIS IS BLUE', 'color': '#0846e4'},
59+
]
7960
8061
while True:
81-
try:
82-
value = matrixportal.fetch()
83-
print("Response is", value)
84-
except (ValueError, RuntimeError) as e:
85-
print("Some error occured, retrying! -", e)
62+
for content in contents:
63+
matrixportal.set_text(content['text'])
8664
87-
time.sleep(3 * 60) # wait 3 minutes
65+
# Set the text color
66+
matrixportal.set_text_color(content['color'])
8867
68+
# Scroll it
69+
matrixportal.scroll_text(SCROLL_DELAY)
8970
9071
Contributing
9172
============

0 commit comments

Comments
 (0)