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
 
  21 from busdisplay import BusDisplay
 
  22 from busdisplay._displaybus import _DisplayBus
 
  23 from epaperdisplay import EPaperDisplay
 
  24 from ._bitmap import Bitmap
 
  25 from ._colorspace import Colorspace
 
  26 from ._colorconverter import ColorConverter
 
  27 from ._group import Group
 
  28 from ._ondiskbitmap import OnDiskBitmap
 
  29 from ._palette import Palette
 
  30 from ._tilegrid import TileGrid
 
  31 from ._constants import CIRCUITPY_DISPLAY_LIMIT
 
  33 __version__ = "0.0.0+auto.0"
 
  34 __repo__ = "https://github.com/adafruit/Adafruit_Blinka_displayio.git"
 
  42     """Main thread function to loop through all displays and update them"""
 
  44         for display in displays:
 
  45             display._background()  # pylint: disable=protected-access
 
  48 def release_displays() -> None:
 
  49     """Releases any actively used displays so their busses and pins can be used again.
 
  51     Use this once in your code.py if you initialize a display. Place it right before the
 
  52     initialization so the display is active as long as possible.
 
  54     for display in displays:
 
  55         display._release()  # pylint: disable=protected-access
 
  58     for display_bus in display_buses:
 
  63 def allocate_display(new_display: Union[BusDisplay, EPaperDisplay]) -> None:
 
  64     """Add a display to the displays pool and return the new display"""
 
  65     if len(displays) >= CIRCUITPY_DISPLAY_LIMIT:
 
  66         raise RuntimeError("Too many displays")
 
  67     displays.append(new_display)
 
  70 def allocate_display_bus(new_display_bus: _DisplayBus) -> None:
 
  71     """Add a display bus to the display_buses pool and return the new display bus"""
 
  72     if len(display_buses) >= CIRCUITPY_DISPLAY_LIMIT:
 
  74             "Too many display busses; forgot displayio.release_displays() ?"
 
  76     display_buses.append(new_display_bus)
 
  79 background_thread = threading.Thread(target=_background, daemon=True)
 
  82 # Start the background thread
 
  83 def _start_background():
 
  84     if not background_thread.is_alive():
 
  85         background_thread.start()
 
  88 def _stop_background():
 
  89     if background_thread.is_alive():
 
  91         background_thread.join()