-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathadafruit_st7789.py
executable file
·72 lines (52 loc) · 2.11 KB
/
adafruit_st7789.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# SPDX-FileCopyrightText: 2019 Melissa LeBlanc-Williams for Adafruit Industries
#
# SPDX-License-Identifier: MIT
"""
`adafruit_st7789`
====================================================
Displayio driver for ST7789 based displays.
* Author(s): Melissa LeBlanc-Williams
Implementation Notes
--------------------
**Hardware:**
* Adafruit 1.3" 240x240 Wide Angle TFT LCD Display with MicroSD - ST7789:
https://www.adafruit.com/product/4313
* Adafruit 1.54" 240x240 Wide Angle TFT LCD Display with MicroSD - ST7789:
https://www.adafruit.com/product/3787
* Adafruit 1.14" 240x135 Color TFT Display + MicroSD Card Breakout - ST7789:
https://www.adafruit.com/product/4383
* Adafruit Mini PiTFT 1.3" - 240x240 TFT Add-on for Raspberry Pi:
https://www.adafruit.com/product/4484
* Adafruit 1.3" Color TFT Bonnet for Raspberry Pi - 240x240 TFT + Joystick Add-on
https://www.adafruit.com/product/4506
* Adafruit Mini PiTFT - 135x240 Color TFT Add-on for Raspberry Pi:
https://www.adafruit.com/product/4393
**Software and Dependencies:**
* Adafruit CircuitPython firmware for the supported boards:
https://github.com/adafruit/circuitpython/releases
"""
# Starting in CircuitPython 9.x fourwire will be a seperate internal library
# rather than a component of the displayio library
try:
from fourwire import FourWire
from busdisplay import BusDisplay
except ImportError:
from displayio import FourWire
from displayio import Display as BusDisplay
__version__ = "0.0.0+auto.0"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_ST7789.git"
_INIT_SEQUENCE = (
b"\x01\x80\x96" # _SWRESET and Delay 150ms
b"\x11\x80\xFF" # _SLPOUT and Delay 500ms
b"\x3A\x81\x55\x0A" # _COLMOD and Delay 10ms
b"\x36\x01\x08" # _MADCTL
b"\x21\x80\x0A" # _INVON Hack and Delay 10ms
b"\x13\x80\x0A" # _NORON and Delay 10ms
b"\x36\x01\xC0" # _MADCTL
b"\x29\x80\xFF" # _DISPON and Delay 500ms
)
# pylint: disable=too-few-public-methods
class ST7789(BusDisplay):
"""ST7789 driver"""
def __init__(self, bus: FourWire, **kwargs) -> None:
super().__init__(bus, _INIT_SEQUENCE, **kwargs)