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()