Help with a Wave Pi Pico LCD 1.14

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
FeK9
Posts: 33
Joined: Sun Jan 20, 2019 8:19 am

Help with a Wave Pi Pico LCD 1.14

Post by FeK9 » Thu Dec 16, 2021 9:35 am

Morning All...

For the past day or two ive been tring to get a Wave Pi Pico LCD display 1.14 ST7789 SPI called 'Wave Pi Pico LCD 1.14'
to use CWriter to print a simple 'Hello World'. Been pulling my hair out, no luck yet... :(

The display a 240×135 pixel driven by a ST7789 and a Pi Pico...

The code shown below is the result of my trawling both 'micropython-nano-gui' and 'micropython-micro-gui' liberies
by 'peterhinch'... It's mostly from the set up examples called 'st7789_pico.py' and 'st7789_ttgo.py' found in setup_examples
of 'micropython-nano-gui'...

I've used a micropython example by Waveshare https://www.waveshare.net/w/upload/0/06 ... D-1.14.zip to
confirm that the display works, it does... The example code drives the ST7789 directly...

The pic below shows the result. The SPI GP pin's should be a match for the Pi Pico, and pixel's 240x135 are the same for
the TTGO OLed...

Any ideas suggestions...?

Code: Select all

from machine import Pin, SPI
import gc

from drivers.st7789_4bit import *
SSD = ST7789

from writer.writer import CWriter
#from writer.colors import *    # No effect

import fonts.font10  # Font to use

BL = Pin(13, Pin.OUT, value=1)  # Back light on
CS = Pin(9, Pin.OUT, value=1)
RST = Pin(12, Pin.OUT, value=1)
#height=135
#width=240

gc.collect()  # Precaution before instantiating framebuf
# Conservative low baudrate. Can go to 62.5MHz. Depending on wiring.
spi = SPI(1, 10000_000, sck=Pin(10), mosi=Pin(11), miso=None)
ssd = SSD(spi, height=135, width=240, dc=Pin(8), cs=CS, rst=RST)
#spi = SPI(1, 30_000_000, sck=Pin(10), mosi=Pin(11), miso=Pin(8))
#ssd = SSD(spi, dc=pdc, cs=pcs, rst=prst)

#refresh(ssd, True)  # Initialise and clear display. # NameError: name 'refresh' isn't defined
#=====================================================================

# Define a few colors
GREEN = SSD.rgb(0, 255, 0)
RED = SSD.rgb(255,0,0)
BLACK = SSD.rgb(0, 0, 0)


# Instantiate a writer for a specific font
ssd.fill(0)
wri = CWriter(ssd, fonts.font10)  # Can set verbose = False to suppress console output
CWriter.set_textpos(ssd, 0, 0)  # In case a previous test has altered this
wri.setcolor(RED, BLACK)  # Colors can be set in constructor or changed dynamically
wri.printstring('Hello World')
ssd.show()
Attachments
Image 2021-12-16 at 10.45.00.jpeg
Image 2021-12-16 at 10.45.00.jpeg (136.52 KiB) Viewed 32543 times

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Help with a Wave Pi Pico LCD 1.14

Post by pythoncoder » Thu Dec 16, 2021 10:34 am

I can't see anything obviously wrong with your code.

Unfortunately ST7789 displays come in various configurations. The driver currently supports two types: GENERIC (the default) and TDISPLAY. You could try the latter, e.g. from the t-display config:

Code: Select all

ssd = SSD(spi, height=135, width=240, dc=pdc, cs=pcs, rst=prst, disp_mode=LANDSCAPE, display=TDISPLAY)
otherwise we may need to delve into the working display driver to find the arguments that your display requires.

It's worth running the quick hardware check to verify a configuration before trying to render text as the resulting display can give clues as to what is wrong.

[EDIT]
I will support this display as it's ideally suited to micro-gui. I've now ordered one. It will be a while before it arrives and I persuade it to work. In the mean time, if display=TDISPLAY doesn't work you might like to experiment with the display tuple in conjunction with the hardware test script. You need to find values which produce that display in a pixel-perfect fashion, otherwise text etc. will be garbage. Otherwise I'll publish a setup file in due course.
Peter Hinch
Index to my micropython libraries.

User avatar
curt
Posts: 25
Joined: Thu Jul 29, 2021 3:52 am
Location: Big Lake, Alaska

Re: Help with a Wave Pi Pico LCD 1.14

Post by curt » Thu Dec 16, 2021 6:41 pm

On my ESP32 TTGO I use the precompiled firmware from here:
https://github.com/russhughes/st7789_mpy
There is firmware available for the PI Pico

Curt

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Help with a Wave Pi Pico LCD 1.14

Post by pythoncoder » Fri Dec 17, 2021 10:18 am

The micro-gui and nano-gui lbraries work with the TTGO - the question is whether the X and Y offset values for the TTGO correspond with the requirements of the Waveshare display. As the website you reference makes clear, these values often have to be determined by experiment. His approach:
One technique is to draw a box the same size as the display and then make small changes to the offsets until the display looks correct.
I prefer the asymmetrical shape drawn by my script which makes it easy to see errors like inversion and reflection.
Peter Hinch
Index to my micropython libraries.

FeK9
Posts: 33
Joined: Sun Jan 20, 2019 8:19 am

Re: Help with a Wave Pi Pico LCD 1.14

Post by FeK9 » Fri Dec 17, 2021 4:43 pm

pythoncoder wrote:
Thu Dec 16, 2021 10:34 am
I can't see anything obviously wrong with your code.

Unfortunately ST7789 displays come in various configurations. The driver currently supports two types: GENERIC (the default) and TDISPLAY. You could try the latter, e.g. from the t-display config:
.........................
Hi @pythoncoder

Thanks for input, did as you suggested... Only one thing change, stripy white display became a clear dark display. I also did the hardware_setup.py test, to no effect blank display...

Noted on your second post...

Below is the REPL output, it was the same for all test...

Code: Select all

MicroPython v1.17 on 2021-09-02; Raspberry Pi Pico with RP2040
Type "help()" for more information.
>>> %Run -c $EDITOR_CONTENT

Orientation: Horizontal. Reversal: False. Width: 240. Height: 135.
Start row = 0 col = 0

>>> 

Code: Select all

from machine import Pin, SPI
import gc
from drivers.st7789_4bit import *
from writer.colors import *
SSD = ST7789

BL = Pin(13, Pin.OUT, value=1)  # Back light on
CS = Pin(9, Pin.OUT, value=1)
RST = Pin(12, Pin.OUT, value=1)

gc.collect()  # Precaution before instantiating framebuf
# Conservative low baudrate. Can go to 62.5MHz. Depending on wiring.
spi = SPI(1, 10000_000, sck=Pin(10), mosi=Pin(11), miso=None)
ssd = SSD(spi, height=135, width=240, dc=Pin(8), cs=CS, rst=RST, disp_mode=LANDSCAPE, display=TDISPLAY)

#=====================================================================

ssd.fill(0)
ssd.line(0, 0, ssd.width - 1, ssd.height - 1, GREEN)  # Green diagonal corner-to-corner
ssd.rect(0, 0, 15, 15, RED)  # Red square at top left
ssd.rect(ssd.width -15, ssd.height -15, 15, 15, BLUE)  # Blue square at bottom right
ssd.show()

FeK9
Posts: 33
Joined: Sun Jan 20, 2019 8:19 am

Re: Help with a Wave Pi Pico LCD 1.14

Post by FeK9 » Fri Dec 17, 2021 4:47 pm

curt wrote:
Thu Dec 16, 2021 6:41 pm
On my ESP32 TTGO I use the precompiled firmware from here:
https://github.com/russhughes/st7789_mpy
There is firmware available for the PI Pico

Curt
Hi @curt

Thx's for the link, will look at in a day or two... :)

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Help with a Wave Pi Pico LCD 1.14

Post by pythoncoder » Fri Dec 17, 2021 5:54 pm

I'll do my best to sort this out once my display arrives...
Peter Hinch
Index to my micropython libraries.

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Help with a Wave Pi Pico LCD 1.14

Post by pythoncoder » Sun Dec 19, 2021 4:53 pm

[EDIT] I now have some hardware. My preliminary conclusions is that there is something odd about the SPI hardware interface. I have a driver based on Waveshare's Python driver which works with micro-gui (and CWriter) but performance is poor. I will study the schematics and try to figure out the issue. I'm sure it can be made to work properly because their demo works fine, but something isn't quite right.

I'll report back in a day or two.
Peter Hinch
Index to my micropython libraries.

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Fixed

Post by pythoncoder » Tue Dec 21, 2021 9:05 am

I've found the problem. The clowns at Waveshare use GP8 for the d/c signal when it is defined as SPI(1) MISO. This means that in your hardware configuration file you must define the SPI bus with miso=None before you instantiate the d/c pin. As luck would have it my config file did it in the opposite order. The following config enables micro-gui, nano-gui and CWriter to work, but in landscape mode only. Lines after the SSD instantiation are for micro-gui only. Their own driver also only supports landscape.

Code: Select all

# hardware_setup.py Customise for your hardware config
# Released under the MIT License (MIT). See LICENSE.
# Copyright (c) 2021 Peter Hinch, Ihor Nehrutsa

# Supports:
# Waveshare Pico LCD 1.14" 135*240(Pixel) based on ST7789V

from machine import Pin, SPI
import gc

from drivers.st7789.st7789_4bit import *
SSD = ST7789

gc.collect()  # Precaution before instantiating framebuf
# Conservative low baudrate. Can go to 62.5MHz.
spi = SPI(1, 30_000_000, sck=Pin(10), mosi=Pin(11), miso=None)
pcs = Pin(9, Pin.OUT, value=1)
prst = Pin(12, Pin.OUT, value=1)
pbl = Pin(13, Pin.OUT, value=1)
pdc = Pin(8, Pin.OUT, value=0)

ssd = SSD(spi, height=135, width=240, dc=pdc, cs=pcs, rst=prst, disp_mode=LANDSCAPE, display=TDISPLAY)

from gui.core.ugui import Display
# Create and export a Display instance
# Define control buttons
nxt = Pin(20, Pin.IN, Pin.PULL_UP)  # Move to next control
sel = Pin(3, Pin.IN, Pin.PULL_UP)  # Operate current control
prev = Pin(16, Pin.IN, Pin.PULL_UP)  # Move to previous control
increase = Pin(2, Pin.IN, Pin.PULL_UP)  # Increase control's value
decrease = Pin(18, Pin.IN, Pin.PULL_UP)  # Decrease control's value
display = Display(ssd, nxt, sel, prev, increase, decrease)
[EDIT]
Now works in landscape, portrait, upside-down and reflected modes. See updated setup examples and docs. Note that the driver itself needed no change: only the setup file is new.
Peter Hinch
Index to my micropython libraries.

FeK9
Posts: 33
Joined: Sun Jan 20, 2019 8:19 am

Re: Fixed

Post by FeK9 » Thu Dec 23, 2021 9:42 am

pythoncoder wrote:
Tue Dec 21, 2021 9:05 am
I've found the problem. The clowns at Waveshare use GP8 for the d/c signal when it is defined as SPI(1) MISO. This means that in your hardware configuration file you must define the SPI bus with miso=None before you instantiate the d/c pin. As luck would have it my config file did it in the opposite order. The following config enables micro-gui, nano-gui and CWriter to work, but in landscape mode only. Lines after the SSD instantiation are for micro-gui only. Their own driver also only supports landscape.

Code: Select all

# hardware_setup.py Customise for your hardware config
# Released under the MIT License (MIT). See LICENSE.
# Copyright (c) 2021 Peter Hinch, Ihor Nehrutsa

# Supports:
# Waveshare Pico LCD 1.14" 135*240(Pixel) based on ST7789V

from machine import Pin, SPI
import gc

from drivers.st7789.st7789_4bit import *
SSD = ST7789

gc.collect()  # Precaution before instantiating framebuf
# Conservative low baudrate. Can go to 62.5MHz.
spi = SPI(1, 30_000_000, sck=Pin(10), mosi=Pin(11), miso=None)
pcs = Pin(9, Pin.OUT, value=1)
prst = Pin(12, Pin.OUT, value=1)
pbl = Pin(13, Pin.OUT, value=1)
pdc = Pin(8, Pin.OUT, value=0)

ssd = SSD(spi, height=135, width=240, dc=pdc, cs=pcs, rst=prst, disp_mode=LANDSCAPE, display=TDISPLAY)

from gui.core.ugui import Display
# Create and export a Display instance
# Define control buttons
nxt = Pin(20, Pin.IN, Pin.PULL_UP)  # Move to next control
sel = Pin(3, Pin.IN, Pin.PULL_UP)  # Operate current control
prev = Pin(16, Pin.IN, Pin.PULL_UP)  # Move to previous control
increase = Pin(2, Pin.IN, Pin.PULL_UP)  # Increase control's value
decrease = Pin(18, Pin.IN, Pin.PULL_UP)  # Decrease control's value
display = Display(ssd, nxt, sel, prev, increase, decrease)
[EDIT]
Now works in landscape, portrait, upside-down and reflected modes. See updated setup examples and docs. Note that the driver itself needed no change: only the setup file is new.
Thx Peter

Got the 'simple.py' example working on the 'Wave Pi Pico LCD 1.14' with it's toggle joy stick, now to distil / simplify.
I only need CWriter larger fonts as this 1.14" screen is tiny, I think even a 21 year old with 20 20 vision would have a problem
reading it.

:)

Post Reply