Skip to content

Commit a38c9bb

Browse files
authored
Merge pull request #18 from makermelissa/master
File changes for PyPI and examples for Pi
2 parents 7223530 + 156783b commit a38c9bb

12 files changed

+257
-10
lines changed

adafruit_st7789.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,24 @@
3232
3333
**Hardware:**
3434
35-
* Adafruit 1.54" 240x240 Wide Angle TFT LCD Display with MicroSD:
35+
* Adafruit 1.3" 240x240 Wide Angle TFT LCD Display with MicroSD - ST7789:
36+
https://www.adafruit.com/product/4313
37+
38+
* Adafruit 1.54" 240x240 Wide Angle TFT LCD Display with MicroSD - ST7789:
3639
https://www.adafruit.com/product/3787
3740
41+
* Adafruit 1.14" 240x135 Color TFT Display + MicroSD Card Breakout - ST7789:
42+
https://www.adafruit.com/product/4383
43+
44+
* Adafruit Mini PiTFT 1.3" - 240x240 TFT Add-on for Raspberry Pi:
45+
https://www.adafruit.com/product/4484
46+
47+
* Adafruit 1.3" Color TFT Bonnet for Raspberry Pi - 240x240 TFT + Joystick Add-on
48+
https://www.adafruit.com/product/4506
49+
50+
* Adafruit Mini PiTFT - 135x240 Color TFT Add-on for Raspberry Pi:
51+
https://www.adafruit.com/product/4393
52+
3853
**Software and Dependencies:**
3954
4055
* Adafruit CircuitPython firmware for the supported boards:

docs/index.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,18 @@ Table of Contents
2626
.. toctree::
2727
:caption: Related Products
2828

29+
Adafruit 1.3" 240x240 Wide Angle TFT LCD Display with MicroSD <https://www.adafruit.com/product/4313>
30+
2931
Adafruit 1.54" 240x240 Wide Angle TFT LCD Display with MicroSD <https://www.adafruit.com/product/3787>
3032

33+
Adafruit 1.14" 240x135 Color TFT Display + MicroSD Card Breakout <https://www.adafruit.com/product/4383>
34+
35+
Adafruit Mini PiTFT 1.3" - 240x240 TFT Add-on for Raspberry Pi <https://www.adafruit.com/product/4484>
36+
37+
Adafruit 1.3" Color TFT Bonnet for Raspberry Pi - 240x240 TFT + Joystick Add-on <https://www.adafruit.com/product/4506>
38+
39+
Adafruit Mini PiTFT - 135x240 Color TFT Add-on for Raspberry Pi <https://www.adafruit.com/product/4393>
40+
3141
.. toctree::
3242
:caption: Other Links
3343

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
"""
2+
This test will initialize the display using displayio and draw a solid green
3+
background, a smaller purple rectangle, and some yellow text.
4+
5+
Pinouts are for the 1.14" Mini PiTFT and should be run in CPython.
6+
"""
7+
import board
8+
import terminalio
9+
import displayio
10+
from adafruit_display_text import label
11+
from adafruit_st7789 import ST7789
12+
13+
# First set some parameters used for shapes and text
14+
BORDER = 20
15+
FONTSCALE = 2
16+
BACKGROUND_COLOR = 0x00FF00 # Bright Green
17+
FOREGROUND_COLOR = 0xAA0088 # Purple
18+
TEXT_COLOR = 0xFFFF00
19+
20+
# Release any resources currently in use for the displays
21+
displayio.release_displays()
22+
23+
spi = board.SPI()
24+
tft_cs = board.CE0
25+
tft_dc = board.D25
26+
27+
display_bus = displayio.FourWire(spi, command=tft_dc, chip_select=tft_cs)
28+
display = ST7789(
29+
display_bus, rotation=90, width=240, height=135, rowstart=40, colstart=53
30+
)
31+
32+
# Make the display context
33+
splash = displayio.Group(max_size=10)
34+
display.show(splash)
35+
36+
color_bitmap = displayio.Bitmap(display.width, display.height, 1)
37+
color_palette = displayio.Palette(1)
38+
color_palette[0] = BACKGROUND_COLOR
39+
40+
bg_sprite = displayio.TileGrid(color_bitmap, pixel_shader=color_palette, x=0, y=0)
41+
splash.append(bg_sprite)
42+
43+
# Draw a smaller inner rectangle
44+
inner_bitmap = displayio.Bitmap(
45+
display.width - BORDER * 2, display.height - BORDER * 2, 1
46+
)
47+
inner_palette = displayio.Palette(1)
48+
inner_palette[0] = FOREGROUND_COLOR
49+
inner_sprite = displayio.TileGrid(
50+
inner_bitmap, pixel_shader=inner_palette, x=BORDER, y=BORDER
51+
)
52+
splash.append(inner_sprite)
53+
54+
# Draw a label
55+
text = "Hello World!"
56+
text_area = label.Label(terminalio.FONT, text=text, color=TEXT_COLOR)
57+
text_width = text_area.bounding_box[2] * FONTSCALE
58+
text_group = displayio.Group(
59+
max_size=10,
60+
scale=FONTSCALE,
61+
x=display.width // 2 - text_width // 2,
62+
y=display.height // 2,
63+
)
64+
text_group.append(text_area) # Subgroup for text scaling
65+
splash.append(text_group)
66+
67+
while True:
68+
pass

