Skip to content

File changes for PyPI and examples for Pi #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion adafruit_st7789.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,24 @@

**Hardware:**

* Adafruit 1.54" 240x240 Wide Angle TFT LCD Display with MicroSD:
* 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:
Expand Down
10 changes: 10 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,18 @@ Table of Contents
.. toctree::
:caption: Related Products

Adafruit 1.3" 240x240 Wide Angle TFT LCD Display with MicroSD <https://www.adafruit.com/product/4313>

Adafruit 1.54" 240x240 Wide Angle TFT LCD Display with MicroSD <https://www.adafruit.com/product/3787>

Adafruit 1.14" 240x135 Color TFT Display + MicroSD Card Breakout <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>

.. toctree::
:caption: Other Links

Expand Down
68 changes: 68 additions & 0 deletions examples/st7789_240x135_pitft_simpletest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
"""
This test will initialize the display using displayio and draw a solid green
background, a smaller purple rectangle, and some yellow text.

Pinouts are for the 1.14" Mini PiTFT and should be run in CPython.
"""
import board
import terminalio
import displayio
from adafruit_display_text import label
from adafruit_st7789 import ST7789

# First set some parameters used for shapes and text
BORDER = 20
FONTSCALE = 2
BACKGROUND_COLOR = 0x00FF00 # Bright Green
FOREGROUND_COLOR = 0xAA0088 # Purple
TEXT_COLOR = 0xFFFF00

# Release any resources currently in use for the displays
displayio.release_displays()

spi = board.SPI()
tft_cs = board.CE0
tft_dc = board.D25

display_bus = displayio.FourWire(spi, command=tft_dc, chip_select=tft_cs)
display = ST7789(
display_bus, rotation=90, width=240, height=135, rowstart=40, colstart=53
)

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

color_bitmap = displayio.Bitmap(display.width, display.height, 1)
color_palette = displayio.Palette(1)
color_palette[0] = BACKGROUND_COLOR

bg_sprite = displayio.TileGrid(color_bitmap, pixel_shader=color_palette, x=0, y=0)
splash.append(bg_sprite)

# Draw a smaller inner rectangle
inner_bitmap = displayio.Bitmap(
display.width - BORDER * 2, display.height - BORDER * 2, 1
)
inner_palette = displayio.Palette(1)
inner_palette[0] = FOREGROUND_COLOR
inner_sprite = displayio.TileGrid(
inner_bitmap, pixel_shader=inner_palette, x=BORDER, y=BORDER
)
splash.append(inner_sprite)

# Draw a label
text = "Hello World!"
text_area = label.Label(terminalio.FONT, text=text, color=TEXT_COLOR)
text_width = text_area.bounding_box[2] * FONTSCALE
text_group = displayio.Group(
max_size=10,
scale=FONTSCALE,
x=display.width // 2 - text_width // 2,
y=display.height // 2,
)
text_group.append(text_area) # Subgroup for text scaling
splash.append(text_group)

while True:
pass
2 changes: 1 addition & 1 deletion examples/st7789_240x135_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
background, a smaller purple rectangle, and some yellow text.
"""
import board
import displayio
import terminalio
import displayio
from adafruit_display_text import label
from adafruit_st7789 import ST7789

Expand Down
58 changes: 58 additions & 0 deletions examples/st7789_240x240_bonnet_simpletest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
"""
This test will initialize the display using displayio and draw a solid green
background, a smaller purple rectangle, and some yellow text.

Pinouts are for the 1.3" TFT Bonnet and should be run in CPython.
"""
import board
import terminalio
import displayio
from adafruit_display_text import label
from adafruit_st7789 import ST7789

# Release any resources currently in use for the displays
displayio.release_displays()

spi = board.SPI()
tft_cs = board.CE0
tft_dc = board.D25
tft_lite = board.D26

display_bus = displayio.FourWire(spi, command=tft_dc, chip_select=tft_cs)

display = ST7789(
display_bus,
width=240,
height=240,
rowstart=80,
rotation=180,
backlight_pin=tft_lite,
)

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

color_bitmap = displayio.Bitmap(240, 240, 1)
color_palette = displayio.Palette(1)
color_palette[0] = 0x00FF00 # Bright Green

bg_sprite = displayio.TileGrid(color_bitmap, pixel_shader=color_palette, x=0, y=0)
splash.append(bg_sprite)

# Draw a smaller inner rectangle
inner_bitmap = displayio.Bitmap(200, 200, 1)
inner_palette = displayio.Palette(1)
inner_palette[0] = 0xAA0088 # Purple
inner_sprite = displayio.TileGrid(inner_bitmap, pixel_shader=inner_palette, x=20, y=20)
splash.append(inner_sprite)

# Draw a label
text_group = displayio.Group(max_size=10, scale=2, x=50, y=120)
text = "Hello World!"
text_area = label.Label(terminalio.FONT, text=text, color=0xFFFF00)
text_group.append(text_area) # Subgroup for text scaling
splash.append(text_group)

while True:
pass
50 changes: 50 additions & 0 deletions examples/st7789_240x240_pitft_simpletest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
"""
This test will initialize the display using displayio and draw a solid green
background, a smaller purple rectangle, and some yellow text.

