From a6e0fadb82c84cdda55258153b2d7a51006baaf2 Mon Sep 17 00:00:00 2001 From: victorpv Date: Wed, 27 May 2015 20:05:35 -0500 Subject: [PATCH] Reverts changes to the ILI9341 library that should not use DMA. --- .../Adafruit_ILI9341/Adafruit_ILI9341.cpp | 74 ++++++------------- .../Adafruit_ILI9341/Adafruit_ILI9341.h | 1 + 2 files changed, 24 insertions(+), 51 deletions(-) diff --git a/STM32F1/libraries/Adafruit_ILI9341/Adafruit_ILI9341.cpp b/STM32F1/libraries/Adafruit_ILI9341/Adafruit_ILI9341.cpp index 4233716..4f1e146 100644 --- a/STM32F1/libraries/Adafruit_ILI9341/Adafruit_ILI9341.cpp +++ b/STM32F1/libraries/Adafruit_ILI9341/Adafruit_ILI9341.cpp @@ -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;i0; 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) { } */ + diff --git a/STM32F1/libraries/Adafruit_ILI9341/Adafruit_ILI9341.h b/STM32F1/libraries/Adafruit_ILI9341/Adafruit_ILI9341.h index 1ce359a..1e9bf60 100644 --- a/STM32F1/libraries/Adafruit_ILI9341/Adafruit_ILI9341.h +++ b/STM32F1/libraries/Adafruit_ILI9341/Adafruit_ILI9341.h @@ -167,3 +167,4 @@ class Adafruit_ILI9341 : public Adafruit_GFX { }; #endif +