/ adafruit_ili9341.py
adafruit_ili9341.py
1 # The MIT License (MIT) 2 # 3 # Copyright (c) 2019 Scott Shawcroft 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_ili9341` 24 ==================================================== 25 26 Display driver for ILI9341 27 28 * Author(s): Scott Shawcroft 29 30 Implementation Notes 31 -------------------- 32 33 **Hardware:** 34 35 * Adafruit PiTFT 2.2" HAT Mini Kit - 320x240 2.2" TFT - No Touch 36 <https://www.adafruit.com/product/2315> 37 * Adafruit PiTFT 2.4" HAT Mini Kit - 320x240 TFT Touchscreen 38 <https://www.adafruit.com/product/2455> 39 * Adafruit PiTFT - 320x240 2.8" TFT+Touchscreen for Raspberry Pi 40 <https://www.adafruit.com/product/1601> 41 * PiTFT 2.8" TFT 320x240 + Capacitive Touchscreen for Raspberry Pi 42 <https://www.adafruit.com/product/1983> 43 * Adafruit PiTFT Plus 320x240 2.8" TFT + Capacitive Touchscreen 44 <https://www.adafruit.com/product/2423> 45 * PiTFT Plus Assembled 320x240 2.8" TFT + Resistive Touchscreen 46 <https://www.adafruit.com/product/2298> 47 * PiTFT Plus 320x240 3.2" TFT + Resistive Touchscreen 48 <https://www.adafruit.com/product/2616> 49 * 2.2" 18-bit color TFT LCD display with microSD card breakout 50 <https://www.adafruit.com/product/1480> 51 * 2.4" TFT LCD with Touchscreen Breakout Board w/MicroSD Socket 52 <https://www.adafruit.com/product/2478> 53 * 2.8" TFT LCD with Touchscreen Breakout Board w/MicroSD Socket 54 <https://www.adafruit.com/product/1770> 55 * 3.2" TFT LCD with Touchscreen Breakout Board w/MicroSD Socket 56 <https://www.adafruit.com/product/1743> 57 * TFT FeatherWing - 2.4" 320x240 Touchscreen For All Feathers 58 <https://www.adafruit.com/product/3315> 59 60 **Software and Dependencies:** 61 62 * Adafruit CircuitPython firmware for the supported boards: 63 https://github.com/adafruit/circuitpython/releases 64 65 """ 66 67 import displayio 68 69 __version__ = "0.0.0-auto.0" 70 __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_ILI9341.git" 71 72 _INIT_SEQUENCE = ( 73 b"\x01\x80\x80" # Software reset then delay 0x80 (128ms) 74 b"\xEF\x03\x03\x80\x02" 75 b"\xCF\x03\x00\xC1\x30" 76 b"\xED\x04\x64\x03\x12\x81" 77 b"\xE8\x03\x85\x00\x78" 78 b"\xCB\x05\x39\x2C\x00\x34\x02" 79 b"\xF7\x01\x20" 80 b"\xEA\x02\x00\x00" 81 b"\xc0\x01\x23" # Power control VRH[5:0] 82 b"\xc1\x01\x10" # Power control SAP[2:0];BT[3:0] 83 b"\xc5\x02\x3e\x28" # VCM control 84 b"\xc7\x01\x86" # VCM control2 85 b"\x36\x01\x38" # Memory Access Control 86 b"\x37\x01\x00" # Vertical scroll zero 87 b"\x3a\x01\x55" # COLMOD: Pixel Format Set 88 b"\xb1\x02\x00\x18" # Frame Rate Control (In Normal Mode/Full Colors) 89 b"\xb6\x03\x08\x82\x27" # Display Function Control 90 b"\xF2\x01\x00" # 3Gamma Function Disable 91 b"\x26\x01\x01" # Gamma curve selected 92 b"\xe0\x0f\x0F\x31\x2B\x0C\x0E\x08\x4E\xF1\x37\x07\x10\x03\x0E\x09\x00" # Set Gamma 93 b"\xe1\x0f\x00\x0E\x14\x03\x11\x07\x31\xC1\x48\x08\x0F\x0C\x31\x36\x0F" # Set Gamma 94 b"\x11\x80\x78" # Exit Sleep then delay 0x78 (120ms) 95 b"\x29\x80\x78" # Display on then delay 0x78 (120ms) 96 ) 97 98 # pylint: disable=too-few-public-methods 99 class ILI9341(displayio.Display): 100 """ILI9341 display driver""" 101 102 def __init__(self, bus, **kwargs): 103 super().__init__(bus, _INIT_SEQUENCE, **kwargs)