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

RGB565 have inverted channels for display #141

Open
dimitre opened this issue Jun 14, 2024 · 3 comments
Open

RGB565 have inverted channels for display #141

dimitre opened this issue Jun 14, 2024 · 3 comments

Comments

@dimitre
Copy link
Contributor

dimitre commented Jun 14, 2024

I've noticed today that display uses wrong colors for RGB565

this is Blue 0b111111 << 10
this is Red 0b11111 << 5
and this is Green 0b11111

Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
RGB565 r r r r r g g g g g g b b b b b
Maixduino b b b b b b r r r r r g g g g g

So channels are inverted and bit depth also, the correct order would be RGB with Green with 6 bits instead of blue.
Thank you

@dimitre
Copy link
Contributor Author

dimitre commented Jun 14, 2024

it seems to work OK on display if bits are swapped like this

uint16_t rgbto565(uint8_t r, uint8_t g, uint8_t b) {
	return ((b >> 3) << 11) | ((r>>3) << 6) | g >> 2;
}

instead of normal RGB565 bit order:

uint16_t rgbto5651(uint8_t r, uint8_t g, uint8_t b) {
	return ((b>>3) << 11) | ((g>>2) << 5) | r >> 3;
}

@Neutree
Copy link
Member

Neutree commented Jun 15, 2024

we only set invert rgb to bgr on maixcube maixamigo, but maixduino seems no need to invert anything.(it's benn long time last I play k210, so I can not remember it clearly now, you can find code in MaixPy-v1 repo)

https://github.com/sipeed/MaixPy-v1/blob/a95e2eee386a34c99fd990394fcbba19f149e149/components/drivers/lcd/src/lcd_rgb.c#L510

https://github.com/sipeed/MaixPy-v1/blob/a95e2eee386a34c99fd990394fcbba19f149e149/components/drivers/lcd/src/lcd_mcu.c#L242

@dimitre
Copy link
Contributor Author

dimitre commented Jun 15, 2024

Now I understand better, if I draw to the LCD, RGB565 is correct
but if I draw to a canvas GFXCanvas16, then COLOR_RED draws blue.

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