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
24 from busdisplay import BusDisplay
25 from busdisplay._displaybus import _DisplayBus
26 from epaperdisplay import EPaperDisplay
27 from ._bitmap import Bitmap
28 from ._colorspace import Colorspace
29 from ._colorconverter import ColorConverter
30 from ._group import Group
31 from ._ondiskbitmap import OnDiskBitmap
32 from ._palette import Palette
33 from ._tilegrid import TileGrid
34 from ._constants import CIRCUITPY_DISPLAY_LIMIT
36 # 8.x Backwards compatibility, remove at 10.x or
37 # when compatibility is removed from core displayio
39 FourWire = fourwire.FourWire
40 I2CDisplay = i2cdisplaybus.I2CDisplayBus
42 __version__ = "0.0.0+auto.0"
43 __repo__ = "https://github.com/adafruit/Adafruit_Blinka_displayio.git"
51 """Main thread function to loop through all displays and update them"""
53 for display in displays:
54 display._background() # pylint: disable=protected-access
57 def release_displays() -> None:
58 """Releases any actively used displays so their busses and pins can be used again.
60 Use this once in your code.py if you initialize a display. Place it right before the
61 initialization so the display is active as long as possible.
63 for display in displays:
64 display._release() # pylint: disable=protected-access
67 for display_bus in display_buses:
72 def allocate_display(new_display: Union[BusDisplay, EPaperDisplay]) -> None:
73 """Add a display to the displays pool and return the new display"""
74 if len(displays) >= CIRCUITPY_DISPLAY_LIMIT:
75 raise RuntimeError("Too many displays")
76 displays.append(new_display)
79 def allocate_display_bus(new_display_bus: _DisplayBus) -> None:
80 """Add a display bus to the display_buses pool and return the new display bus"""
81 if len(display_buses) >= CIRCUITPY_DISPLAY_LIMIT:
83 "Too many display busses; forgot displayio.release_displays() ?"
85 display_buses.append(new_display_bus)
88 background_thread = threading.Thread(target=_background, daemon=True)
91 # Start the background thread
92 def _start_background():
93 if not background_thread.is_alive():
94 background_thread.start()
97 def _stop_background():
98 if background_thread.is_alive():
100 background_thread.join()