1 # SPDX-FileCopyrightText: 2020 Melissa LeBlanc-Williams for Adafruit Industries
3 # SPDX-License-Identifier: MIT
7 ================================================================================
11 **Software and Dependencies:**
14 https://github.com/adafruit/Adafruit_Blinka/releases
16 * Author(s): Melissa LeBlanc-Williams
20 from typing import Union
22 from ._bitmap import Bitmap
23 from ._colorspace import Colorspace
24 from ._colorconverter import ColorConverter
25 from ._group import Group
26 from ._ondiskbitmap import OnDiskBitmap
27 from ._palette import Palette
28 from ._tilegrid import TileGrid
29 from ._constants import CIRCUITPY_DISPLAY_LIMIT
32 __version__ = "0.0.0+auto.0"
33 __repo__ = "https://github.com/adafruit/Adafruit_Blinka_displayio.git"
41 """Main thread function to loop through all displays and update them"""
43 for display in displays:
44 display._background() # pylint: disable=protected-access
47 def release_displays() -> None:
48 """Releases any actively used displays so their busses and pins can be used again.
50 Use this once in your code.py if you initialize a display. Place it right before the
51 initialization so the display is active as long as possible.
53 for display in displays:
54 display._release() # pylint: disable=protected-access
57 for display_bus in display_buses:
63 new_display: Union["busdisplay.BusDisplay", "epaperdisplay.EPaperDisplay"]
65 """Add a display to the displays pool and return the new display"""
66 if len(displays) >= CIRCUITPY_DISPLAY_LIMIT:
67 raise RuntimeError("Too many displays")
68 displays.append(new_display)
71 def allocate_display_bus(new_display_bus: "busdisplay._displaybus._DisplayBus") -> None:
72 """Add a display bus to the display_buses pool and return the new display bus"""
73 if len(display_buses) >= CIRCUITPY_DISPLAY_LIMIT:
75 "Too many display busses; forgot displayio.release_displays() ?"
77 display_buses.append(new_display_bus)
80 background_thread = threading.Thread(target=_background, daemon=True)
83 # Start the background thread
84 def _start_background():
85 if not background_thread.is_alive():
86 background_thread.start()
89 def _stop_background():
90 if background_thread.is_alive():
92 background_thread.join()