/ adafruit_hx8357.py
adafruit_hx8357.py
 1  # The MIT License (MIT)
 2  #
 3  # Copyright (c) 2019 Melissa LeBlanc-Williams for Adafruit Industries
 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_hx8357`
24  ================================================================================
25  
26  displayio driver for HX8357 Displays such as the 3.5-inch TFT FeatherWing and Breakout
27  
28  * Author(s): Melissa LeBlanc-Williams
29  
30  Implementation Notes
31  --------------------
32  
33  **Hardware:**
34  
35  * 3.5" PiTFT Plus 480x320 3.5" TFT+Touchscreen for Raspberry Pi:
36    <https://www.adafruit.com/product/2441>
37  * 3.5" TFT 320x480 + Touchscreen Breakout Board w/MicroSD Socket:
38    <https://www.adafruit.com/product/2050>
39  * Adafruit TFT FeatherWing - 3.5" 480x320 Touchscreen for Feathers:
40    <https://www.adafruit.com/product/3651>
41  
42  **Software and Dependencies:**
43  
44  * Adafruit CircuitPython firmware for the supported boards:
45    https://github.com/adafruit/circuitpython/releases
46  """
47  
48  # imports
49  
50  import displayio
51  
52  __version__ = "0.0.0-auto.0"
53  __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_HX8357.git"
54  
55  _INIT_SEQUENCE = (
56      b"\x01\x80\x64"  # _SWRESET and Delay 100ms
57      b"\xB9\x83\xFF\x83\x57\xFF"  # _SETC and delay 500ms
58      b"\xB3\x04\x80\x00\x06\x06"  # _SETRGB 0x80 enables SDO pin (0x00 disables)
59      b"\xB6\x01\x25"  # _SETCOM -1.52V
60      b"\xB0\x01\x68"  # _SETOSC Normal mode 70Hz, Idle mode 55 Hz
61      b"\xCC\x01\x05"  # _SETPANEL BGR, Gate direction swapped
62      b"\xB1\x06\x00\x15\x1C\x1C\x83\xAA"  # _SETPWR1 Not deep standby BT VSPR VSNR AP
63      b"\xC0\x06\x50\x50\x01\x3C\x1E\x08"  # _SETSTBA OPON normal OPON idle STBA GEN
64      b"\xB4\x07\x02\x40\x00\x2A\x2A\x0D\x78"  # _SETCYC NW 0x02 RTN DIV DUM DUM GDON GDOFF
65      b"\xE0\x22\x02\x0A\x11\x1d\x23\x35\x41\x4b\x4b\x42\x3A\x27\x1B\x08\x09\x03\x02\x0A"
66      b"\x11\x1d\x23\x35\x41\x4b\x4b\x42\x3A\x27\x1B\x08\x09\x03\x00\x01"  # _SETGAMMA
67      b"\x3A\x01\x55"  # _COLMOD 16 bit
68      b"\x36\x01\xC0"  # _MADCTL
69      b"\x35\x01\x00"  # _TEON TW off
70      b"\x44\x02\x00\x02"  # _TEARLINE
71      b"\x11\x80\x96"  # _SLPOUT and delay 150 ms
72      b"\x36\x01\xA0"
73      b"\x29\x80\x32"  # _DISPON and delay 50 ms
74  )
75  
76  # pylint: disable=too-few-public-methods
77  class HX8357(displayio.Display):
78      """HX8357D driver"""
79  
80      def __init__(self, bus, **kwargs):
81          super().__init__(bus, _INIT_SEQUENCE, **kwargs)