Skip to content
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
26 changes: 11 additions & 15 deletions pin_magic.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,21 +202,17 @@
}

#else // Mega w/Breakout board

#define write8inline(d) \
{ \
PORTA = (d); \
WR_STROBE; \
}
#define read8inline(result) \
{ \
RD_ACTIVE; \
DELAY7; \
result = PINA; \
RD_IDLE; \
}
#define setWriteDirInline() DDRA = 0xff
#define setReadDirInline() DDRA = 0
#define write8inline(d) {\
PORTH &= ~(0x78);\
PORTH |= ((d&0xC0) >> 3) | ((d&0x3) << 5);\
PORTE &= ~(0x38);\
PORTE |= ((d & 0xC) << 2) | ((d & 0x20) >> 2);\
PORTG &= ~(0x20);\
PORTG |= (d & 0x10) << 1; \
WR_STROBE; }
#define read8inline(result) { RD_ACTIVE; DELAY7; result = (PINH & 0x60) >> 5;result |= (PINH & 0x18) << 3;result |= (PINE & 0x8) << 2;result |= (PINE & 0x30) >> 2;result |= (PING & 0x20) >> 1;RD_IDLE;}
#define setWriteDirInline() { DDRH |= 0x78;DDRE |= 0x38;DDRG |= 0x20; }
#define setReadDirInline() { DDRH &= ~0x78;DDRE &= ~0x38;DDRG &= ~(0x20); }

#endif

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