Author Topic: OAK TFT driver?  (Read 10404 times)

postuma

  • Jr. Member
  • **
  • Posts: 64
Re: OAK TFT driver?
« Reply #15 on: June 04, 2016, 12:31:03 pm »
Yes, I know. That's what I tried to say with my two previous posts. I must look like a real :o.

Anyway, got the screen up and running:



That's just the layout. Next, porting everything from my Digispark Pro version of my bike computer.

PeterF

  • Hero Member
  • *****
  • Posts: 883
Re: OAK TFT driver?
« Reply #16 on: June 04, 2016, 05:59:09 pm »
As long as you don't take offence to me promptly ROFTLMAO then no comment from me!  ;D

... other than "Wow! That looks great!" ... and here I am with a TFT that just says Remote Temperature in green print, and the temperature below in yellow print, and spinning cursor in the corner to indicate that the Oak is still alive 'n kicking... and thinking that is pretty good stuff!  ;D  :o  :-X

Will be very interesting to see your progress... look forward to seeing more posts as you progress!  :)

emardee

  • Full Member
  • ***
  • Posts: 136
Re: OAK TFT driver?
« Reply #17 on: June 27, 2016, 01:16:06 am »
Having the same problem that others had earlier in the thread... namely that my screen is pure white with no graphics showing.

I'm using the tft oak kit from digistump.
I've soldered the shield directly to the screen, (so it can't be flaky jumpers on a breadboard as the cause! - but could be a dry joint I guess?)
I'm trying the sketch from:
     Arduino 1.6.5r5 > File Menu > Examples > Adafruit ILI9341 > graphicstest_esp8266
Is that the correct sketch to work from, or is there an Oak version of that sketch in another location?
I couldn't see any changes needing to made in that sketch, so loaded as is (ie no changes)
Also tried it with the 3rd "delay(0)" changed to "delay(1)" (as suggested by postuma).

