Skip to content

Commit e421aaa

Browse files
authored
Merge pull request #38 from makermelissa/main
Update examples and use deepsleep
2 parents edc9830 + f33a868 commit e421aaa

File tree

2 files changed

+8
-20
lines changed

2 files changed

+8
-20
lines changed

examples/magtag_bitcoin_demo.py

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries
22
#
33
# SPDX-License-Identifier: Unlicense
4-
import time
5-
import terminalio
64
from adafruit_magtag.magtag import MagTag
75

86
# Set up where we'll be fetching data from
@@ -22,7 +20,6 @@ def text_transform(val):
2220
magtag.network.connect()
2321

2422
magtag.add_text(
25-
text_font=terminalio.FONT,
2623
text_position=(
2724
(magtag.graphics.display.width // 2) - 1,
2825
(magtag.graphics.display.height // 2) - 1,
@@ -32,16 +29,9 @@ def text_transform(val):
3229
text_anchor_point=(0.5, 0.5),
3330
)
3431

35-
magtag.preload_font(b"$012345789") # preload numbers
36-
magtag.preload_font((0x00A3, 0x20AC)) # preload gbp/euro symbol
37-
38-
timestamp = None
39-
40-
while True:
41-
if not timestamp or (time.monotonic() - timestamp) > 60: # once every 60 seconds...
42-
try:
43-
value = magtag.fetch()
44-
print("Response is", value)
45-
except (ValueError, RuntimeError) as e:
46-
print("Some error occured, retrying! -", e)
47-
timestamp = time.monotonic()
32+
try:
33+
value = magtag.fetch()
34+
print("Response is", value)
35+
except (ValueError, RuntimeError) as e:
36+
print("Some error occured, retrying! -", e)
37+
magtag.exit_and_deep_sleep(60)

examples/magtag_simpletest.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@
22
#
33
# SPDX-License-Identifier: Unlicense
44
import time
5-
import terminalio
65
from adafruit_magtag.magtag import MagTag
76

87
magtag = MagTag()
98

109
magtag.add_text(
11-
text_font=terminalio.FONT,
1210
text_position=(
1311
50,
1412
(magtag.graphics.display.height // 2) - 1,
@@ -18,13 +16,13 @@
1816

1917
magtag.set_text("Hello World")
2018

21-
buttons = magtag.peripherals.buttons
2219
button_colors = ((255, 0, 0), (255, 150, 0), (0, 255, 255), (180, 0, 255))
2320
button_tones = (1047, 1318, 1568, 2093)
21+
2422
timestamp = time.monotonic()
2523

2624
while True:
27-
for i, b in enumerate(buttons):
25+
for i, b in enumerate(magtag.peripherals.buttons):
2826
if not b.value:
2927
print("Button %c pressed" % chr((ord("A") + i)))
3028
magtag.peripherals.neopixel_disable = False

0 commit comments

Comments
 (0)