Giter Site home page Giter Site logo

adafruit / adafruit_circuitpython_st7789 Goto Github PK

View Code? Open in Web Editor NEW
56.0 22.0 17.0 139 KB

CircuitPython DisplayIO Driver for ST7789 Color TFT Controller

Home Page: https://circuitpython.org

License: MIT License

Python 100.00%
circuitpython displayio st7789 st7789-display-driver tft-display hacktoberfest

adafruit_circuitpython_st7789's Introduction

Introduction

Documentation Status Discord Build Status Code Style: Black

displayio driver for ST7789 TFT-LCD displays.

Dependencies

This driver depends on:

Please ensure all dependencies are available on the CircuitPython filesystem. This is easily achieved by downloading the Adafruit library and driver bundle.

Usage Example

import board
import displayio
# 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
except ImportError:
    from displayio import FourWire

from adafruit_st7789 import ST7789

displayio.release_displays()

spi = board.SPI()
while not spi.try_lock():
    pass
spi.configure(baudrate=24000000) # Configure SPI for 24MHz
spi.unlock()
tft_cs = board.D5
tft_dc = board.D6

display_bus = FourWire(spi, command=tft_dc, chip_select=tft_cs, reset=board.D9)

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

# Make the display context
splash = displayio.Group()
display.root_group = splash

color_bitmap = displayio.Bitmap(240, 240, 1)
color_palette = displayio.Palette(1)
color_palette[0] = 0xFF0000

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

while True:
    pass

Documentation

API documentation for this library can be found on Read the Docs.

For information on building library documentation, please check out this guide.

Contributing

Contributions are welcome! Please read our Code of Conduct before contributing to help this project stay welcoming.

adafruit_circuitpython_st7789's People

Contributors

deshipu avatar dhalbert avatar evaherrada avatar foamyguy avatar helgibbons avatar kattni avatar ladyada avatar lesamouraipourpre avatar makermelissa avatar markmcgookin avatar mlashley avatar neradoc avatar retiredwizard avatar rmblau avatar siddacious avatar sommersoft avatar tannewt avatar tcfranks avatar tekktrik avatar wildestpixel avatar xgpt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

adafruit_circuitpython_st7789's Issues

This driver seemes not working with ST7789 with CS pin to ground

Hello,

I have a ST7789 screen, like the one in the link below, which has its CS pin connected directly to GND.
I can't initialize the screen, it keeps showing a black screen. How can I fix it?

Thank you,
Xing

https://nl.aliexpress.com/item/1005003381703710.html?spm=a2g0o.productlist.0.0.45f96ee1jJNqHn&algo_pvid=4914bab9-a37d-438a-a21e-121a30a94272&algo_exp_id=4914bab9-a37d-438a-a21e-121a30a94272-0&pdp_ext_f=%7B%22sku_id%22%3A%2212000025518790453%22%7D&pdp_pi=-1%3B2.93%3B-1%3B167%40salePrice%3BUSD%3Bsearch-mainSearch

displayio randomly throws ValueError on object length

I have some fractal generation code I'm writing to play with the CPB and Gizmo from the AdaBox014. The code runs for a random length of time, then throws a "ValueError: requested length 2 but object has length 6"

I should reiterate that the time before this happens is completely random. Sometimes it's in "make the entire display black," sometimes it's in setting the value of color_bitmap[x,y], and sometimes it's in getting the value of the pixel at color_bitmap[x,y].

Relevant code is in my Fractal01 repo. The file that exercises this bug (I think it's a bug, at least) is fractal01a.py in that repo.

The image is a picture of the Gizmo displaying the error.
cpb_error

DisplayIO missing from library

Testing TFT Gizmo example with Circuit Playground Express running Circuit Python V5 alpha 4. I have the following libraries installed from circuit python 5 bundle:

adafruit_bus_device
adafruit_display_shapes
adafruit_display_text
adafruit_st7789.mpy

Traceback (most recent call last): File "code.py", line 7, in <module> ImportError: no module named 'displayio'

Missing Type Annotations

There are missing type annotations for some functions in this library.

The typing module does not exist on CircuitPython devices so the import needs to be wrapped in try/except to catch the error for missing import. There is an example of how that is done here:

try:
    from typing import List, Tuple
except ImportError:
    pass

Once imported the typing annotations for the argument type(s), and return type(s) can be added to the function signature. Here is an example of a function that has had this done already:

def wrap_text_to_pixels(
    string: str, max_width: int, font=None, indent0: str = "", indent1: str = ""
) -> List[str]:

If you are new to Git or Github we have a guide about contributing to our projects here: https://learn.adafruit.com/contribute-to-circuitpython-with-git-and-github

There is also a guide that covers our CI utilities and how to run them locally to ensure they will pass in Github Actions here: https://learn.adafruit.com/creating-and-sharing-a-circuitpython-library/check-your-code In particular the pages: Sharing docs on ReadTheDocs and Check your code with pre-commit contain the tools to install and commands to run locally to run the checks.

If you are attempting to resolve this issue and need help, you can post a comment on this issue and tag both @FoamyGuy and @kattni or reach out to us on Discord: https://adafru.it/discord in the #circuitpython-dev channel.

The following locations are reported by mypy to be missing type annotations:

  • adafruit_st7789.py:63

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.