adafruit / Adafruit_CircuitPython_RGB_Display

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

Red and Blue switched on ST7735R #5

Closed Andon-A closed 6 years ago

Andon-A commented 6 years ago

Running a ST7735R on a Feather M0 Basic, and when it should display red - IE, color565(255,0,0) - it displays blue instead, and the reverse is also true.

The super simple code I am using:

import busio
import digitalio
import board
import time
from adafruit_rgb_display import color565
import adafruit_rgb_display.st7735 as st7735

spi = busio.SPI(clock=board.SCK, MOSI=board.MOSI, MISO=board.MISO)

display = st7735.ST7735R(spi, cs=digitalio.DigitalInOut(board.D9), dc=digitalio.DigitalInOut(board.D10), rst=digitalio.DigitalInOut(board.D11))

while True:
    time.sleep(2.5)
    print("RED")
    display.fill(color565(255,0,0))
    time.sleep(2.5)
    print("BLUE")
    display.fill(color565(0,0,255))

for completeness sake, I've removed the other driver files (hx8353, ili9341, etc) from the folder to save on space, as the M0 basic has almost none.

ladyada commented 6 years ago

hiya which adafruit display are you using?

Andon-A commented 6 years ago

100% honesty: It's not an Adafruit display, it's a minimalist knockoff one I've had lying around for ages. It's the ST7735R display just like the breakout or the bare screen.

This specific screen works 100% perfectly with the Arduino Library but when loading the CircuitPython library red and blue are swapped. I've worked with these screens extensively in the past so they should be identical in function to the Adafruit versions.

Attempting to use the ST7735 non-R CircuitPython initializer results in nothing being displayed on the screen at all.

ladyada commented 6 years ago

sounds like they have different color order, you'll have to mod the library to support it!

Andon-A commented 6 years ago

With my work using these screens previously, I'm inclined to disagree. As mentioned, they work perfectly with the Arduino libraries.

That said, I'll have an actual, proper Adafruit screen in my hands tomorrow to be 100% certain. And swapping colors in color565() is super easy if it does turn out to be the case. It's also worth noting that I don't expect you to worry at all about non-Adafruit things. You've got enough Adafruit products to deal with as it is.

ladyada commented 6 years ago

awesome, let us know!

Andon-A commented 6 years ago

Breakout board arrived earlier today, and I just got home, soldered the header on, and can confirm that the blue and red are swapped.

ladyada commented 6 years ago

huh! ok we'll take a look - @tdicola good one for you to check out!

tannewt commented 6 years ago

Has this been fixed?

Andon-A commented 6 years ago

Last I heard, @kattni had verified it when going through doing her testing, but it has't been fixed yet to my knowledge.

kattni commented 6 years ago

I was able to replicate this when testing the linting PR. To my knowledge, it has not been fixed.

deshipu commented 6 years ago

This is simply a wrong RGB mode in the initialization, in the MADCTL register — it needs to be 0x00 for RGB color. By the way, we could have a parameter for that register to set the orientation, for example 0xc0 rotates by 90°.

kattni commented 6 years ago

Issue is no longer present. We're unsure how we reproduced the bug in the first place. Whatever it is, it's fixed for now.