Any other ideas?
A different sketch to try? (different version of that same sketch from different location?)
A setting I needed to change in the sketch that I missed (I've checked DC 1 and CS 6, but they were already in sketch correctly)?
Something else obvious?

Running Oak firmware v1.0.1 (in case this makes a difference)

Thanks in advance...

Mike


PeterF

  • Hero Member
  • *****
  • Posts: 883
Re: OAK TFT driver?
« Reply #18 on: June 27, 2016, 04:06:27 am »
Hi Mike,

Since you've soldered it, I don't think even a dry joint would be a deal-breaker problem at this point.

Only thing I can suggest is to ask is the Arduino IDE picking the right Adafruit_ILI9341 library? Are you getting any warning messages about multiple libraries and it picking one over the other? And if so, is it picking the standard Adafruit one over the one that was distributed with the Oak... (although if you have a current version of the standard library I don't think it really makes any difference)...

Pete

emardee

  • Full Member
  • ***
  • Posts: 136
Re: OAK TFT driver?
« Reply #19 on: June 28, 2016, 02:36:13 am »
PeterF

Thanks for the reply.

Here's the sketch I am using (in case anyone spots an obvious rookie error!):

Code: [Select]
#include <Adafruit_ILI9341.h>
#include <Adafruit_GFX.h>
#include <SPI.h>
// For the Adafruit shield, these are the default.
#define TFT_DC 1
#define TFT_CS 6

// Use hardware SPI (on Uno, #13, #12, #11) and the above for CS/DC
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
#define SERIAL_OUT Serial

unsigned long testFillScreen() {
  unsigned long start = micros();
  tft.fillScreen(ILI9341_BLACK);
  tft.fillScreen(ILI9341_RED);
  tft.fillScreen(ILI9341_GREEN);
  tft.fillScreen(ILI9341_BLUE);
  tft.fillScreen(ILI9341_BLACK);
  return micros() - start;
}

unsigned long testText() {
  tft.fillScreen(ILI9341_BLACK);
  unsigned long start = micros();
  tft.setCursor(0, 0);
  tft.setTextColor(ILI9341_WHITE);  tft.setTextSize(1);
  tft.println("Hello World!");
  tft.setTextColor(ILI9341_YELLOW); tft.setTextSize(2);
  tft.println(1234.56);
  tft.setTextColor(ILI9341_RED);    tft.setTextSize(3);
  tft.println(0xDEADBEEF, HEX);
  tft.println();
  tft.setTextColor(ILI9341_GREEN);
  tft.setTextSize(5);
  tft.println("Groop");
  tft.setTextSize(2);
  tft.println("I implore thee,");
  tft.setTextSize(1);
  tft.println("my foonting turlingdromes.");
  tft.println("And hooptiously drangle me");
  tft.println("with crinkly bindlewurdles,");
  tft.println("Or I will rend thee");
  tft.println("in the gobberwarts");
  tft.println("with my blurglecruncheon,");
  tft.println("see if I don't!");
  return micros() - start;
}

unsigned long testLines(uint16_t color) {
  unsigned long start, t;
  int           x1, y1, x2, y2,
                w = tft.width(),
                h = tft.height();

  tft.fillScreen(ILI9341_BLACK);
  delay(0);

  x1 = y1 = 0;
  y2    = h - 1;
  start = micros();
  for(x2=0; x2<w; x2+=6) tft.drawLine(x1, y1, x2, y2, color);
  x2    = w - 1;
  for(y2=0; y2<h; y2+=6) tft.drawLine(x1, y1, x2, y2, color);
  t     = micros() - start; // fillScreen doesn't count against timing

  tft.fillScreen(ILI9341_BLACK);
  delay(0);

  x1    = w - 1;
  y1    = 0;
  y2    = h - 1;
  start = micros();
  for(x2=0; x2<w; x2+=6) tft.drawLine(x1, y1, x2, y2, color);
  x2    = 0;
  for(y2=0; y2<h; y2+=6) tft.drawLine(x1, y1, x2, y2, color);
  t    += micros() - start;

  tft.fillScreen(ILI9341_BLACK);
  delay(0);

  x1    = 0;
  y1    = h - 1;
  y2    = 0;
  start = micros();
  for(x2=0; x2<w; x2+=6) tft.drawLine(x1, y1, x2, y2, color);
  x2    = w - 1;
  for(y2=0; y2<h; y2+=6) tft.drawLine(x1, y1, x2, y2, color);
  t    += micros() - start;

  tft.fillScreen(ILI9341_BLACK);
  delay(0);

  x1    = w - 1;
  y1    = h - 1;
  y2    = 0;
  start = micros();
  for(x2=0; x2<w; x2+=6) tft.drawLine(x1, y1, x2, y2, color);
  x2    = 0;
  for(y2=0; y2<h; y2+=6) tft.drawLine(x1, y1, x2, y2, color);

  return micros() - start;
}

unsigned long testFastLines(uint16_t color1, uint16_t color2) {
  unsigned long start;
  int           x, y, w = tft.width(), h = tft.height();

  tft.fillScreen(ILI9341_BLACK);
  start = micros();
  for(y=0; y<h; y+=5) tft.drawFastHLine(0, y, w, color1);
  for(x=0; x<w; x+=5) tft.drawFastVLine(x, 0, h, color2);

  return micros() - start;
}

unsigned long testRects(uint16_t color) {
  unsigned long start;
  int           n, i, i2,
                cx = tft.width()  / 2,
                cy = tft.height() / 2;

  tft.fillScreen(ILI9341_BLACK);
  n     = min(tft.width(), tft.height());
  start = micros();
  for(i=2; i<n; i+=6) {
    i2 = i / 2;
    tft.drawRect(cx-i2, cy-i2, i, i, color);
  }

  return micros() - start;
}

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) {
    delay(0);
    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;
}

unsigned long testFilledCircles(uint8_t radius, uint16_t color) {
  unsigned long start;
  int x, y, w = tft.width(), h = tft.height(), r2 = radius * 2;

  tft.fillScreen(ILI9341_BLACK);
  start = micros();
  for(x=radius; x<w; x+=r2) {
    for(y=radius; y<h; y+=r2) {
      tft.fillCircle(x, y, radius, color);
    }
  }

  return micros() - start;
}

unsigned long testCircles(uint8_t radius, uint16_t color) {
  unsigned long start;
  int           x, y, r2 = radius * 2,
                w = tft.width()  + radius,
                h = tft.height() + radius;

  // Screen is not cleared for this one -- this is
  // intentional and does not affect the reported time.
  start = micros();
  for(x=0; x<w; x+=r2) {
    for(y=0; y<h; y+=r2) {
      tft.drawCircle(x, y, radius, color);
    }
  }

  return micros() - start;
}

unsigned long testTriangles() {
  unsigned long start;
  int           n, i, cx = tft.width()  / 2 - 1,
                      cy = tft.height() / 2 - 1;

  tft.fillScreen(ILI9341_BLACK);
  n     = min(cx, cy);
  start = micros();
  for(i=0; i<n; i+=5) {
    tft.drawTriangle(
      cx    , cy - i, // peak
      cx - i, cy + i, // bottom left
      cx + i, cy + i, // bottom right
      tft.color565(0, 0, i));
  }

  return micros() - start;
}

unsigned long testFilledTriangles() {
  unsigned long start, t = 0;
  int           i, cx = tft.width()  / 2 - 1,
                   cy = tft.height() / 2 - 1;

  tft.fillScreen(ILI9341_BLACK);
  start = micros();
  for(i=min(cx,cy); i>10; i-=5) {
    start = micros();
    tft.fillTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i,
      tft.color565(0, i, i));
    t += micros() - start;
    tft.drawTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i,
      tft.color565(i, i, 0));
  }

  return t;
}

