Skip to content

Prep for publishing as a library and adding to the Bundle #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Jun 18, 2019
17 changes: 13 additions & 4 deletions adafruit_pyoa.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
https://github.com/adafruit/circuitpython/releases
"""

#pylint: disable=too-many-instance-attributes,no-self-use
#pylint: disable=too-many-instance-attributes,no-self-use,line-too-long

# imports
import time
Expand All @@ -59,6 +59,8 @@
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_PYOA.git"

class PYOA_Graphics():
"""A choose your own adventure game framework."""

def __init__(self):
self.root_group = displayio.Group(max_size=15)

Expand Down Expand Up @@ -101,7 +103,8 @@ def __init__(self):

self.touchscreen = adafruit_touchscreen.Touchscreen(board.TOUCH_XL, board.TOUCH_XR,
board.TOUCH_YD, board.TOUCH_YU,
calibration=((5200, 59000), (5800, 57000)),
calibration=((5200, 59000),
(5800, 57000)),
size=(320, 240))
self._gamedirectory = None
self._gamefilename = None
Expand Down Expand Up @@ -131,7 +134,7 @@ def _fade_to_black(self):
# turn off background so we can render the text
self.set_background(None, with_fade=False)
self.set_text(None, None)
for i in range(len(self._button_group)):
for _ in range(len(self._button_group)):
self._button_group.pop()

def _display_buttons(self, card):
Expand Down Expand Up @@ -251,7 +254,7 @@ def display_card(self, card_num):
if page_struct.get('page_id', None) == destination_page_id:
return page_number # found the matching card!
# eep if we got here something went wrong
raise RuntimeError("Could not find card with matching 'page_id': ", goto_page)
raise RuntimeError("Could not find card with matching 'page_id': ", destination_page_id)

def play_sound(self, filename, *, wait_to_finish=True, loop=False):
"""Play a sound
Expand Down Expand Up @@ -289,6 +292,12 @@ def play_sound(self, filename, *, wait_to_finish=True, loop=False):
self._speaker_enable.value = False

def set_text(self, text, color):
"""Display the test for a card.

:param text: the text to display
:param color: the text color

"""
if self._text_group:
self._text_group.pop()
if not text or not color:
Expand Down
6 changes: 4 additions & 2 deletions examples/pyoa_simpletest.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#pylint disable=wrong-import-position
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dont disable this, fix it instead!


import sys
sys.path.append('/Adafruit_CircuitPython_PYOA')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can remove this, its for testing

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, and Travis is green. Have another look.


import board
import digitalio
import adafruit_sdcard
import storage
from adafruit_pyoa import PYOA_Graphics
import board
import digitalio

try:
sdcard = adafruit_sdcard.SDCard(board.SPI(), digitalio.DigitalInOut(board.SD_CS))
Expand Down