Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ST7789 might have incorrect RAMCTRL setting, giving slightly incorrect colours on pico display 2 #1040

Closed
trepidacious opened this issue Dec 22, 2024 · 1 comment

Comments

@trepidacious
Copy link

While writing a rust driver for the pico display 2, I ran into an issue where using a minimum brightness green pixel (RGB 0,1,0) gives a grey colour rather than green. The fix for this is setting the RAMCTRL (0xB0) register to 0x00, 0xC0 to replace the default. This ensures the correct bit ordering is used for RGB565 data. Apparently whether this is needed can depend on how the ST7789 pins are connected, I've only observed the issue on the pico display 2 but it might well be the same on other ST7789 displays.

While debugging the issue in my code I checked your driver code in st7789.cpp and it doesn't seem to set RAMCTRL, so I thought this might be worth looking at in case it needs the new setting?

There's a good description of the same problem happening from arduino code here.

@Gadgetoid
Copy link
Member

Thanks. We weren't able to replicate this until we removed our custom (manufacturer supplied, iirc) gamma settings (which give a noticeable improvement in brightness variation across the screen.)

With our gamma, the grey issue seems to be lost at the low end of the brightness scale, but skipping this and using the default gamma immediately shows very odd grey artefacts toward lower brightnesses. (And also really badly blows the screen out to the point where there's very little dynamic range)

Tests were conducted with this script and eyeballed:

import time
from picographics import PicoGraphics, DISPLAY_PICO_DISPLAY_2, PEN_RGB565 as PEN

display = PicoGraphics(display=DISPLAY_PICO_DISPLAY_2, pen_type=PEN)

WIDTH, HEIGHT = display.get_bounds()

bar = WIDTH // 4

for y in range(HEIGHT):
    c = display.create_pen((8 + y) % 255, 0, 0)
    display.set_pen(c)
    display.line(0, y, bar, y)
    c = display.create_pen(0, (4 + y) % 255, 0)
    display.set_pen(c)
    display.line(bar, y, bar * 2, y)
    c = display.create_pen(0, 0, (8 + y) % 255)
    display.set_pen(c)
    display.line(bar * 2, y, bar * 3, y)
    
display.update()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants