Skip to content

Commit 192bb86

Browse files
Update comments
1 parent af96085 commit 192bb86

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

adafruit_pyoa.py

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def __init__(self):
117117
def load_game(self, game_directory):
118118
"""Load a game.
119119
120-
:param game_directory: where the game files are stored
120+
:param str game_directory: where the game files are stored
121121
"""
122122
self._gamedirectory = game_directory
123123
self._text_font = terminalio.FONT
@@ -286,7 +286,7 @@ def _wait_for_press(self, card):
286286
def display_card(self, card_num):
287287
"""Display and handle input on a card.
288288
289-
:param card_num: the index of the card to process
289+
:param int card_num: the index of the card to process
290290
"""
291291
card = self._game[card_num]
292292
print(card)
@@ -324,9 +324,10 @@ def display_card(self, card_num):
324324
def play_sound(self, filename, *, wait_to_finish=True, loop=False):
325325
"""Play a sound
326326
327-
:param filename: The filename of the sound to play
328-
:param wait_to_finish: Whether playing the sound should block
329-
:param loop: Whether the sound should loop
327+
:param Union(None,str) filename: The filename of the sound to play. Use `None` to stop
328+
playing anything.
329+
:param bool wait_to_finish: Whether playing the sound should block
330+
:param bool loop: Whether the sound should loop
330331
"""
331332
self._speaker_enable.value = False
332333
self.audio.stop()
@@ -358,8 +359,8 @@ def play_sound(self, filename, *, wait_to_finish=True, loop=False):
358359
def set_text(self, text, color):
359360
"""Display the test for a card.
360361
361-
:param text: the text to display
362-
:param color: the text color
362+
:param Union(None,str) text: the text to display
363+
:param Union(None,int) color: the text color
363364
364365
"""
365366
if self._text_group:
@@ -389,7 +390,9 @@ def set_text(self, text, color):
389390
def set_background(self, filename, *, with_fade=True):
390391
"""The background image to a bitmap file.
391392
392-
:param filename: The filename of the chosen background
393+
:param Union(None,str) filename: The filename of the chosen background
394+
:param bool with_fade: If `True` fade out the backlight while loading the new background
395+
and fade in the backlight once completed.
393396
"""
394397
print("Set background to", filename)
395398
if with_fade:
@@ -401,6 +404,7 @@ def set_background(self, filename, *, with_fade=True):
401404
if self._background_file:
402405
self._background_file.close()
403406
self._background_file = open(self._gamedirectory + "/" + filename, "rb")
407+
# TODO: Once CP6 is no longer supported, pass the combined filename into OnDiskBitmap
404408
background = displayio.OnDiskBitmap(self._background_file)
405409
self._background_sprite = displayio.TileGrid(
406410
background,
@@ -416,10 +420,15 @@ def set_background(self, filename, *, with_fade=True):
416420
self.backlight_fade(1.0)
417421

418422
def backlight_fade(self, to_light):
419-
"""Adjust the TFT backlight. Fade from one value to another"""
423+
"""
424+
Adjust the TFT backlight. Fade from the current value to the ``to_light`` value
425+
426+
:param float to_light: the desired backlight brightness between :py:const:`0.0` and
427+
:py:const:`1.0`.
428+
"""
420429
from_light = self._display.brightness
421430
from_light = int(from_light * 100)
422-
to_light = max(0, min(100, to_light * 100))
431+
to_light = max(0, min(100, int(to_light * 100)))
423432
delta = 1
424433
if from_light > to_light:
425434
delta = -1

0 commit comments

Comments
 (0)