/ adafruit_st7735.py
adafruit_st7735.py
1 # The MIT License (MIT) 2 # 3 # Copyright (c) 2019 Scott Shawcroft and Melissa LeBlanc-Williams 4 # for Adafruit Industries LLC 5 # 6 # Permission is hereby granted, free of charge, to any person obtaining a copy 7 # of this software and associated documentation files (the "Software"), to deal 8 # in the Software without restriction, including without limitation the rights 9 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 # copies of the Software, and to permit persons to whom the Software is 11 # furnished to do so, subject to the following conditions: 12 # 13 # The above copyright notice and this permission notice shall be included in 14 # all copies or substantial portions of the Software. 15 # 16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 # THE SOFTWARE. 23 """ 24 `adafruit_st7735` 25 ==================================================== 26 27 Displayio driver for ST7735 based displays. 28 29 * Author(s): Melissa LeBlanc-Williams 30 31 Implementation Notes 32 -------------------- 33 34 **Hardware:** 35 36 **Software and Dependencies:** 37 38 * Adafruit CircuitPython firmware for the supported boards: 39 https://github.com/adafruit/circuitpython/releases 40 41 """ 42 43 import displayio 44 45 __version__ = "0.0.0-auto.0" 46 __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_ST7735.git" 47 48 _INIT_SEQUENCE = ( 49 b"\x01\x80\x32" # _SWRESET and Delay 50ms 50 b"\x11\x80\xFF" # _SLPOUT 51 b"\x3A\x81\x05\x0A" # _COLMOD 52 b"\xB1\x83\x00\x06\x03\x0A" # _FRMCTR1 53 b"\x36\x01\x08" # _MADCTL 54 b"\xB6\x02\x15\x02" # _DISSET5 55 # 1 clk cycle nonoverlap, 2 cycle gate, rise, 3 cycle osc equalize, Fix on VTL 56 b"\xB4\x01\x00" # _INVCTR line inversion 57 b"\xC0\x82\x02\x70\x0A" # _PWCTR1 GVDD = 4.7V, 1.0uA, 10 ms delay 58 b"\xC1\x01\x05" # _PWCTR2 VGH = 14.7V, VGL = -7.35V 59 b"\xC2\x02\x01\x02" # _PWCTR3 Opamp current small, Boost frequency 60 b"\xC5\x82\x3C\x38\x0A" # _VMCTR1 61 b"\xFC\x02\x11\x15" # _PWCTR6 62 b"\xE0\x10\x09\x16\x09\x20\x21\x1B\x13\x19\x17\x15\x1E\x2B\x04\x05\x02\x0E" # _GMCTRP1 Gamma 63 b"\xE1\x90\x0B\x14\x08\x1E\x22\x1D\x18\x1E\x1B\x1A\x24\x2B\x06\x06\x02\x0F\x0A" # _GMCTRN1 64 b"\x13\x80\x0a" # _NORON 65 b"\x29\x80\xFF" # _DISPON 66 ) 67 68 # pylint: disable=too-few-public-methods 69 class ST7735(displayio.Display): 70 """ST7735 driver""" 71 72 def __init__(self, bus, **kwargs): 73 super().__init__(bus, _INIT_SEQUENCE, **kwargs)