Added readcommand8 to GFX (#220)

This commit is contained in:
Melissa LeBlanc-Williams 2019-05-10 15:12:05 -07:00 committed by Limor "Ladyada" Fried
parent cc87251ef0
commit de85b7696f
3 changed files with 25 additions and 1 deletions

View File

@ -1729,6 +1729,29 @@ void Adafruit_SPITFT::sendCommand(uint8_t commandByte, const uint8_t *dataBytes,
SPI_END_TRANSACTION(); SPI_END_TRANSACTION();
} }
/*!
@brief Read 8 bits of data from display configuration memory (not RAM).
This is highly undocumented/supported and should be avoided,
function is only included because some of the examples use it.
@param command
The command register to read data from.
@param index
The byte index into the command to read from.
@return Unsigned 8-bit data read from display register.
*/
/**************************************************************************/
uint8_t Adafruit_SPITFT::readcommand8(uint8_t commandByte, uint8_t index) {
uint8_t result;
startWrite();
SPI_DC_LOW(); // Command mode
spiWrite(commandByte);
SPI_DC_HIGH(); // Data mode
do {
result = spiRead();
} while(index--); // Discard bytes up to index'th
endWrite();
return result;
}
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
// Lowest-level hardware-interfacing functions. Many of these are inline and // Lowest-level hardware-interfacing functions. Many of these are inline and

View File

@ -189,6 +189,7 @@ class Adafruit_SPITFT : public Adafruit_GFX {
void endWrite(void); void endWrite(void);
void sendCommand(uint8_t commandByte, uint8_t *dataBytes = NULL, uint8_t numDataBytes = 0); void sendCommand(uint8_t commandByte, uint8_t *dataBytes = NULL, uint8_t numDataBytes = 0);
void sendCommand(uint8_t commandByte, const uint8_t *dataBytes, uint8_t numDataBytes); void sendCommand(uint8_t commandByte, const uint8_t *dataBytes, uint8_t numDataBytes);
uint8_t readcommand8(uint8_t commandByte, uint8_t index = 0);
// These functions require a chip-select and/or SPI transaction // These functions require a chip-select and/or SPI transaction
// around them. Higher-level graphics primitives might start a // around them. Higher-level graphics primitives might start a

View File

@ -1,5 +1,5 @@
name=Adafruit GFX Library name=Adafruit GFX Library
version=1.4.14 version=1.5.0
author=Adafruit author=Adafruit
maintainer=Adafruit <info@adafruit.com> maintainer=Adafruit <info@adafruit.com>
sentence=Adafruit GFX graphics core library, this is the 'core' class that all our other graphics libraries derive from. sentence=Adafruit GFX graphics core library, this is the 'core' class that all our other graphics libraries derive from.