Pinouts are for the 1.3" PiTFT and should be run in CPython.
"""
import board
import terminalio
import displayio
from adafruit_display_text import label
from adafruit_st7789 import ST7789

# Release any resources currently in use for the displays
displayio.release_displays()

spi = board.SPI()
tft_cs = board.CE0
tft_dc = board.D25

display_bus = displayio.FourWire(spi, command=tft_dc, chip_select=tft_cs)

display = ST7789(display_bus, width=240, height=240, rowstart=80, rotation=180)

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

color_bitmap = displayio.Bitmap(240, 240, 1)
color_palette = displayio.Palette(1)
color_palette[0] = 0x00FF00 # Bright Green

bg_sprite = displayio.TileGrid(color_bitmap, pixel_shader=color_palette, x=0, y=0)
splash.append(bg_sprite)

# Draw a smaller inner rectangle
inner_bitmap = displayio.Bitmap(200, 200, 1)
inner_palette = displayio.Palette(1)
inner_palette[0] = 0xAA0088 # Purple
inner_sprite = displayio.TileGrid(inner_bitmap, pixel_shader=inner_palette, x=20, y=20)
splash.append(inner_sprite)

# Draw a label
text_group = displayio.Group(max_size=10, scale=2, x=50, y=120)
text = "Hello World!"
text_area = label.Label(terminalio.FONT, text=text, color=0xFFFF00)
text_group.append(text_area) # Subgroup for text scaling
splash.append(text_group)

while True:
pass
2 changes: 1 addition & 1 deletion examples/st7789_320x240_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
background, a smaller purple rectangle, and some yellow text.
"""
import board
import displayio
import terminalio
import displayio
from adafruit_display_text import label
from adafruit_st7789 import ST7789

Expand Down
2 changes: 1 addition & 1 deletion examples/st7789_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
background, a smaller purple rectangle, and some yellow text.
"""
import board
import displayio
import terminalio
import displayio
from adafruit_display_text import label
from adafruit_st7789 import ST7789

Expand Down
2 changes: 1 addition & 1 deletion examples/st7789_tft_gizmo_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"""
import board
import busio
import displayio
import terminalio
import displayio
from adafruit_display_text import label
from adafruit_st7789 import ST7789

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Adafruit-Blinka

adafruit-blinka-displayio
50 changes: 50 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
"""A setuptools based setup module.
See:
https://packaging.python.org/en/latest/distributing.html
https://github.com/pypa/sampleproject
"""

from setuptools import setup, find_packages

# To use a consistent encoding
from codecs import open
from os import path

here = path.abspath(path.dirname(__file__))

# Get the long description from the README file
with open(path.join(here, "README.rst"), encoding="utf-8") as f:
long_description = f.read()

setup(
name="adafruit-circuitpython-st7789",
use_scm_version=True,
setup_requires=["setuptools_scm"],
description="displayio driver for ST7789 TFT-LCD displays.",
long_description=long_description,
long_description_content_type="text/x-rst",
# The project's main homepage.
url="https://github.com/adafruit/Adafruit_CircuitPython_ST7789",
# Author details
author="Adafruit Industries",
author_email="circuitpython@adafruit.com",
install_requires=["Adafruit-Blinka", "adafruit-blinka-displayio",],
# Choose your license
license="MIT",
# See https://pypi.python.org/pypi?%3Aaction=list_classifiers
classifiers=[
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"Topic :: Software Development :: Libraries",
"Topic :: System :: Hardware",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
],
# What does your project relate to?
keywords="adafruit blinka circuitpython micropython st7789 display tft lcd displayio",
# You can just specify the packages manually here if your project is
# simple. Or you can use find_packages().
py_modules=["adafruit_st7789"],
)
4 changes: 0 additions & 4 deletions setup.py.disabled

This file was deleted.