unsigned long testRoundRects() {
  unsigned long start;
  int           w, i, i2,
                cx = tft.width()  / 2 - 1,
                cy = tft.height() / 2 - 1;

  tft.fillScreen(ILI9341_BLACK);
  w     = min(tft.width(), tft.height());
  start = micros();
  for(i=0; i<w; i+=6) {
    i2 = i / 2;
    tft.drawRoundRect(cx-i2, cy-i2, i, i, i/8, tft.color565(i, 0, 0));
    delay(0);
  }

  return micros() - start;
}

unsigned long testFilledRoundRects() {
  unsigned long start;
  int           i, i2,
                cx = tft.width()  / 2 - 1,
                cy = tft.height() / 2 - 1;

  tft.fillScreen(ILI9341_BLACK);
  start = micros();
  for(i=min(tft.width(), tft.height()); i>20; i-=6) {
    i2 = i / 2;
    tft.fillRoundRect(cx-i2, cy-i2, i, i, i/8, tft.color565(0, i, 0));
    delay(0);
  }

  return micros() - start;
}


void setup() {
  SERIAL_OUT.begin(115200);
  SERIAL_OUT.println("ILI9341 Test!");

  tft.begin();

  // read diagnostics (optional but can help debug problems)
  uint8_t x = tft.readcommand8(ILI9341_RDMODE);
  SERIAL_OUT.print("Display Power Mode: 0x"); SERIAL_OUT.println(x, HEX);
  x = tft.readcommand8(ILI9341_RDMADCTL);
  SERIAL_OUT.print("MADCTL Mode: 0x"); SERIAL_OUT.println(x, HEX);
  x = tft.readcommand8(ILI9341_RDPIXFMT);
  SERIAL_OUT.print("Pixel Format: 0x"); SERIAL_OUT.println(x, HEX);
  x = tft.readcommand8(ILI9341_RDIMGFMT);
  SERIAL_OUT.print("Image Format: 0x"); SERIAL_OUT.println(x, HEX);
  x = tft.readcommand8(ILI9341_RDSELFDIAG);
  SERIAL_OUT.print("Self Diagnostic: 0x"); SERIAL_OUT.println(x, HEX);

  SERIAL_OUT.println(F("Benchmark                Time (microseconds)"));

  SERIAL_OUT.print(F("Screen fill              "));
  SERIAL_OUT.println(testFillScreen());
  delay(500);

  SERIAL_OUT.print(F("Text                     "));
  SERIAL_OUT.println(testText());
  delay(3000);

  SERIAL_OUT.print(F("Lines                    "));
  SERIAL_OUT.println(testLines(ILI9341_CYAN));
  delay(500);

  SERIAL_OUT.print(F("Horiz/Vert Lines         "));
  SERIAL_OUT.println(testFastLines(ILI9341_RED, ILI9341_BLUE));
  delay(500);

  SERIAL_OUT.print(F("Rectangles (outline)     "));
  SERIAL_OUT.println(testRects(ILI9341_GREEN));
  delay(500);

  SERIAL_OUT.print(F("Rectangles (filled)      "));
  SERIAL_OUT.println(testFilledRects(ILI9341_YELLOW, ILI9341_MAGENTA));
  delay(500);

  SERIAL_OUT.print(F("Circles (filled)         "));
  SERIAL_OUT.println(testFilledCircles(10, ILI9341_MAGENTA));

  SERIAL_OUT.print(F("Circles (outline)        "));
  SERIAL_OUT.println(testCircles(10, ILI9341_WHITE));
  delay(500);

  SERIAL_OUT.print(F("Triangles (outline)      "));
  SERIAL_OUT.println(testTriangles());
  delay(500);

  SERIAL_OUT.print(F("Triangles (filled)       "));
  SERIAL_OUT.println(testFilledTriangles());
  delay(500);

  SERIAL_OUT.print(F("Rounded rects (outline)  "));
  SERIAL_OUT.println(testRoundRects());
  delay(500);

  SERIAL_OUT.print(F("Rounded rects (filled)   "));
  SERIAL_OUT.println(testFilledRoundRects());
  delay(500);

  SERIAL_OUT.println(F("Done!"));

}


