It's easy enough to write data to this display thanks to the example code provided, but none of the examples I've seen show how to read data back. I need to be able to determine pixel color for alpha blending, but haven't had any luck reading the GRAM register to get the color. As far as I understand, I need to set the pixel location 'easy enough', make a dummy read, and then read the two 8 bit chunks, but despite trying a number of combinations I'm yet to get any coherent data back.
I've searched high and low on google, but most examples seems to be write-only. Has anyone here figured out the secret formula to get a pixel back? This is my current (hopeless) attempt:
/*************************************************/
uint16_t lcdGetPixel(uint16_t x, uint16_t y)
{
ili9325SetCursor(x, y);
return (ili9325Read());
}
/*************************************************/
uint16_t ili9325Read(void)
{
uint8_t argh, argl;
CLR_CS;
SET_CD;
// set GPIO pins to input
ILI9325_GPIO2DATA_SETINPUT;
CLR_RD;
ili9325Delay(50);
// Dummy read
argl = GPIO_GPIO2DATA >> ILI9325_DATA_OFFSET;
SET_RD;
ili9325Delay(50);
// low byte
argl = GPIO_GPIO2DATA >> ILI9325_DATA_OFFSET;
SET_RD;
ili9325Delay(50);
CLR_RD;
ili9325Delay(50);
// high byte
argh = GPIO_GPIO2DATA >> ILI9325_DATA_OFFSET;
SET_RD;
// Set GPIO pins back to output
ILI9325_GPIO2DATA_SETOUTPUT;
SET_CS;
return argh << 8 | argl;
}
It would definately be helpful to see this added to the examples since one-way communication definately limits you in how much you can take advantage of the LCDs.
I've searched high and low on google, but most examples seems to be write-only. Has anyone here figured out the secret formula to get a pixel back? This is my current (hopeless) attempt:
/*************************************************/
uint16_t lcdGetPixel(uint16_t x, uint16_t y)
{
ili9325SetCursor(x, y);
return (ili9325Read());
}
/*************************************************/
uint16_t ili9325Read(void)
{
uint8_t argh, argl;
CLR_CS;
SET_CD;
// set GPIO pins to input
ILI9325_GPIO2DATA_SETINPUT;
CLR_RD;
ili9325Delay(50);
// Dummy read
argl = GPIO_GPIO2DATA >> ILI9325_DATA_OFFSET;
SET_RD;
ili9325Delay(50);
// low byte
argl = GPIO_GPIO2DATA >> ILI9325_DATA_OFFSET;
SET_RD;
ili9325Delay(50);
CLR_RD;
ili9325Delay(50);
// high byte
argh = GPIO_GPIO2DATA >> ILI9325_DATA_OFFSET;
SET_RD;
// Set GPIO pins back to output
ILI9325_GPIO2DATA_SETOUTPUT;
SET_CS;
return argh << 8 | argl;
}
It would definately be helpful to see this added to the examples since one-way communication definately limits you in how much you can take advantage of the LCDs.
Looking for additional LCD resources? Check out our LCD blog for the latest developments in LCD technology.