Skip to content

Commit 045afc1

Browse files
authored
Merge pull request #2912 from FoamyGuy/tft_spirit_board
Spirit Board Improvements
2 parents 41f3f0f + 8a7026c commit 045afc1

File tree

6 files changed

+51
-18
lines changed

6 files changed

+51
-18
lines changed

TFT_Spirit_Board/esp32s3_s2_tft_featherwing_480x320/spirit_board.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,8 @@ def write_message(self, message, skip_spaces=True, step_size=6, delay=0.02):
240240
# loop over the words in the message
241241
for index, word in enumerate(message_words):
242242
print(f"index: {index}, word: {word}")
243+
# send it to lowercase to get rid of capital letters
244+
word = word.lower()
243245

244246
# if the current word is one of the full words on the board
245247
if word in SpiritBoard.FULL_WORDS:
@@ -269,12 +271,17 @@ def write_message(self, message, skip_spaces=True, step_size=6, delay=0.02):
269271

270272
# loop over each character in the word
271273
for character in word:
272-
# slide the planchette to the current characters location
273-
self.slide_planchette(SpiritBoard.LOCATIONS[character],
274-
delay=delay, step_size=step_size)
275-
276-
# pause after we arrive
277-
time.sleep(0.5)
274+
# if the character is in our locations mapping
275+
if character in SpiritBoard.LOCATIONS:
276+
# slide the planchette to the current characters location
277+
self.slide_planchette(SpiritBoard.LOCATIONS[character],
278+
delay=delay, step_size=step_size)
279+
280+
# pause after we arrive
281+
time.sleep(0.5)
282+
else:
283+
# character is not in our mapping
284+
print(f"Skipping '{character}', it's not on the board.")
278285

279286
# if we are not skipping spaces, and we are not done with the message
280287
if not skip_spaces and index < len(message_words) - 1:
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
hello world
2+
spirits are near
3+
i <3 circuitpython
4+
goodbye

TFT_Spirit_Board/pyportal/spirit_board.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,8 @@ def write_message(self, message, skip_spaces=True, step_size=6, delay=0.02):
240240
# loop over the words in the message
241241
for index, word in enumerate(message_words):
242242
print(f"index: {index}, word: {word}")
243+
# send it to lowercase to get rid of capital letters
244+
word = word.lower()
243245

244246
# if the current word is one of the full words on the board
245247
if word in SpiritBoard.FULL_WORDS:
@@ -269,12 +271,17 @@ def write_message(self, message, skip_spaces=True, step_size=6, delay=0.02):
269271

270272
# loop over each character in the word
271273
for character in word:
272-
# slide the planchette to the current characters location
273-
self.slide_planchette(SpiritBoard.LOCATIONS[character],
274-
delay=delay, step_size=step_size)
275-
276-
# pause after we arrive
277-
time.sleep(0.5)
274+
# if the character is in our locations mapping
275+
if character in SpiritBoard.LOCATIONS:
276+
# slide the planchette to the current characters location
277+
self.slide_planchette(SpiritBoard.LOCATIONS[character],
278+
delay=delay, step_size=step_size)
279+
280+
# pause after we arrive
281+
time.sleep(0.5)
282+
else:
283+
# character is not in our mapping
284+
print(f"Skipping '{character}', it's not on the board.")
278285

279286
# if we are not skipping spaces, and we are not done with the message
280287
if not skip_spaces and index < len(message_words) - 1:
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
hello world
2+
spirits are near
3+
i <3 circuitpython
4+
goodbye

TFT_Spirit_Board/pyportal_titano/spirit_board.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,8 @@ def write_message(self, message, skip_spaces=True, step_size=6, delay=0.02):
240240
# loop over the words in the message
241241
for index, word in enumerate(message_words):
242242
print(f"index: {index}, word: {word}")
243+
# send it to lowercase to get rid of capital letters
244+
word = word.lower()
243245

244246
# if the current word is one of the full words on the board
245247
if word in SpiritBoard.FULL_WORDS:
@@ -269,12 +271,17 @@ def write_message(self, message, skip_spaces=True, step_size=6, delay=0.02):
269271

270272
# loop over each character in the word
271273
for character in word:
272-
# slide the planchette to the current characters location
273-
self.slide_planchette(SpiritBoard.LOCATIONS[character],
274-
delay=delay, step_size=step_size)
275-
276-
# pause after we arrive
277-
time.sleep(0.5)
274+
# if the character is in our locations mapping
275+
if character in SpiritBoard.LOCATIONS:
276+
# slide the planchette to the current characters location
277+
self.slide_planchette(SpiritBoard.LOCATIONS[character],
278+
delay=delay, step_size=step_size)
279+
280+
# pause after we arrive
281+
time.sleep(0.5)
282+
else:
283+
# character is not in our mapping
284+
print(f"Skipping '{character}', it's not on the board.")
278285

279286
# if we are not skipping spaces, and we are not done with the message
280287
if not skip_spaces and index < len(message_words) - 1:
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
hello world
2+
spirits are near
3+
i <3 circuitpython
4+
goodbye

0 commit comments

Comments
 (0)