Skip to content

Commit de85b76

Browse files
makermelissaladyada
authored andcommitted
Added readcommand8 to GFX (#220)
1 parent cc87251 commit de85b76

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

Adafruit_SPITFT.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1729,6 +1729,29 @@ void Adafruit_SPITFT::sendCommand(uint8_t commandByte, const uint8_t *dataBytes,
17291729
SPI_END_TRANSACTION();
17301730
}
17311731

1732+
/*!
1733+
@brief Read 8 bits of data from display configuration memory (not RAM).
1734+
This is highly undocumented/supported and should be avoided,
1735+
function is only included because some of the examples use it.
1736+
@param command
1737+
The command register to read data from.
1738+
@param index
1739+
The byte index into the command to read from.
1740+
@return Unsigned 8-bit data read from display register.
1741+
*/
1742+
/**************************************************************************/
1743+
uint8_t Adafruit_SPITFT::readcommand8(uint8_t commandByte, uint8_t index) {
1744+
uint8_t result;
1745+
startWrite();
1746+
SPI_DC_LOW(); // Command mode
1747+
spiWrite(commandByte);
1748+
SPI_DC_HIGH(); // Data mode
1749+
do {
1750+
result = spiRead();
1751+
} while(index--); // Discard bytes up to index'th
1752+
endWrite();
1753+
return result;
1754+
}
17321755

17331756
// -------------------------------------------------------------------------
17341757
// Lowest-level hardware-interfacing functions. Many of these are inline and

Adafruit_SPITFT.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ class Adafruit_SPITFT : public Adafruit_GFX {
189189
void endWrite(void);
190190
void sendCommand(uint8_t commandByte, uint8_t *dataBytes = NULL, uint8_t numDataBytes = 0);
191191
void sendCommand(uint8_t commandByte, const uint8_t *dataBytes, uint8_t numDataBytes);
192+
uint8_t readcommand8(uint8_t commandByte, uint8_t index = 0);
192193

193194
// These functions require a chip-select and/or SPI transaction
194195
// around them. Higher-level graphics primitives might start a

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=Adafruit GFX Library
2-
version=1.4.14
2+
version=1.5.0
33
author=Adafruit
44
maintainer=Adafruit <[email protected]>
55
sentence=Adafruit GFX graphics core library, this is the 'core' class that all our other graphics libraries derive from.

0 commit comments

Comments
 (0)