Forum Rule: Always post complete source code & details to reproduce any issue!
Page 22 of 26 FirstFirst ... 12 20 21 22 23 24 ... LastLast
Results 526 to 550 of 647

Thread: Highly optimized ILI9341 (320x240 TFT color display) library

  1. #526
    Quote Originally Posted by swedeo View Post

    After a lot of googeling and several days of testing I have decided I'm too stupid and I have to ask someone who is more experienced in this matter. Which I hereby do:

    Can someone please have a look and help?

    Has someone tried readRect()/writeRect() with Teensy3.2 successfully? If so - with what code and library and speed settings?
    I've had plenty of success with doing this, but initially spent a lot of time troubleshooting some odd colour issues. (I'm using Teensy 3.6, but it's unlikely to be related to your version of Teensy)

    The colour issues were caused by SPI speed during read. Reducing it helped my display keep up with outputting serial data. Higher speed caused colour drifts as the values read back from the display were inconsistent.

    Then I tried another display (higher density) and have not been able to make it work at all yet. I used an oscilloscope to look at the MISO waveform, and it's too low and noisy for Teensy to register the values at any speed. I'm going to try a custom PCB to see if that cleans up the signal enough to be serviceable. Otherwise I'll need to abandon the display and find another.

    Double check you're using the correct MISO pin in hardware and software. If you're using a breadboard, try another one. I've had other projects with intermittent signal problems because the contacts were damaged from using pin headers instead of flip-pins (see https://www.tindie.com/products/OSHC...-or-36-4-sets/). Keep that connection short and secure.

    If possible, check the waveform on an oscilloscope to confirm it meets the required logic levels for Teensy. Chase down that before spending much more time trying different code and/or clock speeds.

  2. #527
    Junior Member
    Join Date
    Feb 2018
    Posts
    4
    Thanx for the quick answer.

    Unfortunately I don't have an oscilloscope. And I did not build the device, so cant say anything about if the right pins are used (the code assumes the default pin for MISO.) Just doing some coding help for a friend who built it...

    Do you know of a code snippet with which I could check some predictable return value from the display? Say - pixel resolution or rotation state? The get-functions in the ILI-libraries unfortunately just return preset values they keep in store for that, without actually reading out those values...

  3. #528
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    10,783
    As mentioned, would help to see the actual wiring. That is the display will probably work fine output only without the MISO pin connected, but the Read won't work it it is not setup with it.

    Some of the test programs I believe will print out some register values at the startup of the program.

    Example graphictest for ili9341_t3 library starts off with:
    Code:
     Serial.println("ILI9341 Test!"); 
    
      // read diagnostics (optional but can help debug problems)
      uint8_t x = tft.readcommand8(ILI9341_RDMODE);
      Serial.print("Display Power Mode: 0x"); Serial.println(x, HEX);
      x = tft.readcommand8(ILI9341_RDMADCTL);
      Serial.print("MADCTL Mode: 0x"); Serial.println(x, HEX);
      x = tft.readcommand8(ILI9341_RDPIXFMT);
      Serial.print("Pixel Format: 0x"); Serial.println(x, HEX);
      x = tft.readcommand8(ILI9341_RDIMGFMT);
      Serial.print("Image Format: 0x"); Serial.println(x, HEX);
      x = tft.readcommand8(ILI9341_RDSELFDIAG);
      Serial.print("Self Diagnostic: 0x"); Serial.println(x, HEX);
    So what do these registers print out as?

  4. #529
    Junior Member
    Join Date
    Feb 2018
    Posts
    4
    all requests return the same:

    ILI9341 Test!
    Display Power Mode: 0x3
    MADCTL Mode: 0x3
    Pixel Format: 0x3
    Image Format: 0x3
    Self Diagnostic: 0x3

  5. #530
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    10,783
    Sounds like it is not working properly...

    Again without seeing the actual wiring, it is hard to say what is wrong.

    Also any additional devices connected up to the SPI pins?

  6. #531
    Junior Member
    Join Date
    Feb 2018
    Posts
    4
    ok, I finally got a qualified reply from my friend who built it.
    You both were totally right: the MISO-pin was not connected properly, but he forgot this fact himself. (Before I gave it a try he also spent some time trying...)

    *sigh*

    So - everything was a false alarm. It could never have worked like it is. :-/

    Nonetheless - Thanks for your help!!

  7. #532
    Senior Member Projectitis's Avatar
    Join Date
    Feb 2018
    Location
    New Zealand
    Posts
    191
    Amazing work on the optimised library!

    @Frank B -
    Thanks for your work on Google font files! Would it be possible for me to request OpenSans please?
    Secondly, is your ILI9341_t3DMI library still valid, or are the DMI improvements now part of the main t3 library?

  8. #533
    Quote Originally Posted by ohhorob View Post
    Then I tried another display (higher density) and have not been able to make it work at all yet. I used an oscilloscope to look at the MISO waveform, and it's too low and noisy for Teensy to register the values at any speed. I'm going to try a custom PCB to see if that cleans up the signal enough to be serviceable. Otherwise I'll need to abandon the display and find another.
    This is the display -- https://www.crystalfontz.com/product...FT-240x320-IPS

    I purchased it on the carrier board, and built this simple board for it to connect with Teensy 3.6.

    Name:  eb17139aaf5abea1067b2a22daa81cd5.png