void loop(void) {
  for(uint8_t rotation=0; rotation<4; rotation++) {
    tft.setRotation(rotation);
    testText();
    delay(1000);
  }
}

The warning I get upon compiling is:

Quote
WARNING: library SPI claims to run on [esp8266] architecture(s) and may be incompatible with your current board which runs on [oak] architecture(s).

I am expecting that since the sketch is called: "graphicstest_esp8266", that the warning is acceptable in this case.

The only other thing I forgot to mention was that the activity LED on the Oak does a slight flicker... eg it is mostly on, but is very faintly dimming slightly in flickers.... which I presume is a sign that the Oak is processing something for the screen, just that the screen isn't displaying it.

Any ideas how I can check which the culprit is.... I'm guessing it is one of these:
  • A duff TFT screen?
  • My soldering?
  • The wrong Sketch?
  • Wrong settings in the right sketch?
  • Wrong library being used? (how would I tell this?)
  • Something else?

Any thoughts?

Thanks

Mike

PeterF

  • Hero Member
  • *****
  • Posts: 883
Re: OAK TFT driver?
« Reply #20 on: June 29, 2016, 07:49:23 pm »
I don't have time to look at the code atm, but since it is essentially just the graphicstest_esp8266 with some delays IIRC your earlier posting, then I don't think that would be the issue.

On my Oak Arduino setup (which doesn't know about any of my other Arduino libraries...), I also get the

Code: [Select]
WARNING: library SPI claims to run on [esp8266] architecture(s) and may be incompatible with your current board which runs on [oak] architecture(s).
so I think that is normal. The P1 led blinking is because it shares one of the LCD display pins, and should be blinking or lit when the display is doing something - I think it is either the enable or clock pin...

emardee

  • Full Member
  • ***
  • Posts: 136
Re: OAK TFT driver?
« Reply #21 on: June 29, 2016, 08:12:52 pm »
Thanks for the comments.

I've confirmed I'm using the right example sketch that others have used.

I re-read the reason for changing the delay(0) to delay(1) and it was only needed by someone earlier in the thread where their oak froze at a certain point in the code... since that isn't my problem, that shouldn't make a difference, so I've left that alone now.

Very unlikely to be a wrong library being used, since there are no other boards installed on this copy of Arduino IDE.

I think therefore I've either got a bad TFT board from Digistump, or I'd soldered the shield up badly.

No I've narrowed that down, it should be easy enough to prove if I've shorted something out, or something has a dry joint. Failing that it looks like I got a bad TFT.

Will do some troubleshooting and if necessary get in touch with Erik.

Thanks for helping me narrow down the cause! Much appreciated.

Mike

saperlot

  • Newbie
  • *
  • Posts: 16
Re: OAK TFT driver?
« Reply #22 on: July 20, 2016, 04:52:55 am »
Did you came to a conclusion?
mine also don't work.


saperlot

  • Newbie
  • *
  • Posts: 16
Re: OAK TFT driver?
« Reply #23 on: July 22, 2016, 04:23:56 am »
I checked all the signals,
sampled with 24Mhz and i see that the signals look very screwed up. So i checked the frequency of the SPI. And it must be running at 80Mhz. According to that defining in Adafruit_ILI9341.cpp:
Code: [Select]
#ifdef ESP8266
SPISettings spiSettings = SPISettings(ESP8266_CLOCK, MSBFIRST, SPI_MODE0);
#else

So i changed it to 8000000, trying to run the SPi at 8Mhz. Now i see the signals looks ok, i got a reasonable clock and MOSI but no MISO.
--> no response from the tft.
I'm using the connecting shield. No connection error.

Well, i have no clue what's wrong.


emardee

  • Full Member
  • ***
  • Posts: 136
Re: OAK TFT driver?
« Reply #24 on: July 22, 2016, 05:28:26 am »
I paused my investigations expecting Particle IDE to be released any day (would make investigating this much easier as I'm not normally near the one machine I have with Arduino IDE installed on... so web based IDE would be awesome for me) but that that hasn't been released yet, so I didn't get back to investigating.

Interested to hear of others with problems though, as there might be a common problem between ours.

Are you using the Oak TFT shield?  Which library & Sketch example are you using?

saperlot

  • Newbie
  • *
  • Posts: 16
Re: OAK TFT driver?
« Reply #25 on: July 28, 2016, 07:17:20 am »
Are you using the Oak TFT shield?  Which library & Sketch example are you using?

Yes the oak TFT shield.
I use the provided library and example from the OAK package. (Adafruit ILI9341/graphictest_esp8266)

saperlot

  • Newbie
  • *
  • Posts: 16
Re: OAK TFT driver?
« Reply #26 on: August 03, 2016, 08:59:34 am »
Well, shouldn't the 2.2'' TFT use the ILI9340 Driver????
Adafruit states that this is for their 2.2TFT and the ILI9341 is for their 2.8'' tft.

So, i don't want to start porting the ili9340 library until i got a statement that this chip is inside the 2.2'' TFT.


emardee

  • Full Member
  • ***
  • Posts: 136
Re: OAK TFT driver?
« Reply #27 on: August 03, 2016, 03:01:43 pm »
Wrong driver chip and therefore library could certainly be the cause of problems. Is there an easy way to tell which library the screen needs?

PeterF

  • Hero Member
  • *****
  • Posts: 883
Re: OAK TFT driver?
« Reply #28 on: August 03, 2016, 06:12:44 pm »
Whilst the adafruit displays use a variety of LCD driver chips (ILI9340/ILI9341/ST7735R/HXD8357D), all of the red TFT LCD boards I have enocuntered so far all work with the Adafruit_ILI9341 library, so I'd presume they are all using ILI9341 driver chips. This is for the 2.2" LCD I got with the Oak, as well as some 1.8" and 2.8" displays I bought on ebay. I am using the Oak TFT shield, but I didn't solder the display directly on, only headers. I then use an extension to link to the display. I can swap out any of the three displays when using the graphicstest_esp8266 code without any changes, and all three sizes work flawlessly (just change the display when the Oak is not powered!).

Interestingly enough, in a discussion about which library to use to control the displays, Paul Stoffregen (one of the people contributing to Arduino) commented that at least on the older Adafruit display with ILI9340, the same code work with either [ILI9340 or ILI9341] controller chip.

I am using the 1.0.5 Arduino IDE Oak board package, Arduino 1.6.10, and sketchbook that has only Oak related code and a couple of custom libraries. There is no other copy of the Adafruit_ILI9341 library installed in this sketchbook, so there is no change it is using a different version (thus also no warning in the compile log about the IDE auto-magically picking between multiple libraries - and getting it wrong). And the example is working just fine in my case.

If you are thinking about trying the Adafruit_ILI9340 library... you may not need to do much. Both the Adafruit_ILI9340 and Adafruit_ILI9341 libraries have been updated with ESP8266 support (although I haven't had any need to test that out myself yet) since Erik starting working on the Oak, so may actually be fully compatible already - at most they might need to be tricked into thinking they're being compiled for an Oak instead of a ESP8266.

saperlot

  • Newbie
  • *
  • Posts: 16
Re: OAK TFT driver?
« Reply #29 on: August 04, 2016, 04:49:46 am »
Thanks PeterF for your explanation.

I now got a clean installation of Arduino 1.6.10 and with a clean installation of oak 1.0.5. Compiled the example without modification --> Display stays white.
I don't think that the problem is related to my soldering. Every connection is made and i also got no short circuits.
Also when i look at the signals, they are clear and it runs at 8Mbit. I don't see any response from the Display at all. BUt the example given does make a read out at the beginning. So i'm still not sure what is wrong.
I guess i have to give up and trash this tft.