Reverts changes to the ILI9341 library that should not use DMA.

This commit is contained in:
victorpv 2015-05-27 20:05:35 -05:00
parent 92d0470349
commit a6e0fadb82
2 changed files with 24 additions and 51 deletions

View File

@ -253,7 +253,7 @@ void Adafruit_ILI9341::begin(void) {
writedata(0x10); //SAP[2:0];BT[3:0]
writecommand(ILI9341_VMCTR1); //VCM control
writedata(0x3e); //¶Ô±È¶Èµ÷½Ú
writedata(0x3e); //???????
writedata(0x28);
writecommand(ILI9341_VMCTR2); //VCM control2
@ -327,11 +327,9 @@ void Adafruit_ILI9341::begin(void) {
void Adafruit_ILI9341::setAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1,
uint16_t y1) {
byte buf[4];
writecommand(ILI9341_CASET); // Column addr set
*dcport |= dcpinmask;
*csport &= ~cspinmask;
SPI.write(x0 >> 8);
SPI.write(x0 & 0xFF); // XSTART
SPI.write(x1 >> 8);
@ -340,13 +338,11 @@ void Adafruit_ILI9341::setAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1,
writecommand(ILI9341_PASET); // Row addr set
*dcport |= dcpinmask;
*csport &= ~cspinmask;
SPI.write(y0>>8);
SPI.write(y0); // YSTART
SPI.write(y1>>8);
SPI.write(y1); // YEND
writecommand(ILI9341_RAMWR); // write to RAM
}
@ -437,58 +433,33 @@ void Adafruit_ILI9341::fillScreen(uint16_t color) {
}
// fill a rectangle
void Adafruit_ILI9341::fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color) {
void Adafruit_ILI9341::fillRect(int16_t x, int16_t y, int16_t w, int16_t h,
uint16_t color) {
int numPixels;
// rudimentary clipping (drawChar w/big text requires this)
if((x >= _width) || (y >= _height)) return;
if((x + w - 1) >= _width) w = _width - x;
if((y + h - 1) >= _height) h = _height - y;
unsigned char *buff;
if (hwSPI) spi_begin();
setAddrWindow(x, y, x+w-1, y+h-1);
// rudimentary clipping (drawChar w/big text requires this)
if((x >= _width) || (y >= _height)) return;
if((x + w - 1) >= _width) w = _width - x;
if((y + h - 1) >= _height) h = _height - y;
uint8_t hi = color >> 8, lo = color;
if (hwSPI) spi_begin();
setAddrWindow(x, y, x+w-1, y+h-1);
uint8_t hi = color >> 8, lo = color;
*dcport |= dcpinmask;
*csport &= ~cspinmask;
*dcport |= dcpinmask;
*csport &= ~cspinmask;
if (true)
for(y=h; y>0; y--)
{
for(x=w; x>0; x--)
{
// Use DMA
byte txBuf[h*2];// Buffer to be sent via DMA
byte rxBuf[h*2];// Buffer to be sent via DMA
// need to build a buffer of the required height (h)
// Note I suspect there is a faster way to do this
for(int i=0;i<h*2;i++)
{
txBuf[i++] = hi&0xff;
txBuf[i] = lo&0xff;
}
// Tansfer each line by DMA
for(int i=0;i<w;i++)
{
//memcpy(rxBuf,txBuf,h*2);
SPI.DMATransfer(txBuf,rxBuf,h*2);
}
}
else
{
// Non DMA method (currently not used)
for(y=h; y>0; y--)
{
for(x=w; x>0; x--)
{
SPI.write(hi);
SPI.write(lo);
}
}
}
if (hwSPI) spi_end();
*csport |= cspinmask;
SPI.write(hi);
SPI.write(lo);
}
}
if (hwSPI) spi_end();
*csport |= cspinmask;
}
@ -658,3 +629,4 @@ uint8_t Adafruit_ILI9341::readcommand8(uint8_t c, uint8_t index) {
}
*/

View File

@ -167,3 +167,4 @@ class Adafruit_ILI9341 : public Adafruit_GFX {
};
#endif