0

I have the display working fine, can draw shapes and text, and can display the 240x240 pixel test .jpg image from the manufacturer. I am attempting to generate a QR code image and display it on the screen but after attempting several variations on the same basic process, the image of the QR code never displays. I've saved the .jpg file out of my python script and viewed it; it is 240x240 like the manufacturer requires and displays fine on my laptop. I've included the code I'm using below, as well as a link to the exact product if that is helpful -- any suggestions are much appreciated.

https://www.waveshare.com/1.3inch-lcd-hat.htm

import spidev as SPI
import ST7789
import time

from PIL import Image,ImageDraw,ImageFont
import qrcode

# Raspberry Pi pin configuration:
RST = 27
DC = 25
BL = 24
bus = 0 
device = 0 

# 240x240 display with hardware SPI:
disp = ST7789.ST7789(SPI.SpiDev(bus, device),RST, DC, BL)

# Initialize library.
disp.Init()

# Clear display.
disp.clear()

#generate the QR Code
img = qrcode.make("3FHipXWBarmpVmqbFax4a2g7R6vXqNxLCh")

#resize the image to 240 pixels square
resized = img.resize((240, 240))

#display the image
disp.ShowImage(resized,0,0)
user97315
  • 61
  • 1
  • 4
  • 1
    It's possible that `.ShowImage()` only works with RGB images. However, it's likely that `qrcode.make()` doesn't produce such an image - monochrome, grayscale, or palette-based would make much more sense. Converting the image to RGB might be necessary. You might also need a delay at the end of your code, I don't know if the display library might blank the screen on exit. – jasonharper Dec 22 '20 at 03:06
  • Soon after posting, I realized this as well, .convert('RGB') fixed it. Thank you for the message, will post solution. – user97315 Dec 22 '20 at 03:12
  • Have a read here about RGB, palette and greyscale PNGs... https://stackoverflow.com/a/52307690/2836621 Good luck with your project. – Mark Setchell Dec 22 '20 at 11:56

0 Answers0