Skip to content

Commit 6f16f7a

Browse files
Merge pull request #258 from makermelissa/master
Added previously removed sendCommand() overload to fix rotation issue.
2 parents 4169843 + 70950e3 commit 6f16f7a

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

Adafruit_SPITFT.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1761,6 +1761,37 @@ uint16_t Adafruit_SPITFT::color565(uint8_t red, uint8_t green, uint8_t blue) {
17611761
return ((red & 0xF8) << 8) | ((green & 0xFC) << 3) | (blue >> 3);
17621762
}
17631763

1764+
/*!
1765+
@brief Adafruit_SPITFT Send Command handles complete sending of commands and data
1766+
@param commandByte The Command Byte
1767+
@param dataBytes A pointer to the Data bytes to send
1768+
@param numDataBytes The number of bytes we should send
1769+
*/
1770+
void Adafruit_SPITFT::sendCommand(uint8_t commandByte, uint8_t *dataBytes, uint8_t numDataBytes) {
1771+
SPI_BEGIN_TRANSACTION();
1772+
if(_cs >= 0) SPI_CS_LOW();
1773+
1774+
SPI_DC_LOW(); // Command mode
1775+
spiWrite(commandByte); // Send the command byte
1776+
1777+
SPI_DC_HIGH();
1778+
for (int i=0; i<numDataBytes; i++) {
1779+
spiWrite(*dataBytes); // Send the data bytes
1780+
dataBytes++;
1781+
if((connection == TFT_PARALLEL) && tft8.wide) {
1782+
SPI_WRITE16(*(uint16_t *)dataBytes);
1783+
dataBytes += 2;
1784+
} else {
1785+
spiWrite(*dataBytes); // Send the data bytes
1786+
dataBytes++;
1787+
}
1788+
}
1789+
1790+
if(_cs >= 0) SPI_CS_HIGH();
1791+
SPI_END_TRANSACTION();
1792+
}
1793+
1794+
17641795
/*!
17651796
@brief Adafruit_SPITFT Send Command handles complete sending of commands and data
17661797
@param commandByte The Command Byte

Adafruit_SPITFT.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ class Adafruit_SPITFT : public Adafruit_GFX {
194194
void startWrite(void);
195195
// Chip deselect and/or hardware SPI transaction end as needed:
196196
void endWrite(void);
197+
void sendCommand(uint8_t commandByte, uint8_t *dataBytes, uint8_t numDataBytes);
197198
void sendCommand(uint8_t commandByte, const uint8_t *dataBytes = NULL, uint8_t numDataBytes = 0);
198199
void sendCommand16(uint16_t commandWord, const uint8_t *dataBytes = NULL, uint8_t numDataBytes = 0);
199200
uint8_t readcommand8(uint8_t commandByte, uint8_t index = 0);

0 commit comments

Comments
 (0)