Skip to content

add: readPixel for ILI9341 #36

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions Adafruit_TFTLCD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,25 @@ uint16_t Adafruit_TFTLCD::readPixel(int16_t x, int16_t y) {
return (((uint16_t)r & B11111000) << 8) |
(((uint16_t)g & B11111100) << 3) |
( b >> 3);
} else if(driver == ID_9341) {

uint8_t r, g, b;

setAddrWindow( x,y,x,y);
CS_ACTIVE;
CD_COMMAND;
write8( ILI9341_MEMORYREAD);
setReadDir(); // Set up LCD data port(s) for READ operations
CD_DATA;
read8(r); // First byte back is a dummy read
read8(r);
read8(g);
read8(b);
setWriteDir(); // Restore LCD data port(s) to WRITE configuration
CS_IDLE;
return (((uint16_t)r & B11111000) << 8) |
(((uint16_t)g & B11111100) << 3) |
( b >> 3);
} else return 0;
}

Expand Down
1 change: 1 addition & 0 deletions registers.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
#define ILI9341_COLADDRSET 0x2A
#define ILI9341_PAGEADDRSET 0x2B
#define ILI9341_MEMORYWRITE 0x2C
#define ILI9341_MEMORYREAD 0x2E
#define ILI9341_PIXELFORMAT 0x3A
#define ILI9341_FRAMECONTROL 0xB1
#define ILI9341_DISPLAYFUNC 0xB6
Expand Down