Skip to content

Commit 521dabe

Browse files
author
Melissa LeBlanc-Williams
committed
Changes requested by tannewt
1 parent 6921f75 commit 521dabe

File tree

8 files changed

+179
-178
lines changed

8 files changed

+179
-178
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ install:
2727
- pip install --force-reinstall pylint==1.9.2
2828

2929
script:
30-
- pylint adafruit_st7735.py
30+
- pylint adafruit_st7735/*.py
3131
- ([[ ! -d "examples" ]] || pylint --disable=missing-docstring,invalid-name,bad-whitespace examples/*.py)
3232
- circuitpython-build-bundles --filename_prefix adafruit-circuitpython-st7735 --library_location .
3333
- cd docs && sphinx-build -E -W -b html . _build/html && cd ..

adafruit_st7735.py

Lines changed: 0 additions & 170 deletions
This file was deleted.

adafruit_st7735/st7735b.py

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# The MIT License (MIT)
2+
#
3+
# Copyright (c) 2019 Scott Shawcroft and Melissa LeBlanc-Williams
4+
# for Adafruit Industries LLC
5+
#
6+
# Permission is hereby granted, free of charge, to any person obtaining a copy
7+
# of this software and associated documentation files (the "Software"), to deal
8+
# in the Software without restriction, including without limitation the rights
9+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
# copies of the Software, and to permit persons to whom the Software is
11+
# furnished to do so, subject to the following conditions:
12+
#
13+
# The above copyright notice and this permission notice shall be included in
14+
# all copies or substantial portions of the Software.
15+
#
16+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
# THE SOFTWARE.
23+
"""
24+
`adafruit_st7735.st7735b`
25+
====================================================
26+
27+
Displayio driver for ST7735B based displays.
28+
29+
* Author(s): Melissa LeBlanc-Williams
30+
31+
Implementation Notes
32+
--------------------
33+
34+
**Hardware:**
35+
36+
**Software and Dependencies:**
37+
38+
* Adafruit CircuitPython firmware for the supported boards:
39+
https://github.com/adafruit/circuitpython/releases
40+
41+
"""
42+
43+
import displayio
44+
45+
__version__ = "0.0.0-auto.0"
46+
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_ST7735.git"
47+
48+
_INIT_SEQUENCE = (
49+
b"\x01\x80\x32" # _SWRESET and Delay 50ms
50+
b"\x11\x80\xFF" # _SLPOUT
51+
b"\x3A\x81\x05\x0A" # _COLMOD
52+
b"\xB1\x83\x00\x06\x03\x0A" # _FRMCTR1
53+
b"\x36\x01\x08" # _MADCTL
54+
b"\xB6\x02\x15\x02" # _DISSET5
55+
#1 clk cycle nonoverlap, 2 cycle gate, rise, 3 cycle osc equalize, Fix on VTL
56+
b"\xB4\x01\x00" # _INVCTR line inversion
57+
b"\xC0\x82\x02\x70\x0A" # _PWCTR1 GVDD = 4.7V, 1.0uA, 10 ms delay
58+
b"\xC1\x01\x05" # _PWCTR2 VGH = 14.7V, VGL = -7.35V
59+
b"\xC2\x02\x01\x02" # _PWCTR3 Opamp current small, Boost frequency
60+
b"\xC5\x82\x3C\x38\x0A" # _VMCTR1
61+
b"\xFC\x02\x11\x15" # _PWCTR6
62+
b"\xE0\x10\x09\x16\x09\x20\x21\x1B\x13\x19\x17\x15\x1E\x2B\x04\x05\x02\x0E" # _GMCTRP1 Gamma
63+
b"\xE1\x90\x0B\x14\x08\x1E\x22\x1D\x18\x1E\x1B\x1A\x24\x2B\x06\x06\x02\x0F\x0A" # _GMCTRN1
64+
b"\x2a\x00\x02\x00\x81" # _CASET
65+
b"\x2b\x00\x02\x00\x81" # _RASET
66+
b"\x13\x80\x0a" # _NORON
67+
b"\x29\x80\xFF" # _DISPON
68+
)
69+
70+
# pylint: disable=too-few-public-methods
71+
class ST7735B(displayio.Display):
72+
"""ST7735 driver for ST7735B"""
73+
def __init__(self, bus, **kwargs):
74+
super().__init__(bus, _INIT_SEQUENCE, **kwargs)

adafruit_st7735/st7735r.py

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# The MIT License (MIT)
2+
#
3+
# Copyright (c) 2019 Scott Shawcroft and Melissa LeBlanc-Williams
4+
# for Adafruit Industries LLC
5+
#
6+
# Permission is hereby granted, free of charge, to any person obtaining a copy
7+
# of this software and associated documentation files (the "Software"), to deal
8+
# in the Software without restriction, including without limitation the rights
9+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
# copies of the Software, and to permit persons to whom the Software is
11+
# furnished to do so, subject to the following conditions:
12+
#
13+
# The above copyright notice and this permission notice shall be included in
14+
# all copies or substantial portions of the Software.
15+
#
16+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
# THE SOFTWARE.
23+
"""
24+
`adafruit_st7735.st7735r`
25+
====================================================
26+
27+
Displayio driver for ST7735R based displays.
28+
29+
* Author(s): Scott Shawcroft and Melissa LeBlanc-Williams
30+
31+
Implementation Notes
32+
--------------------
33+
34+
**Hardware:**
35+
36+
* 1.8" SPI TFT display, 160x128 18-bit color:
37+
https://www.adafruit.com/product/618
38+
* Adafruit 0.96" 160x80 Color TFT Display w/ MicroSD Card Breakout:
39+
https://www.adafruit.com/product/3533
40+
* 1.8" Color TFT LCD display with MicroSD Card Breakout:
41+
https://www.adafruit.com/product/358
42+
* Adafruit 1.44" Color TFT LCD Display with MicroSD Card breakout:
43+
https://www.adafruit.com/product/2088
44+
* Adafruit Mini Color TFT with Joystick FeatherWing:
45+
https://www.adafruit.com/product/3321
46+
47+
**Software and Dependencies:**
48+
49+
* Adafruit CircuitPython firmware for the supported boards:
50+
https://github.com/adafruit/circuitpython/releases
51+
52+
"""
53+
54+
import displayio
55+
56+
__version__ = "0.0.0-auto.0"
57+
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_ST7735.git"
58+
59+
_INIT_SEQUENCE = bytearray(
60+
b"\x01\x80\x96" # SWRESET and Delay 150ms
61+
b"\x11\x80\xff" # SLPOUT and Delay
62+
b"\xb1\x03\x01\x2C\x2D" # _FRMCTR1
63+
b"\xb2\x03\x01\x2C\x2D" # _FRMCTR2
64+
b"\xb3\x06\x01\x2C\x2D\x01\x2C\x2D" # _FRMCTR3
65+
b"\xb4\x01\x07" # _INVCTR line inversion
66+
b"\xc0\x03\xa2\x02\x84" # _PWCTR1 GVDD = 4.7V, 1.0uA
67+
b"\xc1\x01\xc5" # _PWCTR2 VGH=14.7V, VGL=-7.35V
68+
b"\xc2\x02\x0a\x00" # _PWCTR3 Opamp current small, Boost frequency
69+
b"\xc3\x02\x8a\x2a"
70+
b"\xc4\x02\x8a\xee"
71+
b"\xc5\x01\x0e" # _VMCTR1 VCOMH = 4V, VOML = -1.1V
72+
b"\x20\x00" # _INVOFF
73+
b"\x36\x01\x18" # _MADCTL bottom to top refresh
74+
# 1 clk cycle nonoverlap, 2 cycle gate rise, 3 sycle osc equalie,
75+
# fix on VTL
76+
b"\x3a\x01\x05" # COLMOD - 16bit color
77+
b"\xe0\x10\x02\x1c\x07\x12\x37\x32\x29\x2d\x29\x25\x2B\x39\x00\x01\x03\x10" # _GMCTRP1 Gamma
78+
b"\xe1\x10\x03\x1d\x07\x06\x2E\x2C\x29\x2D\x2E\x2E\x37\x3F\x00\x00\x02\x10" # _GMCTRN1
79+
b"\x13\x80\x0a" # _NORON
80+
b"\x29\x80\x64" # _DISPON
81+
)
82+
83+
# pylint: disable=too-few-public-methods
84+
class ST7735R(displayio.Display):
85+
"""ST7735 driver for ST7735R"""
86+
def __init__(self, bus, *, init=None, **kwargs):
87+
"""
88+
:param bytes init: (Optional) An extra init sequence to append (default=None)
89+
"""
90+
init_sequence = _INIT_SEQUENCE
91+
if init is not None:
92+
init_sequence += init
93+
super().__init__(bus, init_sequence, **kwargs)

docs/api.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,8 @@
44
.. If your library file(s) are nested in a directory (e.g. /adafruit_foo/foo.py)
55
.. use this format as the module name: "adafruit_foo.foo"
66
7-
.. automodule:: adafruit_st7735
7+
.. automodule:: adafruit_st7735.st7735r
88
:members:
9+
10+
.. automodule:: adafruit_st7735.st7735b
11+
:members:

examples/st7735_128x160_simpletest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import board
77
import displayio
8-
from adafruit_st7735 import ST7735R_BLACK
8+
from adafruit_st7735.st7735r import ST7735R
99

1010
spi = board.SPI()
1111
tft_cs = board.D5
@@ -14,7 +14,7 @@
1414
displayio.release_displays()
1515
display_bus = displayio.FourWire(spi, command=tft_dc, chip_select=tft_cs, reset=board.D9)
1616

17-
display = ST7735R_BLACK(display_bus, width=128, height=160)
17+
display = ST7735R(display_bus, width=128, height=160, init=b"\x36\x01\xC0")
1818

1919
# Make the display context
2020
splash = displayio.Group(max_size=10)

examples/st7735_miniTFT_simpletest.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
"""
44
import board
55
import displayio
6+
import digitalio
67
from adafruit_seesaw.seesaw import Seesaw
7-
from adafruit_st7735 import MINI160X80
8+
from adafruit_st7735.st7735r import ST7735R
89

910
reset_pin = 8
1011
i2c = board.I2C()
@@ -19,7 +20,7 @@
1920
display_bus = displayio.FourWire(spi, command=tft_dc, chip_select=tft_cs, reset=board.D9)
2021

2122
ss.digital_write(reset_pin, True)
22-
display = MINI160X80(display_bus)
23+
display = ST7735R(display_bus, width=160, height=80, rowstart=24, init=b"\x36\x01\x60")
2324

2425
# Make the display context
2526
splash = displayio.Group(max_size=10)

0 commit comments

Comments
 (0)