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