adafruit / Adafruit_CircuitPython_RGB_Display

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

Switch to RGB color in the ST7735 driver #13

Closed deshipu closed 6 years ago

deshipu commented 6 years ago

Fix #5

The MADCTL (0x0b) register stores the information about the display orientation, but also the color mode (RGB or BGR). The initialization sequence used in the ST7735 and ST7735R drivers was setting BGR mode, but the code assumes RGB. As a result, the colors were wrong.

deshipu commented 6 years ago

How did you test it? Can you confirm that with this code:

import busio
import digitalio
from board import SCK, MOSI, MISO, D12, D13

from adafruit_rgb_display import color565
from adafruit_rgb_display.st7735 import ST7735R

spi = busio.SPI(clock=SCK, MOSI=MOSI, MISO=MISO)
display = ST7735R(spi, cs=digitalio.DigitalInOut(D12),
                  dc=digitalio.DigitalInOut(D13))

display.fill(color565(0xff, 0, 0))

you get a blue screen no matter if MADCTL is set to 0xc0 or 0xc8?

kattni commented 6 years ago

I tested it using that code. As discussed, I changed the MADCTL back to MADCTL, b'\xc8' and now it's correct. It shows red when it is supposed to show red.

deshipu commented 6 years ago

In this case I have no idea what caused issue #5 in the first place, as 0xc8 was the original value.

kattni commented 6 years ago

I tested it again with the current version of the lib and it works. I have no idea either.

eos1d3 commented 9 months ago

Exchange ST7735_MADCTL_BGR to ST7735_MADCTL_RGB or versa vice will fix the issue. I just fixed this problem.