Skip to content

Extend the pixelRead() function to allow reading of pixels from ILI9341. #53

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
21 changes: 19 additions & 2 deletions Adafruit_TFTLCD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1000,8 +1000,25 @@ uint16_t Adafruit_TFTLCD::readPixel(int16_t x, int16_t y) {
CS_IDLE;
return (((uint16_t)r & B11111000) << 8) | (((uint16_t)g & B11111100) << 3) |
(b >> 3);
} else
return 0;
} else if(driver == ID_9341) {
uint8_t r, g, b;
setAddrWindow(x, y, width()-1, height()-1);
CS_ACTIVE;
CD_COMMAND;
write8(ILI9341_MEMORYREAD);
setReadDir();
CD_DATA;
delayMicroseconds(50);
read8(r);
read8(r);
read8(g);
read8(b);
setWriteDir();
CS_IDLE;
return (((uint16_t)r & B11111000) << 8) | (((uint16_t)g & B11111100) << 3) |
(b >> 3);

} else return 0;
}

// Ditto with the read/write port directions, as above.
Expand Down
1 change: 1 addition & 0 deletions registers.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,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