examples/st7789_240x135_simpletest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
background, a smaller purple rectangle, and some yellow text.
44
"""
55
import board
6-
import displayio
76
import terminalio
7+
import displayio
88
from adafruit_display_text import label
99
from adafruit_st7789 import ST7789
1010

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
"""
2+
This test will initialize the display using displayio and draw a solid green
3+
background, a smaller purple rectangle, and some yellow text.
4+
5+
Pinouts are for the 1.3" TFT Bonnet and should be run in CPython.
6+
"""
7+
import board
8+
import terminalio
9+
import displayio
10+
from adafruit_display_text import label
11+
from adafruit_st7789 import ST7789
12+
13+
# Release any resources currently in use for the displays
14+
displayio.release_displays()
15+
16+
spi = board.SPI()
17+
tft_cs = board.CE0
18+
tft_dc = board.D25
19+
tft_lite = board.D26
20+
21+
display_bus = displayio.FourWire(spi, command=tft_dc, chip_select=tft_cs)
22+
23+
display = ST7789(
24+
display_bus,
25+
width=240,
26+
height=240,
27+
rowstart=80,
28+
rotation=180,
29+
backlight_pin=tft_lite,
30+
)
31+
32+
# Make the display context
33+
splash = displayio.Group(max_size=10)
34+
display.show(splash)
35+
36+
color_bitmap = displayio.Bitmap(240, 240, 1)
37+
color_palette = displayio.Palette(1)
38+
color_palette[0] = 0x00FF00 # Bright Green
39+
40+
bg_sprite = displayio.TileGrid(color_bitmap, pixel_shader=color_palette, x=0, y=0)
41+
splash.append(bg_sprite)
42+
43+
# Draw a smaller inner rectangle
44+
inner_bitmap = displayio.Bitmap(200, 200, 1)
45+
inner_palette = displayio.Palette(1)
46+
inner_palette[0] = 0xAA0088 # Purple
47+
inner_sprite = displayio.TileGrid(inner_bitmap, pixel_shader=inner_palette, x=20, y=20)
48+
splash.append(inner_sprite)
49+
50+
# Draw a label
51+
text_group = displayio.Group(max_size=10, scale=2, x=50, y=120)
52+
text = "Hello World!"
53+
text_area = label.Label(terminalio.FONT, text=text, color=0xFFFF00)
54+
text_group.append(text_area) # Subgroup for text scaling
55+
splash.append(text_group)
56+
57+
while True:
58+
pass
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
"""
2+
This test will initialize the display using displayio and draw a solid green
3+
background, a smaller purple rectangle, and some yellow text.
4+
5+
Pinouts are for the 1.3" PiTFT and should be run in CPython.
6+
"""
7+
import board
8+
import terminalio
9+
import displayio
10+
from adafruit_display_text import label
11+
from adafruit_st7789 import ST7789
12+
13+
# Release any resources currently in use for the displays
14+
displayio.release_displays()
15+
16+
spi = board.SPI()
17+
tft_cs = board.CE0
18+
tft_dc = board.D25
19+
20+
display_bus = displayio.FourWire(spi, command=tft_dc, chip_select=tft_cs)
21+
22+
display = ST7789(display_bus, width=240, height=240, rowstart=80, rotation=180)
23+
24+
# Make the display context
25+
splash = displayio.Group(max_size=10)
26+
display.show(splash)
27+
28+
color_bitmap = displayio.Bitmap(240, 240, 1)
29+
color_palette = displayio.Palette(1)
30+
color_palette[0] = 0x00FF00 # Bright Green
31+
32+
bg_sprite = displayio.TileGrid(color_bitmap, pixel_shader=color_palette, x=0, y=0)
33+
splash.append(bg_sprite)
34+
35+
# Draw a smaller inner rectangle
36+
inner_bitmap = displayio.Bitmap(200, 200, 1)
37+
inner_palette = displayio.Palette(1)
38+
inner_palette[0] = 0xAA0088 # Purple
39+
inner_sprite = displayio.TileGrid(inner_bitmap, pixel_shader=inner_palette, x=20, y=20)
40+
splash.append(inner_sprite)
41+
42+
# Draw a label
43+
text_group = displayio.Group(max_size=10, scale=2, x=50, y=120)
44+
text = "Hello World!"
45+
text_area = label.Label(terminalio.FONT, text=text, color=0xFFFF00)
46+
text_group.append(text_area) # Subgroup for text scaling
47+
splash.append(text_group)
48+
49+
while True:
50+
pass

examples/st7789_320x240_simpletest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
background, a smaller purple rectangle, and some yellow text.
44
"""
55
import board
6-
import displayio
76
import terminalio
7+
import displayio
88
from adafruit_display_text import label
99
from adafruit_st7789 import ST7789
1010

