diff --git a/adafruit_st7789.py b/adafruit_st7789.py index bb0e0e7..2e35eac 100755 --- a/adafruit_st7789.py +++ b/adafruit_st7789.py @@ -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: diff --git a/docs/index.rst b/docs/index.rst index 24c0cf6..734d593 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -26,8 +26,18 @@ Table of Contents .. toctree:: :caption: Related Products + Adafruit 1.3" 240x240 Wide Angle TFT LCD Display with MicroSD + Adafruit 1.54" 240x240 Wide Angle TFT LCD Display with MicroSD + Adafruit 1.14" 240x135 Color TFT Display + MicroSD Card Breakout + + Adafruit Mini PiTFT 1.3" - 240x240 TFT Add-on for Raspberry Pi + + Adafruit 1.3" Color TFT Bonnet for Raspberry Pi - 240x240 TFT + Joystick Add-on + + Adafruit Mini PiTFT - 135x240 Color TFT Add-on for Raspberry Pi + .. toctree:: :caption: Other Links diff --git a/examples/st7789_240x135_pitft_simpletest.py b/examples/st7789_240x135_pitft_simpletest.py new file mode 100644 index 0000000..5817458 --- /dev/null +++ b/examples/st7789_240x135_pitft_simpletest.py @@ -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 diff --git a/examples/st7789_240x135_simpletest.py b/examples/st7789_240x135_simpletest.py index 97da991..cc72ea2 100644 --- a/examples/st7789_240x135_simpletest.py +++ b/examples/st7789_240x135_simpletest.py @@ -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 diff --git a/examples/st7789_240x240_bonnet_simpletest.py b/examples/st7789_240x240_bonnet_simpletest.py new file mode 100644 index 0000000..9676387 --- /dev/null +++ b/examples/st7789_240x240_bonnet_simpletest.py @@ -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 diff --git a/examples/st7789_240x240_pitft_simpletest.py b/examples/st7789_240x240_pitft_simpletest.py new file mode 100644 index 0000000..5c55926 --- /dev/null +++ b/examples/st7789_240x240_pitft_simpletest.py @@ -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 diff --git a/examples/st7789_320x240_simpletest.py b/examples/st7789_320x240_simpletest.py index a0cbf23..a96eb66 100644 --- a/examples/st7789_320x240_simpletest.py +++ b/examples/st7789_320x240_simpletest.py @@ -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 diff --git a/examples/st7789_simpletest.py b/examples/st7789_simpletest.py index eb85629..1fa06cb 100644 --- a/examples/st7789_simpletest.py +++ b/examples/st7789_simpletest.py @@ -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 diff --git a/examples/st7789_tft_gizmo_simpletest.py b/examples/st7789_tft_gizmo_simpletest.py index e0bab93..34e5f09 100644 --- a/examples/st7789_tft_gizmo_simpletest.py +++ b/examples/st7789_tft_gizmo_simpletest.py @@ -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 diff --git a/requirements.txt b/requirements.txt index cf4cac0..f99129c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ Adafruit-Blinka - +adafruit-blinka-displayio diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..3b18f32 --- /dev/null +++ b/setup.py @@ -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"], +) diff --git a/setup.py.disabled b/setup.py.disabled deleted file mode 100644 index a80b9bf..0000000 --- a/setup.py.disabled +++ /dev/null @@ -1,4 +0,0 @@ -""" -This library is not deployed to PyPI. It is either a board-specific helper library, or -does not make sense for use on or is incompatible with single board computers and Linux. -"""