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

Conversion from 16bpp to 8bpp for drawPixel() and drawPixels() incorrect. #149

Open
davewill opened this issue May 12, 2020 · 1 comment

Comments

@davewill
Copy link

davewill commented May 12, 2020

I noticed that I was getting odd colors that didn't match other elements on my screen drawn with the same colors. Pixels drawn with fillRect() had the correct colors, but pixels drawn with drawPixels() didn't. I tracked it down to this function in RA8875.h:

//convert a 16bit color(565) into 8bit color(332) as requested by RA8875 datasheet
inline __attribute__((always_inline))
	uint8_t _color16To8bpp(uint16_t color) {
		return ((color & 0x3800) >> 6 | (color & 0x00E0) >> 3 | (color & 0x0003));
	}

It's taking the low-order bits of the 565 color instead of the high-order bits. Correcting it to this:

//convert a 16bit color(565) into 8bit color(332) as requested by RA8875 datasheet
inline __attribute__((always_inline))
	uint8_t _color16To8bpp(uint16_t color) {
		return ((color & 0xE000) >> 8 | (color & 0x0700) >> 6 | (color & 0x0018) >> 3);
	}

Fixed my problem nicely.

What I also need to do is create a function, drawPixels8(), that takes the pixel array already in 8-bit color. It seems a bit silly to build a line of 16-bit pixels (the source data is 4-bit IRGB) only to have drawPixels() convert them again.

@davewill
Copy link
Author

I found that this has been fixed over here: https://github.com/mjs513/RA8875/tree/RA8875_t4

It looks like that active development has moved there.

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

1 participant