1.3" SPI Colour LCD (240x240) - Display 2 lines of Text

I’ve got this display working very well, can scroll text, show images etc. But what I’d really like to do is show multiple lines of text but can’t figure out how to. Can anyone help?

Raspberry Pi zero, latest Raspian and using Python ST7789 library.

Example of what I’d like to display where the values after the hyphens come from variables:
Cur Temp - 23.5
Rqd Temo - 25.0
Prg - On
Boost Until - 23:00

Thanks

Gareth

This is the code for the the Enviro+ ST7735 I use to display temp and humidity on two lines. It may work with the ST7789.
try:
while True:
pass

temperature = "Temp: {:.2f} *F".format(bme280.get_temperature()*1.8+32)
humidity = "Hum: {:.2f} %".format(bme280.get_humidity())
x = 0
y = 0
draw.text((x, y), temperature, font=font, fill=colour)
x=0
y=35
draw.text((x, y), humidity, font=font, fill=colour)

disp.display(img)

time.sleep(3)

rect_colour = (0, 0, 0)
draw.rectangle((0, 0, 160, 80), rect_colour)

I converted the temp to deg F because I’m in the US. I hope this helps.

Thanks Crowbot,

I’m struggling with things like draw not defined when I try this, do you have the code you use to setup the display class?

Thanks

Gareth

import ST7735
from PIL import Image, ImageDraw, ImageFont
from smbus import SMBus
from bme280 import BME280
import time

disp = ST7735.ST7735(
port=0,
cs=1,
dc=9,
backlight=8,
rotation=270,
spi_speed_hz=10000000
)

disp.begin()

WIDTH = disp.width
HEIGHT = disp.height

img = Image.new(‘RGB’, (WIDTH, HEIGHT), color=(0, 0, 0))
draw = ImageDraw.Draw(img)

rect_colour = (0, 0, 0)
draw.rectangle((0, 0, 160, 80), rect_colour)

bus = SMBus(1)
bme280 = BME280(i2c_dev=bus)

font_size = 25
font = ImageFont.truetype(“fonts/Asap/Asap-Bold.ttf”, font_size)
colour = (255, 255, 255)

This is the setup I use. Straight from the example file. You should be able to cobble it from there.

Thanks very much for this, was able to identify the mistake I was making using this.

Appreciated

Gareth

Glad you got it working. It’s very cute. :)