-
Notifications
You must be signed in to change notification settings - Fork 58
Open
Description
Hi
1st, many thks for sharing this lib, It's so easy to set up ant it works fine.
I am using a MSP3520 ILI9488 3.5" display.
I am experiencing Latency when updating a menu item selection.
Here is the script :
from luma.core.interface.serial import spi
from luma.core.render import canvas
from luma.lcd.device import ili9488
from PIL import Image, ImageOps, ImageDraw,ImageFont
import os
import time
import RPi.GPIO as GPIO
serial = spi(port=0, device=0, gpio_DC=23, gpio_RST=24, spi_speed_hz=32000000)
device = ili9488(serial, rotate=2,
gpio_LIGHT=18, active_low=False) # BACKLIGHT PIN = GPIO 18, active High
device.backlight(False) # Turn OFF backlight first
BACKLIGHT_PIN = 18
pwm = GPIO.PWM(BACKLIGHT_PIN, 1000)
pwm.start(0)
image = Image.open("bbd.jpg")
img_resized = image.resize((200, 200), Image.LANCZOS)
background=Image.new(device.mode,device.size,"black")
background.paste(img_resized)
draw=ImageDraw.Draw(background)
font=ImageFont.load_default()
font2=ImageFont.truetype('/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf',30)
menu=["item1","item2","item3","item4","item5","item6","item7","item8","item9","item10","item11","item12"]
def fade_in():
for duty_cycle in range(0, 101, 1):
pwm.ChangeDutyCycle(duty_cycle)
time.sleep(0.01)
def fade_out():
for duty_cycle in range(100, -1, -1):
pwm.ChangeDutyCycle(duty_cycle)
time.sleep(0.001)
def init_menu(menu,i):
left=200
width=500
nb_lines=9
size_menu=len(menu)
bloc_indice=i//nb_lines
line_select=i%nb_lines
decalage=bloc_indice*nb_lines
#draw=ImageDraw.Draw(img_resized)
for j in range(0,nb_lines):
if j+decalage<len(menu):
if j==line_select:
color="yellow"
else:
color="blue"
draw.rectangle((left,j*35,min(left+width,475),min(j*35+35,318)),outline="white",fill=color)
draw.text((left,j*35),menu[j+decalage],font=font2,fill="red")
else:
draw.rectangle((left,j*35,min(left+width,475),min(j*35+35,318)),outline="black",fill="black")
device.display(background)
images_folder = "/home/pierre"
files = os.listdir(images_folder)
jpg_files = [file for file in files if file.endswith('.jpg')]
jpg_file_list = sorted(jpg_files)
l=7
while True:
init_menu(menu,l)
l-=1
l=l%len(menu)
fade_in()
time.sleep(0.5)
fade_out()
if I comment out the lines fade_in() and fade_out() in the loop, there is visible latency when changing menu_item selection :
PXL_20251203_103737994.TS-ezgif.com-gif-maker.mp4
With fading in and out, there are lags when updating the screen :
PXL_20251203_103629470.TS-ezgif.com-gif-maker.mp4
Is it possible to make the display run smoothly ? Thks
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels