adafruit / Adafruit_CircuitPython_RGB_Display

Drivers for RGB displays for Adafruit CircuitPython.
MIT License
133 stars 52 forks source link

Inverted colors when using PITFT 2.8" TFT 320X240 + CAPACITIVE #77

Closed tubededentifrice closed 4 years ago

tubededentifrice commented 4 years ago

When using a PITFT 2.8" TFT 320X240 + CAPACITIVE ( https://www.adafruit.com/product/1983 ), colors are inverted.

disp.fill(color565(255, 0, 0))  # red => Fills the screen with blue (cyan)
disp.fill(color565(0, 0, 255))  # blue => Fills with Yellow
disp.fill(color565(0, 255, 0))  # green => Magenta

It's probably just and initialization issue, but I don't know enough to fix it myself (besides manually inverting colors).

The display is initialized with

disp = ili9341.ILI9341(
    spi,
    rotation=270,  # 2.2", 2.4", 2.8", 3.2" ILI9341
    cs=cs_pin,
    dc=dc_pin,
    rst=reset_pin,
    baudrate=BAUDRATE,
)

otherwise it's just the sample from https://github.com/adafruit/Adafruit_CircuitPython_RGB_Display#22-24-28-32-tft

When using the sample AnimatedGif the images look inverted as well.

Thanks.

ladyada commented 4 years ago

is this on a raspberry pi or...?

tubededentifrice commented 4 years ago

Yep, it's a Raspberry Pi 3B+, sorry forgetting mentioning it.

ladyada commented 4 years ago

make sure you've updated all your python libraries, we've made bug fixes recently

tubededentifrice commented 4 years ago

Gosh, this is a brand new install, and though everything was up to date already, but after upgrading everything the colors are now the way they should :)

Thanks you!

For future people hitting this issue, just do:

apt update && apt dist-upgrade
pip3 list --outdated --format=freeze | grep -v '^\-e' | cut -d = -f 1  | xargs -n1 pip3 install -U
tubededentifrice commented 4 years ago

In reality, I think I actually made it work because I accidentally mixed up 2 examples. Here's what work (the provided sample still doesn't and shows, for example, green instead of blue):

import digitalio
import board

spi = board.SPI()
display = ili9341.ILI9341(
    spi,
    rotation=270,
    cs=digitalio.DigitalInOut(board.CE0),
    dc=digitalio.DigitalInOut(board.D25),
    rst=digitalio.DigitalInOut(board.D24),
    baudrate=64000000
)