Views: 771
Size:  28.0 KB

    Turns out the MISO pin is floating

    However the controller is pushing the output signal on the MOSI line, so I've slowed down the clock and used a 1K resistor from MOSI to MISO, and MISO directly to the display data line.

    This works now for read/write, but it's slower than I'd like.. should I be able to omit the resistor and tie MISO and MOSI??

  9. #534
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    4,060
    the resistor will prevent high speed transfers

    did you set your pin to output and drive it deasserted before running the library itself?

  10. #535
    Quote Originally Posted by tonton81 View Post
    the resistor will prevent high speed transfers

    did you set your pin to output and drive it deasserted before running the library itself?
    Is "deasserted" simply writing low to the pin?

    I haven't tried that yet. Would that make it safe to omit the resistor and bring up the clock speed?

  11. #536
    Junior Member
    Join Date
    Mar 2018
    Posts
    1
    Hello everyone. I am new to the forum, and wanted to congratulate you on this great work.
    I am newbie also on this matter, and I have been using the ILI9341_t3 raftly for a month already, and very happy with it.
    Yesteday I found an error that drove me crazy with the fillRectHGradient funtion. The error comes when calculating the delta color it is using the height instead of the width. The formula should be: dr=(r2-r1)/w; dg=(g2-g1)/w; db=(b2-b1)/w; instead of dr=(r2-r1)/h; dg=(g2-g1)/h; db=(b2-b1)/h;, as it is calculating a horizontal gradient.

    Hope it helps.

  12. #537
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    10,783
    Quote Originally Posted by rickusb View Post
    Hello everyone. I am new to the forum, and wanted to congratulate you on this great work.
    I am newbie also on this matter, and I have been using the ILI9341_t3 raftly for a month already, and very happy with it.
    Yesteday I found an error that drove me crazy with the fillRectHGradient funtion. The error comes when calculating the delta color it is using the height instead of the width. The formula should be: dr=(r2-r1)/w; dg=(g2-g1)/w; db=(b2-b1)/w; instead of dr=(r2-r1)/h; dg=(g2-g1)/h; db=(b2-b1)/h;, as it is calculating a horizontal gradient.

    Hope it helps.
    I believe this has been fixed for a long time in my ili9341_t3n version of the library (github kuirte)

    I believe this is also part of the big Pull request I had a year ago: https://github.com/PaulStoffregen/ILI9341_t3/pull/41

    But as I mentioned that was a big Pull request... Things like: Still works when only DC is connected to a hardware CS pin... Ability to set drawing offsets, the ability to set clipping rectangle...

  13. #538
    Greetings all!
    I'd like to use the TFT color display on SPI1 on a Teensy 3.6 project.

    Am I right in thinking that I should be using the KurtE library? Can anyone point me towards any examples of this usage? I've read (most!) of this thread, plus the KurtE library thread, and I will admit to being a little confused about a couple of things. I'm sure an SPI1 example would help a lot.

    Cheers, Doug

  14. #539
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    4,060
    spi0 would be faster as it has a 4 item FIFO queue, SPI1 only has 1. kurts library would be the fastest provided you use the spi0 of course

  15. #540
    Senior Member Projectitis's Avatar
    Join Date
    Feb 2018
    Location
    New Zealand
    Posts
    191
    Does anyone know how to convert a font file (otf or ttf) for use with the libraries, as Frank B was doing? He doesn't seem to be around at the moment

  16. #541
    Senior Member
    Join Date
    Apr 2014
    Location
    -
    Posts
    9,756
    Hi, you can find the code to convert the files here: https://github.com/PaulStoffregen/IL.../master/extras
    If this does not help you, I can take a look - may take some days until I have time...

  17. #542
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    10,783
    As mentioned SPI0 is faster than SPI1 and SPI2, but SPI1 and 2 are still very usable, as they still pretty well double buffer, so probably most of the time we can still keep things going pretty much at full speed.

    As for example of how to use it with SPI1... The example program graphictest has a bunch of #define/#ifdef for different configurations including some for SPI1. Actually I believe there are two examples. One that uses normal pins and the other was setup to be able to use a MicroSD adapter that gave you access to the underlying pins, which you could then use for SPI1...

    So for example if your defined the TFT object like:

    Code:
    #ifdef SPI1_DISP
    #define TFT_DC 6 // 0xe4
    #define TFT_CS 7 // 0xe5
    #define TFT_SCK 32 //0xe2
    #define TFT_MISO 1 // 0xe3
    #define TFT_MOSI 0 // 0xe1
    #define TFT_RESET 8
    ILI9341_t3n tft = ILI9341_t3n(TFT_CS, TFT_DC, TFT_RESET, TFT_MOSI, TFT_SCK, TFT_MISO, &SPIN1);
    #endif
    It would use the SPI1 pins (SPIN1)... Note: the code was also setup that you could ignore specifying which SPIN object to use (SPIN1 -> SPI1), as the code will see that the pins specified were not valid for SPI and so it will check to see if they are valid for SPI1 and if not SPI2...

    Other than than that init, same usage pattern.

  18. #543
    Quote Originally Posted by tonton81 View Post
    spi0 would be faster as it has a 4 item FIFO queue, SPI1 only has 1. kurts library would be the fastest provided you use the spi0 of course
    I'm trying to add the display to an existing board that has SPI1 available. SPI0 would require a layout change (which could be done, if really required).
    If SPI1 is just a bad option, then I'll not waste any more time on it...

  19. #544
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    10,783
    As I mentioned in previous post, it SPI1 worked fine for me.

  20. #545
    Quote Originally Posted by KurtE View Post
    As I mentioned in previous post, it SPI1 worked fine for me.
    Yes, I'll aim to get that going today.
    Thanks,
    Doug

  21. #546
    Senior Member
    Join Date
    Apr 2014
    Location
    -
    Posts
    9,756
    @Projectitis:

    I've just converted the files... see attachment.
    Perhaps time to update my whole google-fonts archive... Unfortunately I deleted the Virtual Machine where I had my code for batch-processing all files. Have to re-write it..
    Attached Files Attached Files
    Last edited by Frank B; 03-19-2018 at 05:27 PM.

  22. #547
    Senior Member Projectitis's Avatar
    Join Date
    Feb 2018
    Location
    New Zealand
    Posts
    191
    Wow, fantastic - thanks Frank!

  23. #548
    Quote Originally Posted by KurtE View Post
    So for example if your defined the TFT object like:

    Code:
    #ifdef SPI1_DISP
    #define TFT_DC 6 // 0xe4
    #define TFT_CS 7 // 0xe5
    #define TFT_SCK 32 //0xe2
    #define TFT_MISO 1 // 0xe3
    #define TFT_MOSI 0 // 0xe1
    #define TFT_RESET 8
    ILI9341_t3n tft = ILI9341_t3n(TFT_CS, TFT_DC, TFT_RESET, TFT_MOSI, TFT_SCK, TFT_MISO, &SPIN1);
    #endif
    Hmmm, I'm only getting a blank, white, screen when I use the above definitions (and hookup appropriately!). The only difference I have is TFT_RESET 255, because I have that pin tied to 3.3V. (I did make sure that SPI1_DISP is #defined).

    The graphicstest program from the ILI9341_t3n library seems relatively happy, returning the following over serial:
    ILI9341 Test!
    After TFT Begin
    0
    Display Power Mode: 0xCE
    MADCTL Mode: 0x24
    Pixel Format: 0x2
    Image Format: 0x0
    Self Diagnostic: 0x0
    Benchmark Time (microseconds)
    Screen fill 225067
    Text 11551
    Lines 60026
    Horiz/Vert Lines 18414
    Rectangles (outline) 11704
    Rectangles (filled) 462564
    Circles (filled) 70791
    Circles (outline) 56546
    Triangles (outline) 14487
    Triangles (filled) 154526
    Rounded rects (outline) 25380
    Rounded rects (filled) 505430
    Hit key to continue
    Done!

    Any thoughts on what I might be missing? I've carefully checked the hookup n+1 times...

    Doug

  24. #549
    Senior Member Projectitis's Avatar
    Join Date
    Feb 2018
    Location
    New Zealand
    Posts
    191
    Doug, I wonder if not resetting the display could be a problem? I'm not sure what the symptoms are though.
    The code ILI9341_xxx::begin specifically resets the display before sending the init commands:
    Code:
    	// toggle RST low to reset
    	if (_rst < 255) {
    		pinMode(_rst, OUTPUT);
    		digitalWrite(_rst, HIGH);
    		delay(5);
    		digitalWrite(_rst, LOW);
    		delay(20);
    		digitalWrite(_rst, HIGH);
    		delay(150);
    	}
    Or are you resetting manually/some other way?

  25. #550
    That was it! (I should have tried that earlier).
    I had been simply tying Reset high because of the connection table on the PJRC product page and assuming it was required only for special circumstances. Silly me...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •