/ adafruit_ssd1351.py
adafruit_ssd1351.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_ssd1351`
24  ================================================================================
25  
26  displayio Driver for SSD1351 Displays
27  
28  
29  * Author(s): Melissa LeBlanc-Williams
30  
31  Implementation Notes
32  --------------------
33  
34  **Hardware:**
35  
36  * OLED Breakout Board - 16-bit Color 1.5" w/microSD holder:
37    https://www.adafruit.com/product/1431
38  * OLED Breakout Board - 16-bit Color 1.27" w/microSD holder:
39    https://www.adafruit.com/product/1673
40  
41  **Software and Dependencies:**
42  
43  * Adafruit CircuitPython firmware for the supported boards:
44    https://github.com/adafruit/circuitpython/releases
45  
46  """
47  
48  import displayio
49  
50  __version__ = "0.0.0-auto.0"
51  __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_SSD1351.git"
52  
53  _INIT_SEQUENCE = (
54      b"\xFD\x01\x12"  # COMMAND_LOCK Unlock IC MCU
55      b"\xFD\x01\xB1"  # COMMAND_LOCK
56      b"\xAE\x00"  # DISPLAY_OFF
57      b"\xB2\x03\xA4\x00\x00"  # DISPLAY_ENHANCEMENT
58      b"\xB3\x01\xF0"  # CLOCK_DIV
59      b"\xCA\x01\x7F"  # MUX_RATIO
60      b"\xA2\x01\x00"  # DISPLAY_OFFSET
61      b"\xB5\x01\x00"  # SET_GPIO
62      b"\xAB\x01\x01"  # FUNCTION_SELECT
63      b"\xB1\x01\x32"  # PRECHARGE
64      b"\xBE\x01\x05"  # VCOMH
65      b"\xA6\x00"  # NORMAL_DISPLAY
66      b"\xC1\x03\xC8\x80\xC8"  # CONTRAST_ABC (RGB)
67      b"\xC7\x01\x0F"  # CONTRAST_MASTER
68      b"\xB4\x03\xA0\xB5\x55"  # SET_VSL Set segment low volt
69      b"\xB6\x01\x01"  # PRECHARGE2
70      b"\xA0\x01\x26"  # Set Color Mode
71      b"\xAF\x00"  # DISPLAY_ON
72  )
73  
74  # pylint: disable=too-few-public-methods
75  class SSD1351(displayio.Display):
76      """SSD1351 driver"""
77  
78      def __init__(self, bus, **kwargs):
79          super().__init__(
80              bus,
81              _INIT_SEQUENCE,
82              **kwargs,
83              set_column_command=0x15,
84              set_row_command=0x75,
85              write_ram_command=0x5C,
86              single_byte_bounds=True,
87          )