loboris / MicroPython_ESP32_psRAM_LoBo

MicroPython for ESP32 with psRAM support
Other
831 stars 344 forks source link

TTGO T-Display ST7789V #310

Open k4m454k opened 5 years ago

k4m454k commented 5 years ago

tg_image_4206645005

not correctly work MISO = not connected, but display lib required miso parameter, im set to pin 0

>>> tft.init(tft.ST7789, rst_pin=23, backl_pin=4, miso=0, mosi=19, clk=18, cs=5, dc=16, width=135, height=240, backl_on=1) 
>>> tft.clear()
>>> tft.text(100,100, 'HUI', tft.YELLOW)

IMG_3886

k4m454k commented 5 years ago

Pinout

Name V18
TFT Driver ST7789
TFT_MISO N/A
TFT_MOSI 19
TFT_SCLK 18
TFT_CS 5
TFT_DC 16
TFT_RST N/A
TFT_BL 4
edwardmccaughan commented 4 years ago

I have also been having the same problems, but got it mostly figured out.

first, the inverted colors problem is solved by someone on the lobo forum. For some reason the color inversion is being set wrong, but there is a low level command to fix it: tft.tft_writecmd(0x21) https://loboris.eu/forum/showthread.php?tid=188

for the screen only drawing to part of the screen, there is also some weirdness in the offset, so I used setwin to 'fix' it. I'm not sure if this is the right way to do it, but it works...

tft.init(tft.ST7789,
         rst_pin=23,
         backl_pin=4,
         miso=0,
         mosi=19,
         clk=18,
         cs=5,
         dc=16,
         width=screen_width_with_offset,
         height= screen_height_with_offset,
         backl_on=1,
) 
tft.setwin(width_offset,height_offset, screen_width_with_offset + 100, screen_height_with_offset+100)

ST7735_INVON = const(0x21)
tft.tft_writecmd(ST7735_INVON)

The MISO pin does not seem to be important in the end

Hope this helps!

hsph commented 4 years ago

I have also been having the same problems, but got it mostly figured out.

first, the inverted colors problem is solved by someone on the lobo forum. For some reason the color inversion is being set wrong, but there is a low level command to fix it: tft.tft_writecmd(0x21) https://loboris.eu/forum/showthread.php?tid=188

for the screen only drawing to part of the screen, there is also some weirdness in the offset, so I used setwin to 'fix' it. I'm not sure if this is the right way to do it, but it works...

tft.init(tft.ST7789,
         rst_pin=23,
         backl_pin=4,
         miso=0,
         mosi=19,
         clk=18,
         cs=5,
         dc=16,
         width=screen_width_with_offset,
         height= screen_height_with_offset,
         backl_on=1,
) 
tft.setwin(width_offset,height_offset, screen_width_with_offset + 100, screen_height_with_offset+100)

ST7735_INVON = const(0x21)
tft.tft_writecmd(ST7735_INVON)

The MISO pin does not seem to be important in the end

Hope this helps!

Your approach did the trick for me. Finding out the right window size / offset was bit of trial and erroring. The values below worked with my TTGO T-Display.

import display

# initialize the display
tft=display.TFT()
tft.init(tft.ST7789, rst_pin=23, backl_pin=4, miso=0, mosi=19, clk=18, cs=5, dc=16, width=235, height=340, backl_on=1)

# invert colors
tft.tft_writecmd(0x21)

# set orientation (optional)
tft.orient(tft.LANDSCAPE)

# set window size
tft.setwin(40, 52, 278, 186)
creed81 commented 4 years ago

Thanks @hsph! The values you provided helped a lot. Just want to add a minor fix(for setwin parameters):

import display

# initialize the display
tft=display.TFT()
tft.init(tft.ST7789, rst_pin=23, backl_pin=4, miso=0, mosi=19, clk=18, cs=5, dc=16, width=235, height=340, backl_on=1)

# invert colors
tft.tft_writecmd(0x21)

# set orientation
tft.orient(tft.LANDSCAPE)

# set window size
 tft.setwin(40, 52, 279, 186)

These values give the full : 240 * 135 that our display is capable of. This can be confirmed by running: tft.winsize() or tft.rect(0, 0, 240, 135, tft.PINK)