/ adafruit_st7789.py
adafruit_st7789.py
1 # The MIT License (MIT) 2 # 3 # Copyright (c) 2019 Melissa LeBlanc-Williams for Adafruit Industries LLC 4 # 5 # Permission is hereby granted, free of charge, to any person obtaining a copy 6 # of this software and associated documentation files (the "Software"), to deal 7 # in the Software without restriction, including without limitation the rights 8 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 # copies of the Software, and to permit persons to whom the Software is 10 # furnished to do so, subject to the following conditions: 11 # 12 # The above copyright notice and this permission notice shall be included in 13 # all copies or substantial portions of the Software. 14 # 15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 # THE SOFTWARE. 22 """ 23 `adafruit_st7789` 24 ==================================================== 25 26 Displayio driver for ST7789 based displays. 27 28 * Author(s): Melissa LeBlanc-Williams 29 30 Implementation Notes 31 -------------------- 32 33 **Hardware:** 34 35 * Adafruit 1.3" 240x240 Wide Angle TFT LCD Display with MicroSD - ST7789: 36 https://www.adafruit.com/product/4313 37 38 * Adafruit 1.54" 240x240 Wide Angle TFT LCD Display with MicroSD - ST7789: 39 https://www.adafruit.com/product/3787 40 41 * Adafruit 1.14" 240x135 Color TFT Display + MicroSD Card Breakout - ST7789: 42 https://www.adafruit.com/product/4383 43 44 * Adafruit Mini PiTFT 1.3" - 240x240 TFT Add-on for Raspberry Pi: 45 https://www.adafruit.com/product/4484 46 47 * Adafruit 1.3" Color TFT Bonnet for Raspberry Pi - 240x240 TFT + Joystick Add-on 48 https://www.adafruit.com/product/4506 49 50 * Adafruit Mini PiTFT - 135x240 Color TFT Add-on for Raspberry Pi: 51 https://www.adafruit.com/product/4393 52 53 **Software and Dependencies:** 54 55 * Adafruit CircuitPython firmware for the supported boards: 56 https://github.com/adafruit/circuitpython/releases 57 58 """ 59 60 import displayio 61 62 __version__ = "0.0.0-auto.0" 63 __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_ST7789.git" 64 65 _INIT_SEQUENCE = ( 66 b"\x01\x80\x96" # _SWRESET and Delay 150ms 67 b"\x11\x80\xFF" # _SLPOUT and Delay 500ms 68 b"\x3A\x81\x55\x0A" # _COLMOD and Delay 10ms 69 b"\x36\x01\x08" # _MADCTL 70 b"\x21\x80\x0A" # _INVON Hack and Delay 10ms 71 b"\x13\x80\x0A" # _NORON and Delay 10ms 72 b"\x36\x01\xC0" # _MADCTL 73 b"\x29\x80\xFF" # _DISPON and Delay 500ms 74 ) 75 76 # pylint: disable=too-few-public-methods 77 class ST7789(displayio.Display): 78 """ST7789 driver""" 79 80 def __init__(self, bus, **kwargs): 81 super().__init__(bus, _INIT_SEQUENCE, **kwargs)