@@ -117,7 +117,7 @@ def __init__(self):
117
117
def load_game (self , game_directory ):
118
118
"""Load a game.
119
119
120
- :param game_directory: where the game files are stored
120
+ :param str game_directory: where the game files are stored
121
121
"""
122
122
self ._gamedirectory = game_directory
123
123
self ._text_font = terminalio .FONT
@@ -286,7 +286,7 @@ def _wait_for_press(self, card):
286
286
def display_card (self , card_num ):
287
287
"""Display and handle input on a card.
288
288
289
- :param card_num: the index of the card to process
289
+ :param int card_num: the index of the card to process
290
290
"""
291
291
card = self ._game [card_num ]
292
292
print (card )
@@ -324,9 +324,10 @@ def display_card(self, card_num):
324
324
def play_sound (self , filename , * , wait_to_finish = True , loop = False ):
325
325
"""Play a sound
326
326
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
330
331
"""
331
332
self ._speaker_enable .value = False
332
333
self .audio .stop ()
@@ -358,8 +359,8 @@ def play_sound(self, filename, *, wait_to_finish=True, loop=False):
358
359
def set_text (self , text , color ):
359
360
"""Display the test for a card.
360
361
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
363
364
364
365
"""
365
366
if self ._text_group :
@@ -389,7 +390,9 @@ def set_text(self, text, color):
389
390
def set_background (self , filename , * , with_fade = True ):
390
391
"""The background image to a bitmap file.
391
392
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.
393
396
"""
394
397
print ("Set background to" , filename )
395
398
if with_fade :
@@ -401,6 +404,7 @@ def set_background(self, filename, *, with_fade=True):
401
404
if self ._background_file :
402
405
self ._background_file .close ()
403
406
self ._background_file = open (self ._gamedirectory + "/" + filename , "rb" )
407
+ # TODO: Once CP6 is no longer supported, pass the combined filename into OnDiskBitmap
404
408
background = displayio .OnDiskBitmap (self ._background_file )
405
409
self ._background_sprite = displayio .TileGrid (
406
410
background ,
@@ -416,10 +420,15 @@ def set_background(self, filename, *, with_fade=True):
416
420
self .backlight_fade (1.0 )
417
421
418
422
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
+ """
420
429
from_light = self ._display .brightness
421
430
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 ) ))
423
432
delta = 1
424
433
if from_light > to_light :
425
434
delta = - 1
0 commit comments