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