adafruit_pyoa

A CircuitPython ‘Choose Your Own Adventure’ framework for PyPortal.

  • Author(s): Adafruit

Implementation Notes

Hardware:

Software and Dependencies:

class adafruit_pyoa.PYOA_Graphics

A choose your own adventure game framework.

backlight_fade(to_light: float) None

Adjust the TFT backlight. Fade from the current value to the to_light value

Parameters:

to_light (float) – the desired backlight brightness between 0.0 and 1.0.

display_card(card_num: int) int

Display and handle input on a card.

Parameters:

card_num (int) – the index of the card to process

Returns:

the card number of the selected card

Return type:

int

load_game(game_directory: str) None

Load a game.

Parameters:

game_directory (str) – where the game files are stored

play_sound(filename: str | None, *, wait_to_finish: bool = True, loop: bool = False) None

Play a sound

Parameters:
  • filename (str or None) – The filename of the sound to play. Use None to stop playing anything.

  • wait_to_finish (bool) – Whether playing the sound should block

  • loop (bool) – Whether the sound should loop

set_background(filename: str | None, *, with_fade: bool = True) None

The background image to a bitmap file.

Parameters:
  • filename (str or None) – The filename of the chosen background

  • with_fade (bool) – If True fade out the backlight while loading the new background and fade in the backlight once completed.

set_text(text: str | None, color: str | None, background_color: int | None = None) None

Display the test for a card.

Parameters:
  • text (str or None) – the text to display

  • color (str or None) – the text color

  • background_color (int or None) – the background color of the text

static wrap_nicely(string: str, max_chars: int) List[str]

A helper that will return a list of lines with word-break wrapping.

Parameters:
  • string (str) – The text to be wrapped.

  • max_chars (int) – The maximum number of characters on a line before wrapping.

Returns:

The list of lines

Return type:

list(str)