/ adafruit_ssd1608.py
adafruit_ssd1608.py
 1  # The MIT License (MIT)
 2  #
 3  # Copyright (c) 2019 Scott Shawcroft for Adafruit Industries LLC
 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_ssd1608`
24  ================================================================================
25  
26  CircuitPython `displayio` driver for SSD1608-based ePaper displays
27  
28  
29  * Author(s): Scott Shawcroft
30  
31  Implementation Notes
32  --------------------
33  
34  **Hardware:**
35  
36  * `Adafruit 1.54" Monochrome ePaper Display Breakout <https://www.adafruit.com/product/4196>`_
37  
38  **Software and Dependencies:**
39  
40  * Adafruit CircuitPython firmware (version 5+) for the supported boards:
41    https://github.com/adafruit/circuitpython/releases
42  
43  """
44  
45  import displayio
46  
47  __version__ = "0.0.0-auto.0"
48  __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_SSD1608.git"
49  
50  _START_SEQUENCE = (
51      b"\x12\x00"  # Software reset
52      b"\x01\x03\x00\x00\x00"  # driver output control
53      b"\x3a\x01\x1b"  # Set dummy line period
54      b"\x3b\x01\x0b"  # Set gate line width
55      b"\x11\x01\x03"  # Data entry sequence
56      b"\x2c\x01\x70"  # Vcom Voltage
57      b"\x32\x1e\x02\x02\x01\x11\x12\x12\x22\x22\x66\x69\x69\x59\x58\x99\x99\x88\x00\x00\x00\x00\xf8"
58      b"\xb4\x13\x51\x35\x51\x51\x19\x01\x00"  # LUT
59      b"\x22\x01\xc7"  # Set DISP ctrl2
60  )
61  
62  _STOP_SEQUENCE = b"\x10\x01\x01"  # Enter deep sleep
63  
64  # pylint: disable=too-few-public-methods
65  class SSD1608(displayio.EPaperDisplay):
66      """SSD1608 driver"""
67  
68      def __init__(self, bus, **kwargs):
69          start_sequence = bytearray(_START_SEQUENCE)
70          width = kwargs["width"]
71          start_sequence[4] = (width - 1) & 0xFF
72          start_sequence[5] = (width - 1) >> 8
73  
74          super().__init__(
75              bus,
76              start_sequence,
77              _STOP_SEQUENCE,
78              **kwargs,
79              ram_width=240,
80              ram_height=320,
81              set_column_window_command=0x44,
82              set_row_window_command=0x45,
83              set_current_column_command=0x4E,
84              set_current_row_command=0x4F,
85              write_black_ram_command=0x24,
86              refresh_display_command=0x20,
87          )