From de85b7696fdc77983557d74f2320105583f1722c Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Fri, 10 May 2019 15:12:05 -0700 Subject: [PATCH] Added readcommand8 to GFX (#220) --- Adafruit_SPITFT.cpp | 23 +++++++++++++++++++++++ Adafruit_SPITFT.h | 1 + library.properties | 2 +- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/Adafruit_SPITFT.cpp b/Adafruit_SPITFT.cpp index 846b3d6..2bdfbb0 100644 --- a/Adafruit_SPITFT.cpp +++ b/Adafruit_SPITFT.cpp @@ -1729,6 +1729,29 @@ void Adafruit_SPITFT::sendCommand(uint8_t commandByte, const uint8_t *dataBytes, 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 diff --git a/Adafruit_SPITFT.h b/Adafruit_SPITFT.h index 66342a2..b41868a 100644 --- a/Adafruit_SPITFT.h +++ b/Adafruit_SPITFT.h @@ -189,6 +189,7 @@ class Adafruit_SPITFT : public Adafruit_GFX { void endWrite(void); 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); + uint8_t readcommand8(uint8_t commandByte, uint8_t index = 0); // These functions require a chip-select and/or SPI transaction // around them. Higher-level graphics primitives might start a diff --git a/library.properties b/library.properties index 2bc14fd..96adbc1 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Adafruit GFX Library -version=1.4.14 +version=1.5.0 author=Adafruit maintainer=Adafruit sentence=Adafruit GFX graphics core library, this is the 'core' class that all our other graphics libraries derive from.