Skip to content

Commit

Permalink
Merge pull request adafruit#258 from makermelissa/master
Browse files Browse the repository at this point in the history
Added previously removed sendCommand() overload to fix rotation issue.
  • Loading branch information
PaintYourDragon authored Dec 20, 2019
2 parents 4169843 + 70950e3 commit 6f16f7a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
31 changes: 31 additions & 0 deletions Adafruit_SPITFT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1761,6 +1761,37 @@ uint16_t Adafruit_SPITFT::color565(uint8_t red, uint8_t green, uint8_t blue) {
return ((red & 0xF8) << 8) | ((green & 0xFC) << 3) | (blue >> 3);
}

/*!
@brief Adafruit_SPITFT Send Command handles complete sending of commands and data
@param commandByte The Command Byte
@param dataBytes A pointer to the Data bytes to send
@param numDataBytes The number of bytes we should send
*/
void Adafruit_SPITFT::sendCommand(uint8_t commandByte, uint8_t *dataBytes, uint8_t numDataBytes) {
SPI_BEGIN_TRANSACTION();
if(_cs >= 0) SPI_CS_LOW();

SPI_DC_LOW(); // Command mode
spiWrite(commandByte); // Send the command byte

SPI_DC_HIGH();
for (int i=0; i<numDataBytes; i++) {
spiWrite(*dataBytes); // Send the data bytes
dataBytes++;
if((connection == TFT_PARALLEL) && tft8.wide) {
SPI_WRITE16(*(uint16_t *)dataBytes);
dataBytes += 2;
} else {
spiWrite(*dataBytes); // Send the data bytes
dataBytes++;
}
}

if(_cs >= 0) SPI_CS_HIGH();
SPI_END_TRANSACTION();
}


/*!
@brief Adafruit_SPITFT Send Command handles complete sending of commands and data
@param commandByte The Command Byte
Expand Down
1 change: 1 addition & 0 deletions Adafruit_SPITFT.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ class Adafruit_SPITFT : public Adafruit_GFX {
void startWrite(void);
// Chip deselect and/or hardware SPI transaction end as needed:
void endWrite(void);
void sendCommand(uint8_t commandByte, uint8_t *dataBytes, uint8_t numDataBytes);
void sendCommand(uint8_t commandByte, const uint8_t *dataBytes = NULL, uint8_t numDataBytes = 0);
void sendCommand16(uint16_t commandWord, const uint8_t *dataBytes = NULL, uint8_t numDataBytes = 0);
uint8_t readcommand8(uint8_t commandByte, uint8_t index = 0);
Expand Down

0 comments on commit 6f16f7a

Please sign in to comment.