Skip to content

Commit

Permalink
feat: let the user render a splash screen before the first frame is r…
Browse files Browse the repository at this point in the history
…eady to be rendered, if not provided, it renders a black screen
  • Loading branch information
sassanh committed May 8, 2024
1 parent a5abbeb commit a155781
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
## Version 0.7.3

- feat: configurable rotation and flip parameters
- feat: let the user render a splash screen before the first frame is ready to be
rendered, if not provided, it renders a black screen

## Version 0.7.2

Expand Down
15 changes: 14 additions & 1 deletion headless_kivy_pi/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,19 @@ def report_uninitialized() -> NoReturn:
raise RuntimeError(msg)


def setup_headless_kivy(config: SetupHeadlessConfig) -> None:
def setup_headless_kivy(
config: SetupHeadlessConfig,
splash_screen: bytes | None = None,
) -> None:
"""Configure the headless mode for the Kivy application.
Arguments:
---------
config: `SetupHeadlessConfig`
splash_screen: `bytes`
it should have a length of `width` x `height` x 2
"""
global _config, _display # noqa: PLW0603
_config = config
Expand Down Expand Up @@ -160,6 +166,13 @@ def setup_headless_kivy(config: SetupHeadlessConfig) -> None:
rst=reset_pin,
baudrate=baudrate,
)
_display._block( # noqa: SLF001
0,
0,
width() - 1,
height() - 1,
bytes(width() * height() * 2) if splash_screen is None else splash_screen,
)
if clear_at_exit:
atexit.register(
lambda: _display
Expand Down

0 comments on commit a155781

Please sign in to comment.