Skip to content

Commit 1061307

Browse files
committed
added long word modifier, maintainability enhancements
1 parent 3ecd7c5 commit 1061307

File tree

1 file changed

+13
-9
lines changed
  • adafruit-esp32-s3-tft-feather/circuitpython/popcorn_reader

1 file changed

+13
-9
lines changed

adafruit-esp32-s3-tft-feather/circuitpython/popcorn_reader/code.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010
version = "0.0.3"
1111

1212
# reading parameters
13-
words_per_minute = 260
13+
words_per_minute = 280
1414
sentence_pause = 1.2
1515
comma_pause = 0.4
16+
long_word_modifier = 1.5
1617

1718
word_pause = 60 / words_per_minute
1819

@@ -29,7 +30,7 @@
2930
# font paths
3031
splash_font_path = "/fonts/Comforta-Regular-20.bdf"
3132
reader_font_path = "/fonts/SourceCodePro-Regular-18.bdf"
32-
author_font_path = "/fonts/Comforta-Regular-20.bdf"
33+
author_font_path = "/fonts/Comforta-Regular-16.bdf"
3334

3435
# message to display
3536
messages = []
@@ -39,10 +40,10 @@
3940
authors.append("Osho")
4041

4142
messages.append("\"Physical concepts are free creations of the human mind, and are not, however it may seem, uniquely determined by the external world. In our endeavor to understand reality we are somewhat like a man trying to understand the mechanism of a closed watch. He sees the face and the moving hands, even hears its ticking, but he has no way of opening the case. If he is ingenious, he may form some picture of a mechanism which could be responsible for all the things he observes, but he may never be quite sure his picture is the only one which could explain his observations. He will never be able to compare his picture with the real mechanism and he cannot even imagine the possibility or the meaning of such a comparison.\"")
42-
authors.append("A. Einstein")
43+
authors.append("Albert Einstein")
4344

4445
messages.append("\"You think your pain and your heartbreak are un- precedented in the history of the world, but then you read. It was books that taught me that the things that tormented me most were the very things that connected me with all the people who were alive, who had ever been alive.\"")
45-
authors.append("J. Baldwin")
46+
authors.append("James Baldwin")
4647

4748
# set up display
4849
display = displayio.Group()
@@ -59,7 +60,7 @@
5960
text="",
6061
color=splash_font_color,
6162
anchor_point=(0.0, 0.5),
62-
anchored_position=(24, screen_height//2),
63+
anchored_position=(screen_width//10, screen_height//2),
6364
)
6465
reader_label = label.Label(
6566
reader_font,
@@ -73,7 +74,7 @@
7374
text="",
7475
color=author_font_color,
7576
anchor_point=(0.0, 0.5),
76-
anchored_position=(24, screen_height//2),
77+
anchored_position=(screen_width//10, screen_height//2),
7778
)
7879
version_label = label.Label(
7980
terminalio.FONT,
@@ -88,7 +89,7 @@
8889
text="",
8990
color=0x000000,
9091
anchor_point=(0.0, 0.5),
91-
anchored_position=(24, screen_height//2),
92+
anchored_position=(screen_width//10, screen_height//2),
9293
)
9394
cache_reader_label = label.Label(
9495
reader_font,
@@ -102,7 +103,7 @@
102103
text="",
103104
color=0x000000,
104105
anchor_point=(0.0, 0.5),
105-
anchored_position=(24, screen_height//2),
106+
anchored_position=(screen_width//10, screen_height//2),
106107
)
107108

108109
display.append(splash_label)
@@ -161,8 +162,11 @@ def display_typed_text(label, text, delay=0.05, cache_label=None):
161162
time.sleep(sentence_pause)
162163
elif word[-1] in {",", ":"}:
163164
time.sleep(comma_pause)
165+
elif len(word) > 8:
166+
time.sleep(word_pause * long_word_modifier)
167+
else:
168+
time.sleep(word_pause)
164169

165-
time.sleep(word_pause)
166170
time.sleep(0.8)
167171

168172
clear_display(1)

0 commit comments

Comments
 (0)