hx8353.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.hx8353`
24  ====================================================
25  
26  A simple driver for the HX8353-based displays.
27  
28  * Author(s): Radomir Dopieralski, Michael McWethy
29  """
30  from micropython import const
31  from adafruit_rgb_display.rgb import DisplaySPI
32  
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  _NORON = const(0x13)
39  _INVOFF = const(0x20)
40  _INVON = const(0x21)
41  _DISPOFF = const(0x28)
42  _DISPON = const(0x29)
43  _CASET = const(0x2A)
44  _PASET = const(0x2B)
45  _RAMWR = const(0x2C)
46  _RAMRD = const(0x2E)
47  _MADCTL = const(0x36)
48  _COLMOD = const(0x3A)
49  
50  
51  class HX8353(DisplaySPI):
52      """
53      A simple driver for the HX8353-based displays.
54  
55      >>> import busio
56      >>> import digitalio
57      >>> import board
58      >>> from adafruit_rgb_display import color565
59      >>> import adafruit_rgb_display.hx8353 as hx8353
60      >>> spi = busio.SPI(clock=board.SCK, MOSI=board.MOSI, MISO=board.MISO)
61      >>> display = hx8353.HX8383(spi, cs=digitalio.DigitalInOut(board.GPIO0),
62      ...    dc=digitalio.DigitalInOut(board.GPIO15))
63      >>> display.fill(0x7521)
64      >>> display.pixel(64, 64, 0)
65      """
66  
67      _COLUMN_SET = _CASET
68      _PAGE_SET = _PASET
69      _RAM_WRITE = _RAMWR
70      _RAM_READ = _RAMRD
71      _INIT = (
72          (_SWRESET, None),
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=128, rotation=0):
80          super().__init__(spi, dc, cs, rst, width, height, rotation)