mirror of
https://github.com/adafruit/Adafruit-GFX-Library.git
synced 2024-10-03 18:18:46 -04:00
move invert display and setaddrwindow to superclass
This commit is contained in:
parent
7667d32f75
commit
0d06686d45
@ -164,6 +164,24 @@ void Adafruit_SPITFT::spiWrite(uint8_t b) {
|
|||||||
* Transaction API
|
* Transaction API
|
||||||
* */
|
* */
|
||||||
|
|
||||||
|
void Adafruit_SPITFT::setAddrWindow(uint16_t x, uint16_t y, uint16_t w, uint16_t h) {
|
||||||
|
x += _xstart;
|
||||||
|
y += _ystart;
|
||||||
|
uint32_t xa = ((uint32_t)x << 16) | (x+w-1);
|
||||||
|
uint32_t ya = ((uint32_t)y << 16) | (y+h-1);
|
||||||
|
|
||||||
|
//Serial.print("X: "); Serial.println(xa, HEX);
|
||||||
|
//Serial.print("Y: "); Serial.println(ya, HEX);
|
||||||
|
|
||||||
|
writeCommand(xSetCommand); // Column addr set
|
||||||
|
SPI_WRITE32(xa);
|
||||||
|
|
||||||
|
writeCommand(ySetCommand); // Row addr set
|
||||||
|
SPI_WRITE32(ya);
|
||||||
|
|
||||||
|
writeCommand(RAMwriteCommand); // write to RAM
|
||||||
|
}
|
||||||
|
|
||||||
void inline Adafruit_SPITFT::startWrite(void){
|
void inline Adafruit_SPITFT::startWrite(void){
|
||||||
SPI_BEGIN_TRANSACTION();
|
SPI_BEGIN_TRANSACTION();
|
||||||
SPI_CS_LOW();
|
SPI_CS_LOW();
|
||||||
@ -297,6 +315,13 @@ void Adafruit_SPITFT::fillRect(int16_t x, int16_t y, int16_t w, int16_t h,
|
|||||||
endWrite();
|
endWrite();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Adafruit_SPITFT::invertDisplay(boolean i) {
|
||||||
|
startWrite();
|
||||||
|
writeCommand(i ? invertOnCommand : invertOffCommand);
|
||||||
|
endWrite();
|
||||||
|
}
|
||||||
|
|
||||||
// Adapted from https://github.com/PaulStoffregen/ILI9341_t3
|
// Adapted from https://github.com/PaulStoffregen/ILI9341_t3
|
||||||
// by Marc MERLIN. See examples/pictureEmbed to use this.
|
// by Marc MERLIN. See examples/pictureEmbed to use this.
|
||||||
// 5/6/2017: function name and arguments have changed for compatibility
|
// 5/6/2017: function name and arguments have changed for compatibility
|
||||||
|
@ -42,7 +42,7 @@ class Adafruit_SPITFT : public Adafruit_GFX {
|
|||||||
void writeFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color);
|
void writeFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color);
|
||||||
|
|
||||||
// Transaction API not used by GFX
|
// Transaction API not used by GFX
|
||||||
virtual void setAddrWindow(uint16_t x, uint16_t y, uint16_t w, uint16_t h) = 0;
|
void setAddrWindow(uint16_t x, uint16_t y, uint16_t w, uint16_t h);
|
||||||
void writePixel(uint16_t color);
|
void writePixel(uint16_t color);
|
||||||
void writePixels(uint16_t * colors, uint32_t len);
|
void writePixels(uint16_t * colors, uint32_t len);
|
||||||
void writeColor(uint16_t color, uint32_t len);
|
void writeColor(uint16_t color, uint32_t len);
|
||||||
@ -56,6 +56,7 @@ class Adafruit_SPITFT : public Adafruit_GFX {
|
|||||||
using Adafruit_GFX::drawRGBBitmap; // Check base class first
|
using Adafruit_GFX::drawRGBBitmap; // Check base class first
|
||||||
void drawRGBBitmap(int16_t x, int16_t y,
|
void drawRGBBitmap(int16_t x, int16_t y,
|
||||||
uint16_t *pcolors, int16_t w, int16_t h);
|
uint16_t *pcolors, int16_t w, int16_t h);
|
||||||
|
void invertDisplay(boolean i);
|
||||||
|
|
||||||
uint16_t color565(uint8_t r, uint8_t g, uint8_t b);
|
uint16_t color565(uint8_t r, uint8_t g, uint8_t b);
|
||||||
|
|
||||||
@ -75,6 +76,10 @@ class Adafruit_SPITFT : public Adafruit_GFX {
|
|||||||
void writeCommand(uint8_t cmd);
|
void writeCommand(uint8_t cmd);
|
||||||
void spiWrite(uint8_t v);
|
void spiWrite(uint8_t v);
|
||||||
uint8_t spiRead(void);
|
uint8_t spiRead(void);
|
||||||
|
|
||||||
|
uint8_t invertOnCommand = 0, invertOffCommand = 0;
|
||||||
|
uint8_t ySetCommand, xSetCommand, RAMwriteCommand;
|
||||||
|
int16_t _xstart = 0, _ystart = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user