So nachdem ich nun endlich das 2.8" Display mit Touchscreen (ist ein Shield für den Arduino Uno) unter dem Arduino Due zum Laufen gebracht habe muss ich nun leider feststellen, dass ich kaum Geschwindigkeitsvorteile mit dem DUE habe. Er ist meist noch nicht einmal doppelt so schnell. Hätte das ca. 4-5 Fache gegenüber den Uno erwartet.
Angeschlossen ist das Display über das 8 Bit Interface. Angeblich soll das ja auch schneller sein als SPI . SPI Anschlüsse hat das Display außerdem sowieso nicht Des Weiteren benutzt ich die "Adafruit TFTLCD-Library-master" Library welche meinen ILI9341 Displaycontroller supportet sowie die "Adafruit-GFX-Library-master" Library (siehe Anhang).
Aus einem damaligen Projekt erinnere ich mich noch, dass digitalWrite() etc. nicht gerade sehr schnell ist und man bestimmte Pin-Manipulations Libraries benutzen soll. Wenn ich das aber richtig sehe ist die Adafruit LCD Library schon für Pin-Manipulationen optimiert und legt die 8 Bit Werte direkt auf den PORTC (PIOC).
Hier in der pin_magic.h gefunden:
#else // Due w/Breakout board
#define write8inline(d) { \
PIO_Set(PIOC, (((d) & 0xFF)<<1)); \
PIO_Clear(PIOC, (((~d) & 0xFF)<<1)); \
WR_STROBE; }
#define read8inline(result) { \
RD_ACTIVE; \
delayMicroseconds(1); \
result = ((PIOC->PIO_PDSR & 0x1FE) >> 1); \
RD_IDLE;}
#define setWriteDirInline() { \
PIOC->PIO_MDDR |= 0x000001FE; /*PIOC->PIO_SODR |= 0x000001FE;*/ PIOC->PIO_OER |= 0x000001FE; PIOC->PIO_PER |= 0x000001FE; }
#define setReadDirInline() { \
pmc_enable_periph_clk( ID_PIOC ) ; \
PIOC->PIO_PUDR |= 0x000001FE; PIOC->PIO_IFDR |= 0x000001FE; PIOC->PIO_ODR |= 0x000001FE; PIOC->PIO_PER |= 0x000001FE; }
// When using the TFT breakout board, control pins are configurable.
#define RD_ACTIVE rdPort->PIO_CODR |= rdPinSet //PIO_Clear(rdPort, rdPinSet)
#define RD_IDLE rdPort->PIO_SODR |= rdPinSet //PIO_Set(rdPort, rdPinSet)
#define WR_ACTIVE wrPort->PIO_CODR |= wrPinSet //PIO_Clear(wrPort, wrPinSet)
#define WR_IDLE wrPort->PIO_SODR |= wrPinSet //PIO_Set(wrPort, wrPinSet)
#define CD_COMMAND cdPort->PIO_CODR |= cdPinSet //PIO_Clear(cdPort, cdPinSet)
#define CD_DATA cdPort->PIO_SODR |= cdPinSet //PIO_Set(cdPort, cdPinSet)
#define CS_ACTIVE csPort->PIO_CODR |= csPinSet //PIO_Clear(csPort, csPinSet)
#define CS_IDLE csPort->PIO_SODR |= csPinSet //PIO_Set(csPort, csPinSet)
#endif
Daher gehe ich jetzt davon aus das das 8-Bit Interface schon "maximal" schnell ist. Bis auf die reset() Funktion die scheinbar kaum genutzt wird benutzt scheinbar nichts mehr digitalWrite() in der LCDTFT Library. Die analogen Pins welche für LCD_RD, LCD_WR, LCD_CD,LCD_CD und LCD RST benutzt werden scheinen auch schon als Ports angesprochen zu werden wobei ich mir da nicht ganz sicher bin da ich die Funktion digitalPinToPort() noch nicht wirklich kennen.
Adafruit_TFTLCD::Adafruit_TFTLCD( //cs,cd,wr,rd,reset are currently Analog ports
uint8_t cs, uint8_t cd, uint8_t wr, uint8_t rd, uint8_t reset) :
Adafruit_GFX(TFTWIDTH, TFTHEIGHT) {
#ifndef USE_ADAFRUIT_SHIELD_PINOUT
// Convert pin numbers to registers and bitmasks
_reset = reset;
#ifdef __AVR__
csPort = portOutputRegister(digitalPinToPort(cs));
cdPort = portOutputRegister(digitalPinToPort(cd));
wrPort = portOutputRegister(digitalPinToPort(wr));
rdPort = portOutputRegister(digitalPinToPort(rd));
#endif
#if defined(__SAM3X8E__)
csPort = digitalPinToPort(cs);
cdPort = digitalPinToPort(cd);
wrPort = digitalPinToPort(wr);
rdPort = digitalPinToPort(rd);
#endif
csPinSet = digitalPinToBitMask(cs);
cdPinSet = digitalPinToBitMask(cd);
wrPinSet = digitalPinToBitMask(wr);
rdPinSet = digitalPinToBitMask(rd);
csPinUnset = ~csPinSet;
cdPinUnset = ~cdPinSet;
wrPinUnset = ~wrPinSet;
rdPinUnset = ~rdPinSet;
#ifdef __AVR__
*csPort |= csPinSet; // Set all control bits to HIGH (idle)
*cdPort |= cdPinSet; // Signals are ACTIVE LOW
*wrPort |= wrPinSet;
*rdPort |= rdPinSet;
#endif
#if defined(__SAM3X8E__)
csPort->PIO_SODR |= csPinSet; // Set all control bits to HIGH (idle)
cdPort->PIO_SODR |= cdPinSet; // Signals are ACTIVE LOW
wrPort->PIO_SODR |= wrPinSet;
rdPort->PIO_SODR |= rdPinSet;
#endif
pinMode(cs, OUTPUT); // Enable outputs
pinMode(cd, OUTPUT);
pinMode(wr, OUTPUT);
pinMode(rd, OUTPUT);
if(reset) {
digitalWrite(reset, HIGH);
pinMode(reset, OUTPUT);
}
#endif
init();
}
Hier noch die Benchmarkergebnisse des UNO und DUE:
===========================
Arduino DUE Ergebnisse:
===========================
TFT size is 240x320
Found ILI9341 LCD driver
Benchmark Time (microseconds)
Screen fill 589958
Text 243888
Lines 2629141
Horiz/Vert Lines 82337
Rectangles (outline) 61069
Rectangles (filled) 1803457
Circles (filled) 791613
Circles (outline) 1148910
Triangles (outline) 833864
Triangles (filled) 880018
Rounded rects (outline) 379342
Rounded rects (filled) 2132058
Done!
===========================
Arduino UNO Ergebnisse:
===========================
Using Adafruit 2.8" TFT Breakout Board Pinout
TFT size is 240x320
Found ILI9341 LCD driver
Benchmark Time (microseconds)
Screen fill 1379560
Text 344032
Lines 3390180
Horiz/Vert Lines 144660
Rectangles (outline) 104264
Rectangles (filled) 3267472
Circles (filled) 1211480
Circles (outline) 1475104
Triangles (outline) 1075600
Triangles (filled) 1719024
Rounded rects (outline) 506432
Rounded rects (filled) 3795236
Done!
Also wenn ich das richtig sehe ist die Adafruit Library schon sehr für Pin-Manipulationen optimiert und scheint mir nicht die Ursache zu sein. Warum ist der Display aber trotzdem so langsam? Woran kann das liegen? Hatte jemand ähnliche Problem und eine Lösung gefunden?
Adafruit-GFX-Library-master.zip (282 KB)