luma.lcd icon indicating copy to clipboard operation
luma.lcd copied to clipboard

Colors are inverted on certain ili9486 displays.

Open JosephHobbs opened this issue 5 months ago • 0 comments

Type of Raspberry Pi

Raspberry Pi 5 4GB

Linux Kernel version

https://github.com/rm-hull/luma.lcd/blob/3cca044e791282f8df6f6801d1d52825084cdd13/luma/lcd/device.py#L826

Issue

I am currently using a Raspberry PI 5 (4GB) with this ILI9486-based device. I've been able to get it to successfully display content, but all colors are inverted.

from luma.core.interface.serial import spi
from luma.core.render import canvas
from luma.lcd.device import ili9486
import time

serial = spi(port=0, device=0, gpio_DC=24, gpio_RST=25)
device = ili9486(serial_interface=serial, width=320, height=480, rotate=1)

with canvas(device) as draw:
    draw.rectangle(device.bounding_box, outline="white", fill="black")
    draw.text((30, 40), "Hello World", fill="red")

time.sleep(5)

In reviewing device.py, it looks like this particular display is coded specifically to invert colors. This is an issue given my display evidently built opposite this. If I send a command 0x20 to disable inversion, the display shows colors as expected.

from luma.core.interface.serial import spi
from luma.core.render import canvas
from luma.lcd.device import ili9486
import time

serial = spi(port=0, device=0, gpio_DC=24, gpio_RST=25)
device = ili9486(serial_interface=serial, width=320, height=480, rotate=1)

device.command(0x20)     # disable display inversion

with canvas(device) as draw:
    draw.rectangle(device.bounding_box, outline="white", fill="black")
    draw.text((30, 40), "Hello World", fill="red")

time.sleep(5)

Would it make sense to add a parameter to __init__() to control display inversion? This would ensure either display scenario would be supported...

JosephHobbs avatar Aug 26 '24 01:08 JosephHobbs