Giter Club home page Giter Club logo

st7789py_mpy's Introduction

Slow ST7789 driver for MicroPython

This is a slow MicroPython driver for 240x240 ST7789 display without CS pin from Ali Express. It also supports 135x240 TTGO Display

Version: 0.1.4

The performance is quite low due to python function call overhead. If you have a chance to build firmware and you are using ESP8266/ESP32 controllers, you should try the fast driver https://github.com/devbis/st7789_mpy

Examples

# ESP8266
import machine
import st7789py
spi = machine.SPI(1, baudrate=40000000, polarity=1)
display = st7789py.ST7789(spi, 240, 240, reset=machine.Pin(5, machine.Pin.OUT), dc=machine.Pin(4, machine.Pin.OUT))
display.init()
display.pixel(120, 120, st7789py.YELLOW)

st7789py_mpy's People

Contributors

devbis 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

st7789py_mpy's Issues

Mirroring issues

Hi @devbis

While using this driver with the T-WATCH S3 I ran into the problem that the display is rotated 180 degrees.
Reading your code and the datasheet of the device, I tried to set MADCTL_MX and MADCTL_MY in the MADCTL register, however while in this way I can see the device oriented correctly, there is a odd offset: it shows only 2/3 of the display 240x240 area. I don't know if it's some issue with the scrolling feature of the chip or what. I wonder if you know anything about it. Thanks.

micropython pyboard 1.1 EIO error with write function

Currently:
def write(self, command=None, data=None):
"""SPI write to the device: commands and data"""
self.cs_low()
if command is not None:
self.dc_low()
self.spi.write(bytes([command]))
if data is not None:
self.dc_high()
self.spi.write(data)
self.cs_high()

Was able to fix it to work by changing to:
if data is not None and data != b'':

Both regular nulls and empty byte strings are passed to the function.

"Yellow" bitmap images

I'm trying to display Bitmaps on the Raspberry Pi Pico using the Waveshare display (https://www.waveshare.com/wiki/Pico-LCD-1.14).
I convert a 240x135 image to BMP (24 bits) and then I convert it using imgtobitmap.py.
Image appears always yellowish: I mean image looks like the BLUE is missing.
I edited the library (st7789py.py) at row 803, maybe it would be

buffer[i + 1] = color & 0xff

instead of

buffer[i + 1] = color_index & 0xff

?

Anyway images still not looks good, even if I chose the maximum value for Bit x Pixel (5, values greater than 5 causes a memory error in Thonny since the generated file is too large).

This driver is not slow

Hello, thank you for writing this driver. Initially I used it with MicroPython SoftSPI, and performances where terrible. I did some profiling and found that it was the SoftSPI implementation itself that is so show, but at least with the ESP32-S3, if we switch to the hardware SPI, it goes from 1100 ticks to fill the screen to... 53! Basically more or less the performance of the C driver if I understand correctly.

Now the trick is that sometimes you can use the SPI() constructor and still use the SoftSPI() thing (and get a deprecation message). This depends on the first parameter, that must be a number, the hardware SPI identifier basically. To really use the hardware SPI, you need to do something like that when constructing the object:

    # Our display does not have a MISO pin, but the MicroPython
    # SPI implementation does not allow to avoid specifying one, so
    # we use just a not used pin in the device.
    spi = SPI(1, baudrate=40000000, polarity=1, sck=18, mosi=13, miso=37)
    display = st7789.ST7789(
        spi, 240, 240,
        reset=False,
        dc=Pin(38, Pin.OUT),
        cs=Pin(12, Pin.OUT),
    )
    display.init()

Note that the S3 seems able to use any pin for hardware SPI! I don't think that before ESP32-S3 it was like that, but I'm not sure.

I hope this helps! And I believe it would be cool to document this in the project README file. Others may benefit from this information.

blit_buffer method

Hi. Thanks you so much for post this "slow" MicroPython module. Is enough quick for my modest project with on ESP32.

So, I can't understand to use the blit_buffer method. What is the image format for the buffer. Do you have a exemple or a link please?

Thanks you!!

Backlight to set

Hello Ivan
I am using an ESP 32 TTGO T Display board and the screen stay black
I have to add before calling display.init() these 2 instructions:

backlight= machine.Pin(4)
backlight.value(1)

to get the display visible
I have looked inside your driver and i don't see any backlight set

Kindly
Dan

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.