Quick update: I pushed up changes to fix the drawing of font characters, plus drawing rectangles and drawing lines. Test program looks like:
Code:
#include <SPIN.h>
#include "SPI.h"
#include "ILI9341_t3n.h"
#include "font_Inconsolata-Regular.h" //from linked library but pointing back to the ili9341_t3n instead of the regular ili9341_t3
#define TFT_DC 9
#define TFT_CS 10
#define TFT_RST 7
#define TFT_SCK 13
#define TFT_MISO 12
#define TFT_MOSI 11
ILI9341_t3n tft = ILI9341_t3n(TFT_CS, TFT_DC, TFT_RST, TFT_MOSI, TFT_SCK, TFT_MISO, &SPIN);
uint8_t use_fb = 0;
void setup() {
while (!Serial && (millis() < 4000)) ;
Serial.begin(115200);
tft.begin();
tft.fillScreen(ILI9341_BLACK);
}
void drawFontText() {
Serial.printf("Use FB: %d ", use_fb); Serial.flush();
uint32_t start_time = millis();
tft.useFBTFT(use_fb);
tft.fillScreen(use_fb ? ILI9341_RED : ILI9341_BLACK);
tft.setRotation(3);
tft.setFont(Inconsolata_60);
tft.setTextColor(ILI9341_WHITE);
tft.setCursor(0, 0);
tft.println("Test");
tft.println("text");
tft.drawRect(0, 150, 200, 50, ILI9341_WHITE);
tft.drawLine(0, 150, 200, 50, ILI9341_GREEN);
tft.updateScreen();
Serial.println(millis() - start_time, DEC);
use_fb = !use_fb;
}
void loop(void) {
// See if any text entered
if (Serial.read() != -1) {
while (Serial.read() != -1) ;
drawFontText();
}
}
So I can enter a text line (typically empty) and switch between drawing with or without frame buffer.
Defragster: Taking a look at the function:
Code:
unsigned long testFilledRects(uint16_t color1, uint16_t color2) {
unsigned long start, t = 0;
int n, i, i2,
cx = tft.width() / 2 - 1,
cy = tft.height() / 2 - 1;
tft.fillScreen(ILI9341_BLACK);
n = min(tft.width(), tft.height());
for(i=n; i>0; i-=6) {
i2 = i / 2;
start = micros();
tft.fillRect(cx-i2, cy-i2, i, i, color1);
t += micros() - start;
// Outlines are not included in timing results
tft.drawRect(cx-i2, cy-i2, i, i, color2);
}
return t;
}
Quick sanity test. Assume width=240, height=320
cx = 119, cy=159, n=240, i=240, i2=120 so first fillRect(-1, 39, 240, 240, color1). So the problem is the -1... Which looks like also looks like maybe need to update the graphic primitives to check for this...
Frank, if you are reading this, maybe need to change your DMA version as well...