examples/st7789_simpletest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
background, a smaller purple rectangle, and some yellow text.
44
"""
55
import board
6-
import displayio
76
import terminalio
7+
import displayio
88
from adafruit_display_text import label
99
from adafruit_st7789 import ST7789
1010

examples/st7789_tft_gizmo_simpletest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
"""
55
import board
66
import busio
7-
import displayio
87
import terminalio
8+
import displayio
99
from adafruit_display_text import label
1010
from adafruit_st7789 import ST7789
1111

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
Adafruit-Blinka
2-
2+
adafruit-blinka-displayio

setup.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
"""A setuptools based setup module.
2+
See:
3+
https://packaging.python.org/en/latest/distributing.html
4+
https://github.com/pypa/sampleproject
5+
"""
6+
7+
from setuptools import setup, find_packages
8+
9+
# To use a consistent encoding
10+
from codecs import open
11+
from os import path
12+
13+
here = path.abspath(path.dirname(__file__))
14+
15+
# Get the long description from the README file
16+
with open(path.join(here, "README.rst"), encoding="utf-8") as f:
17+
long_description = f.read()
18+
19+
setup(
20+
name="adafruit-circuitpython-st7789",
21+
use_scm_version=True,
22+
setup_requires=["setuptools_scm"],
23+
description="displayio driver for ST7789 TFT-LCD displays.",
24+
long_description=long_description,
25+
long_description_content_type="text/x-rst",
26+
# The project's main homepage.
27+
url="https://github.com/adafruit/Adafruit_CircuitPython_ST7789",
28+
# Author details
29+
author="Adafruit Industries",
30+
author_email="[email protected]",
31+
install_requires=["Adafruit-Blinka", "adafruit-blinka-displayio",],
32+
# Choose your license
33+
license="MIT",
34+
# See https://pypi.python.org/pypi?%3Aaction=list_classifiers
35+
classifiers=[
36+
"Development Status :: 3 - Alpha",
37+
"Intended Audience :: Developers",
38+
"Topic :: Software Development :: Libraries",
39+
"Topic :: System :: Hardware",
40+
"License :: OSI Approved :: MIT License",
41+
"Programming Language :: Python :: 3",
42+
"Programming Language :: Python :: 3.4",
43+
"Programming Language :: Python :: 3.5",
44+
],
45+
# What does your project relate to?
46+
keywords="adafruit blinka circuitpython micropython st7789 display tft lcd displayio",
47+
# You can just specify the packages manually here if your project is
48+
# simple. Or you can use find_packages().
49+
py_modules=["adafruit_st7789"],
50+
)

setup.py.disabled

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

0 commit comments

Comments
 (0)