/ adafruit_rgb_display / s6d02a1.py
s6d02a1.py
 1  # The MIT License (MIT)
 2  #
 3  # Copyright (c) 2017 Radomir Dopieralski and 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_rgb_display.s6d02a1`
24  ====================================================
25  
26  A simple driver for the S6D02A1-based displays.
27  
28  * Author(s): Radomir Dopieralski, Michael McWethy
29  """
30  
31  from micropython import const
32  from adafruit_rgb_display.rgb import DisplaySPI
33  
34  __version__ = "0.0.0-auto.0"
35  __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_RGB_Display.git"
36  
37  _SWRESET = const(0x01)
38  _DISPON = const(0x29)
39  _SLEEPOUT = const(0x11)
40  _CASET = const(0x2A)
41  _PASET = const(0x2B)
42  _RAMWR = const(0x2C)
43  _RAMRD = const(0x2E)
44  _COLMOD = const(0x3A)
45  _MADCTL = const(0x36)
46  
47  
48  class S6D02A1(DisplaySPI):
49      """
50      A simple driver for the S6D02A1-based displays.
51  
52      >>> import busio
53      >>> import digitalio
54      >>> import board
55      >>> from adafruit_rgb_display import color565
56      >>> import adafruit_rgb_display.s6d02a1 as s6d02a1
57      >>> spi = busio.SPI(clock=board.SCK, MOSI=board.MOSI, MISO=board.MISO)
58      >>> display = s6d02a1.S6D02A1(spi, cs=digitalio.DigitalInOut(board.GPIO0),
59      ...    dc=digitalio.DigitalInOut(board.GPIO15), rst=digitalio.DigitalInOut(board.GPIO16))
60      >>> display.fill(0x7521)
61      >>> display.pixel(64, 64, 0)
62      """
63  
64      _COLUMN_SET = _CASET
65      _PAGE_SET = _PASET
66      _RAM_WRITE = _RAMWR
67      _RAM_READ = _RAMRD
68      _INIT = (
69          (_SWRESET, None),
70          (_SLEEPOUT, None),
71          (_MADCTL, b"\x10"),  # bottom-top
72          (_COLMOD, b"\x05"),  # RGB565 pixel format
73          (_DISPON, None),
74      )
75      _ENCODE_PIXEL = ">H"
76      _ENCODE_POS = ">HH"
77  
78      # pylint: disable-msg=useless-super-delegation, too-many-arguments
79      def __init__(self, spi, dc, cs, rst=None, width=128, height=160, rotation=0):
80          super().__init__(spi, dc, cs, rst, width, height, rotation)