Forum Rule: Always post complete source code & details to reproduce any issue!
Page 24 of 24 FirstFirst ... 14 22 23 24
Results 576 to 600 of 600

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

  1. #576
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    6,899
    Quote Originally Posted by mjs513 View Post
    @KurtE and @Projectitis

    I incorporated the changes into my copy of the ILI9341_t3 library and the fonts do look nice - but as you said does take a bit longer but the quality is nicer especially for the larger fonts. I did test with the scrolltest.ino sketch but the fonts didn't seem to work as well but I don't have time to debug right now maybe later. But it does work.
    It is now pulled in to the ili9341_t3n library

    Thanks
    Kurt

  2. #577
    Senior Member Projectitis's Avatar
    Join Date
    Feb 2018
    Location
    New Zealand
    Posts
    170
    Hi @mjs513 - I've got family here for a few days, but after that I'll take a look I have a fix for the speed that will make it actually faster than the standard non ant-aliased font rendering, and I'll also debug the scrolling. I realised that I haven't published the script to create anti-aliased fonts either, so I'll do that too!

    @KurtE - fantastic, thank you In my libraries I typedef ILI9341_t3_font_t as packedbdf_t so that it isn't named after a display. What do you think of this strategy going forward?

  3. #578
    Senior Member Projectitis's Avatar
    Join Date
    Feb 2018
    Location
    New Zealand
    Posts
    170
    Scripts and instructions to create packed BDF anti-aliased fonts here:
    https://github.com/projectitis/packedbdf

    Full description of packedbdf_t data type also in the repo. Many thanks to Paul, spook and others for their initial work on all this material!
    note: packedbdf_t and ILI9341_t3_font_t are the same thing.

  4. #579
    Senior Member Projectitis's Avatar
    Join Date
    Feb 2018
    Location
    New Zealand
    Posts
    170
    Quote Originally Posted by mjs513 View Post
    I incorporated the changes into my copy of the ILI9341_t3 library and the fonts do look nice - but as you said does take a bit longer but the quality is nicer especially for the larger fonts. I did test with the scrolltest.ino sketch but the fonts didn't seem to work as well but I don't have time to debug right now maybe later. But it does work.
    @mjs513 I have updated my branch of Paul's ILI9341_t3 library with more efficient anti-alias rendering. Its about 25% faster than the standard non-anti-aliased rendering!
    Normal rendering: 14971
    Anti-aliased rendering: 11551

    I'll take a look at what's happening with scrolltest now (on KurtE's t3n version).

    EDIT: Have made a new example in my version of _t3n. I just had to change the call to setTextColor to also specify the background color.

    It still looks slightly wrong when the text is printed on the green bar at the bottom of the white box - the text that extends into the white box still has a green background color behind it. Since I'm not entirely sure what your intention is with scrolltest, I'll leave it at that for now and let you look into it if it's a problem?
    Last edited by Projectitis; 04-24-2019 at 05:30 AM.

  5. #580
    Senior Member Projectitis's Avatar
    Join Date
    Feb 2018
    Location
    New Zealand
    Posts
    170
    Aaaand have improved the original font rendering speed (1bpp, non anti-aliased fonts) of ILI9341_t3:
    original 1bpp fonts 14971
    improved 1bpp fonts 11360 (~25% faster)
    (Compare to new anti-alias fonts 11551)

    Find updates here: https://github.com/projectitis/ILI93...ti-alias-fonts

  6. #581
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    11,765
    Sounds like some good work

  7. #582
    Wow. 4/24/19 was the last update on this thread?

    What about T4 and ili9341_t3? Is there an ILI9341_t4 I'm missing somewhere?

  8. #583
    Junior Member
    Join Date
    Jan 2020
    Posts
    1
    HI All,
    I'm relatively new here, just tried this library on the T4 but just getting a white screen. If I use the adafruit library with the same wiring and pin assignments it works fine.
    Has anybody had this working with a t4 yet?

    thanks in advance
    Tony

  9. #584
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    6,899
    Quote Originally Posted by tonykenny View Post
    HI All,
    I'm relatively new here, just tried this library on the T4 but just getting a white screen. If I use the adafruit library with the same wiring and pin assignments it works fine.
    Has anybody had this working with a t4 yet?

    thanks in advance
    Tony
    Yes I have it working...

    It would help if you maybe gave a little more details, like, what version of Arduino and Teensyduino you are using? Platform maybe although maybe not so much in this case.

    But more importantly more details on how you have it wired in? Which display are you using...
    Which sketch and how is it configured? i.e. does your wiring match for MOSI, MISO, SCL as well as DC and CS? Do you have RST connected to a pin? If so do you specify it in the constructor and does it match your wiring

  10. #585
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    22,082
    I can also confirm it definitely does work.

    Quote Originally Posted by tonykenny View Post
    If I use the adafruit library with the same wiring and pin assignments it works fine.
    Adafruit's libraries support more pin combinations. Many of their libs support almost any pins, using slow GPIO access to the pins rather than hardware SPI. So one possible explanation is you may have used a pin assignment that's not supported by the optimized library, but works with Adafruit's lib because of their support for slow access using any pins. But really, that's just a blind guess, since I can't see your hardware & wiring, can't see your code or screen.

  11. #586
    I also have it working but my setup on SPI0 required 100 ohm series resistors on MOSI, MISO and SCK at the Teensy end. I also share SPI0 with touch (XPT2046) and SD card through the same resistors, all working properly.

  12. #587
    Junior Member
    Join Date
    Apr 2020
    Posts
    4
    I cannot even compile ILI9341_t3 graphicstest example.
    Isn't it compatible with T4 (or teensyduino 1.51)?

    Am i missing something?

    PS: Adafruit GFX library is installed. BTW using Adafruit ILI9341.h and their own graphicstest example compiles and works just fine.

    Code:
    C:\Users\Thanos\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h: In member function 'void ILI9341_t3::waitFifoNotFull()':
    
    C:\Users\Thanos\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h:178:9: error: 'KINETISK_SPI0' was not declared in this scope
    
        sr = KINETISK_SPI0.SR;
    
             ^
    
    C:\Users\Thanos\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h: In member function 'void ILI9341_t3::waitFifoEmpty()':
    
    C:\Users\Thanos\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h:187:9: error: 'KINETISK_SPI0' was not declared in this scope
    
        sr = KINETISK_SPI0.SR;
    
             ^
    
    C:\Users\Thanos\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h: In member function 'void ILI9341_t3::waitTransmitComplete()':
    
    C:\Users\Thanos\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h:193:12: error: 'KINETISK_SPI0' was not declared in this scope
    
       while (!(KINETISK_SPI0.SR & SPI_SR_TCF)) ; // wait until final output done
    
                ^
    
    C:\Users\Thanos\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h:193:31: error: 'SPI_SR_TCF' was not declared in this scope
    
       while (!(KINETISK_SPI0.SR & SPI_SR_TCF)) ; // wait until final output done
    
                                   ^
    
    C:\Users\Thanos\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h:194:9: error: 'KINETISK_SPI0' was not declared in this scope
    
       tmp = KINETISK_SPI0.POPR;                  // drain the final RX FIFO word
    
             ^
    
    C:\Users\Thanos\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h: In member function 'void ILI9341_t3::writecommand_cont(uint8_t)':
    
    C:\Users\Thanos\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h:197:3: error: 'KINETISK_SPI0' was not declared in this scope
    
       KINETISK_SPI0.PUSHR = c | (pcs_command << 16) | SPI_PUSHR_CTAS(0) | SPI_PUSHR_CONT;
    
       ^
    
    C:\Users\Thanos\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h:197:67: error: 'SPI_PUSHR_CTAS' was not declared in this scope
    
       KINETISK_SPI0.PUSHR = c | (pcs_command << 16) | SPI_PUSHR_CTAS(0) | SPI_PUSHR_CONT;
    
                                                                       ^
    
    C:\Users\Thanos\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h:197:71: error: 'SPI_PUSHR_CONT' was not declared in this scope
    
       KINETISK_SPI0.PUSHR = c | (pcs_command << 16) | SPI_PUSHR_CTAS(0) | SPI_PUSHR_CONT;
    
                                                                           ^
    
    C:\Users\Thanos\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h: In member function 'void ILI9341_t3::writedata8_cont(uint8_t)':
    
    C:\Users\Thanos\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h:201:3: error: 'KINETISK_SPI0' was not declared in this scope
    
       KINETISK_SPI0.PUSHR = c | (pcs_data << 16) | SPI_PUSHR_CTAS(0) | SPI_PUSHR_CONT;
    
       ^
    
    C:\Users\Thanos\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h:201:64: error: 'SPI_PUSHR_CTAS' was not declared in this scope
    
       KINETISK_SPI0.PUSHR = c | (pcs_data << 16) | SPI_PUSHR_CTAS(0) | SPI_PUSHR_CONT;
    
                                                                    ^
    
    C:\Users\Thanos\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h:201:68: error: 'SPI_PUSHR_CONT' was not declared in this scope
    
       KINETISK_SPI0.PUSHR = c | (pcs_data << 16) | SPI_PUSHR_CTAS(0) | SPI_PUSHR_CONT;
    
                                                                        ^
    
    C:\Users\Thanos\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h: In member function 'void ILI9341_t3::writedata16_cont(uint16_t)':
    
    C:\Users\Thanos\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h:205:3: error: 'KINETISK_SPI0' was not declared in this scope
    
       KINETISK_SPI0.PUSHR = d | (pcs_data << 16) | SPI_PUSHR_CTAS(1) | SPI_PUSHR_CONT;
    
       ^
    
    C:\Users\Thanos\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h:205:64: error: 'SPI_PUSHR_CTAS' was not declared in this scope
    
       KINETISK_SPI0.PUSHR = d | (pcs_data << 16) | SPI_PUSHR_CTAS(1) | SPI_PUSHR_CONT;
    
                                                                    ^
    
    C:\Users\Thanos\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h:205:68: error: 'SPI_PUSHR_CONT' was not declared in this scope
    
       KINETISK_SPI0.PUSHR = d | (pcs_data << 16) | SPI_PUSHR_CTAS(1) | SPI_PUSHR_CONT;
    
                                                                        ^
    
    C:\Users\Thanos\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h: In member function 'void ILI9341_t3::writecommand_last(uint8_t)':
    
    C:\Users\Thanos\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h:210:3: error: 'KINETISK_SPI0' was not declared in this scope
    
       KINETISK_SPI0.SR = SPI_SR_TCF;
    
       ^
    
    C:\Users\Thanos\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h:210:22: error: 'SPI_SR_TCF' was not declared in this scope
    
       KINETISK_SPI0.SR = SPI_SR_TCF;
    
                          ^
    
    C:\Users\Thanos\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h:211:67: error: 'SPI_PUSHR_CTAS' was not declared in this scope
    
       KINETISK_SPI0.PUSHR = c | (pcs_command << 16) | SPI_PUSHR_CTAS(0);
    
                                                                       ^
    
    C:\Users\Thanos\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h: In member function 'void ILI9341_t3::writedata8_last(uint8_t)':
    
    C:\Users\Thanos\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h:216:3: error: 'KINETISK_SPI0' was not declared in this scope
    
       KINETISK_SPI0.SR = SPI_SR_TCF;
    
       ^
    
    C:\Users\Thanos\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h:216:22: error: 'SPI_SR_TCF' was not declared in this scope
    
       KINETISK_SPI0.SR = SPI_SR_TCF;
    
                          ^
    
    C:\Users\Thanos\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h:217:64: error: 'SPI_PUSHR_CTAS' was not declared in this scope
    
       KINETISK_SPI0.PUSHR = c | (pcs_data << 16) | SPI_PUSHR_CTAS(0);
    
                                                                    ^
    
    C:\Users\Thanos\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h: In member function 'void ILI9341_t3::writedata16_last(uint16_t)':
    
    C:\Users\Thanos\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h:222:3: error: 'KINETISK_SPI0' was not declared in this scope
    
       KINETISK_SPI0.SR = SPI_SR_TCF;
    
       ^
    
    C:\Users\Thanos\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h:222:22: error: 'SPI_SR_TCF' was not declared in this scope
    
       KINETISK_SPI0.SR = SPI_SR_TCF;
    
                          ^
    
    C:\Users\Thanos\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h:223:64: error: 'SPI_PUSHR_CTAS' was not declared in this scope
    
       KINETISK_SPI0.PUSHR = d | (pcs_data << 16) | SPI_PUSHR_CTAS(1);
    
                                                                    ^

  13. #588
    Junior Member
    Join Date
    Apr 2020
    Posts
    4
    My mistake (the above); I had downloaded and installed the latest ILI9341_t3 via IDE's library manager instead using the one that was already installed by teensyduino 1.51.
    That compiles and works fine on T4.

    Sorry for the false alarm!

  14. #589
    Senior Member jim lee's Avatar
    Join Date
    Dec 2016
    Location
    Anacortes, WA
    Posts
    156
    Same thing. I can't compile this library. To update is the easiest thing to do just to grab a new teensyduino?

    Code:
    #include <Adafruit_GFX.h>
    #include <ILI9341_t3.h>
    
    
    void setup() {
    
    }
    
    void loop() {
    
    }
    Thanks!

    -jim lee

  15. #590
    Senior Member jim lee's Avatar
    Join Date
    Dec 2016
    Location
    Anacortes, WA
    Posts
    156
    Update to above..

    D-loaded fresh arduino and the new teensyduino. Mac OS 10.13.6

    Same result.

    Code:
    Multiple libraries were found for "Adafruit_GFX.h"/var/folders/wt/mcbdk5yn5wz6z1zcpf20xvzw0000gn/T/arduino_build_493687/libraries/ILI9341_t3/ILI9341_t3.cpp.o: In function `Adafruit_GFX_Button::drawButton(bool)':
    
     Used: /Applications/Teensyduino.app/Contents/Java/hardware/teensy/avr/libraries/Adafruit_GFX
     Not used: /Users/jimlee/Documents/Arduino/libraries/Adafruit_GFX_Library
    /Applications/Teensyduino.app/Contents/Java/hardware/teensy/avr/libraries/ILI9341_t3/ILI9341_t3.cpp:1851: multiple definition of `Adafruit_GFX_Button::drawButton(bool)'
    /var/folders/wt/mcbdk5yn5wz6z1zcpf20xvzw0000gn/T/arduino_build_493687/libraries/Adafruit_GFX/Adafruit_GFX.cpp.o:/Applications/Teensyduino.app/Contents/Java/hardware/teensy/avr/libraries/Adafruit_GFX/Adafruit_GFX.cpp:1587: first defined here
    /Applications/Teensyduino.app/Contents/Java/hardware/tools/arm/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/bin/ld: Disabling relaxation: it will not work with multiple definitions
    /var/folders/wt/mcbdk5yn5wz6z1zcpf20xvzw0000gn/T/arduino_build_493687/libraries/ILI9341_t3/ILI9341_t3.cpp.o: In function `Print::flush()':
    /Applications/Teensyduino.app/Contents/Java/hardware/teensy/avr/libraries/ILI9341_t3/ILI9341_t3.cpp:1377: multiple definition of `Adafruit_GFX_Button::contains(short, short)'
    /var/folders/wt/mcbdk5yn5wz6z1zcpf20xvzw0000gn/T/arduino_build_493687/libraries/Adafruit_GFX/Adafruit_GFX.cpp.o:/Applications/Teensyduino.app/Contents/Java/hardware/teensy/avr/cores/teensy3/Print.h:61: first defined here
    collect2: error: ld returned 1 exit status
    Error compiling for board Teensy 3.2 / 3.1.
    Also, what is this new way of doing things? teensyduino.. Is it a replacement of the IDE? Because that's the way it seems to be acting on my machine. It has the same icon as the IDE, it runs like the IDE. Do I still need the original IDE? Confused here.

    -jim lee

  16. #591
    Junior Member
    Join Date
    Jul 2015
    Posts
    14
    Hello, I'm having some problems with the combination of ILI9341_t3n, TFT, Touch on the Teensy LC and wonder if I'm missing something.

    The road so far:

    1. purchase the DISPLAY_ILI9341_TOUCH from pjrc
    2. come to learn that the ILI9341_t3 doesn't work with Teensy_LC
    3. relieved to find that the Adafruit display library does work, even with SPI mode
    4. run the example ino ILI9341Test (from XPT2045_Touchscreen/examples) successfully
    5. get disappointed by flickering
    6. discover that ILI9341_t3n offers a solution to the flickering problem.
    6a. Become impressed that I can get cool fonts, fast code and anti-flicker working with Teensy_LC (kudos to @KurtE and others for this!)
    7. attempt to get the new anti-flickering working with touch screen
    7a. fail - feels like an SPI-conflict of some sort, result
    7b. instrument code to switch between the variety of running mode
    7c. reach out to the sages for advice

    Any suggestions are greatly appreciated. (I did try touch in both IRQ and no-IRQ mode, fwiw).
    Kind regards - Dana


    here's the modified code example (running on latest teensyduino (1.53 beta3) atop arduino 1.8.12)

    Code:
    #include <XPT2046_Touchscreen.h>
    #include <SPI.h>
    
    #define TEST_DISPLAY 1
    #define USE_T3N 0
    
    #define TOUCH_IRQ_PIN  255 /* vs 2 */
    #define TOUCH_CS_PIN  8
    #define DISPLAY_CS_PIN 10
    #define DISPLAY_DC_PIN  21
    // MOSI=11, MISO=12, SCK=13
    
    #if USE_T3N
    #include <ILI9341_t3n.h>
    #include <ili9341_t3n_font_Arial.h>
    ILI9341_t3n tft = ILI9341_t3n(DISPLAY_CS_PIN, DISPLAY_DC_PIN);
    #else
    #include <Adafruit_ILI9341.h>
    Adafruit_ILI9341 tft(&SPI, DISPLAY_DC_PIN, DISPLAY_CS_PIN);
    #endif
    
    
    XPT2046_Touchscreen ts(TOUCH_CS_PIN, TOUCH_IRQ_PIN);
    
    void setup() 
    {
      Serial.begin(38400);
      tft.begin();
      tft.setRotation(1);
      tft.fillScreen(ILI9341_BLACK);
      tft.setTextSize(4);
      
      ts.begin();
      ts.setRotation(1);
      while (!Serial && (millis() <= 1000));
    }
    
    boolean wastouched = true;
    
    void loop() {
      boolean istouched = ts.touched();
      if (istouched) {
        TS_Point p = ts.getPoint();
        if (!wastouched) {
          #if TEST_DISPLAY
          tft.fillScreen(ILI9341_BLACK);
          tft.setTextColor(ILI9341_YELLOW);
          #if USE_T3N
          tft.setFont(Arial_60);
          #endif
          tft.setCursor(60, 80);
          tft.print("Touch");
          #endif
          Serial.println("Touch");
        }
        #if TEST_DISPLAY
        tft.fillRect(100, 150, 140, 60, ILI9341_BLACK);
        tft.setTextColor(ILI9341_GREEN);
        #if USE_T3N
        tft.setFont(Arial_24);
        #endif
        tft.setCursor(100, 150);
        tft.print("X = ");
        tft.print(p.x);
        tft.setCursor(100, 180);
        tft.print("Y = ");
        tft.print(p.y);
        #endif
        Serial.print(", x = ");
        Serial.print(p.x);
        Serial.print(", y = ");
        Serial.println(p.y);
      } else {
        if (wastouched) {
          #if TEST_DISPLAY
          tft.fillScreen(ILI9341_BLACK);
          tft.setTextColor(ILI9341_RED);
          #if USE_T3N
          tft.setFont(Arial_48);
          #endif
          tft.setCursor(120, 50);
          tft.print("No");
          tft.setCursor(80, 120);
          tft.print("Touch");
          #endif
          Serial.println("no touch");
        }
      }
      wastouched = istouched;
      delay(100);
    }

  17. #592
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    6,899
    If needed, I can probably wire something up...

    But the first thing I would try, is something simple, which should be in the touch paint, but does not look like it is...

    That is if you are using multiple CS pins on SPI buss, you should make sure the others are logically deasserted before you start initialization...
    Could be done with Pull Up resistors or first try changing setup:

    Code:
    void setup() 
    {
      Serial.begin(38400);
      pinMode(TOUCH_CS_PIN, OUTPUT);
      digitalWriteFast(TOUCH_CS_PIN, HIGH);
      tft.begin();
      tft.setRotation(1);
      tft.fillScreen(ILI9341_BLACK);
      tft.setTextSize(4);
      
      ts.begin();
      ts.setRotation(1);
      while (!Serial && (millis() <= 1000));
    }
    And see if that solves the issue.

  18. #593
    Junior Member
    Join Date
    Jul 2015
    Posts
    14
    Hi Kurt, thanks for the response! I did try adding the two lines to the setup and still see the same behavior in both IRQ and non-IRQ touch modes. I also tried a pull-up resistor on TOUCH_CS_PIN, then on both CS pins. I also added a few more print statements and find that the problem seems to be that this line:

    Code:
    ts.touched();
    is blocking/hanging on the second call. In other words, a print statement at the top of loop only fires twice.

    This implies that the sequence of events is as follows:

    1. initialize screen (okay)
    2. initialize touch (okay)
    3. loop 1:
    - check touched (returns false, so okay)
    - screen draw "No Touch", end loop (screen shows the right thing)
    4. loop 2:
    - check touched (hangs)

    Is it possible that the SPI transaction is still being held-open (whatever that might mean) after the line:
    Code:
     tft.print("Touch");
    .

    Finally: I'm unsure I understand the full implications of your statement:
    using multiple CS pins on SPI bus
    . I'm happy to try alternate CS pins, but I can't afford the pins to assign a different SPI bus to both the screen and the touch.

  19. #594
    Junior Member
    Join Date
    Jul 2015
    Posts
    14
    More evidence: reorganizing the code, i see that ts.touched() hangs after the first post-init tft activity. (I tried both fillScreen and print). I've just added the modified setup in which the expected line "touched" (or "not touched") doesn't appear.

    regards, Dana

    Code:
    void setup() 
    {
      Serial.begin(38400);
      pinMode(TOUCH_CS_PIN, OUTPUT);
      digitalWriteFast(TOUCH_CS_PIN, HIGH);
      
      tft.begin();
      tft.setRotation(1); /* 1: m2 rotation, right edge is connector */
      tft.fillScreen(ILI9341_BLACK);
      tft.setTextSize(4);
      
      ts.begin();
      ts.setRotation(3); /* 3: xmin->xmax, ymin is top, ymax is bottom */
      while (!Serial && (millis() <= 1000));
      Serial.println("start");
    
      /* tft activity after ts.begin causes touched to hang */
      #if USE_T3N
      tft.setFont(Arial_60);
      tft.print("hello");
      delay(2000);
      tft.fillScreen(ILI9341_BLACK);
      delay(50);
      boolean istouched = ts.touched();
      Serial.println(istouched ? "touched" : "not touched");
      #endif
    }

  20. #595
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    6,899
    Note: I hooked up an LC, although slightly different pins...

    Code:
    #include <XPT2046_Touchscreen.h>
    #include <SPI.h>
    
    #define TEST_DISPLAY 1
    #define USE_T3N 0
    
    #define TOUCH_IRQ_PIN  255 /* vs 2 */
    #define TOUCH_CS_PIN  7
    #define DISPLAY_CS_PIN 10
    #define DISPLAY_DC_PIN  9
    // MOSI=11, MISO=12, SCK=13
    #define DISPLAY_RESET_PIN 8
    
    #if USE_T3N
    #include <ILI9341_t3n.h>
    #include <ili9341_t3n_font_Arial.h>
    ILI9341_t3n tft = ILI9341_t3n(DISPLAY_CS_PIN, DISPLAY_DC_PIN, DISPLAY_RESET_PIN);
    #else
    #include <Adafruit_ILI9341.h>
    Adafruit_ILI9341 tft(&SPI, DISPLAY_DC_PIN, DISPLAY_CS_PIN);
    #endif
    
    
    XPT2046_Touchscreen ts(TOUCH_CS_PIN, TOUCH_IRQ_PIN);
    
    void setup() 
    {
      Serial.begin(38400);
      tft.begin();
      tft.setRotation(1);
      tft.fillScreen(ILI9341_BLACK);
      tft.setTextSize(4);
      
      ts.begin();
      ts.setRotation(1);
      while (!Serial && (millis() <= 1000));
    }
    
    boolean wastouched = true;
    
    void loop() {
      boolean istouched = ts.touched();
      if (istouched) {
        TS_Point p = ts.getPoint();
        if (!wastouched) {
          #if TEST_DISPLAY
          tft.fillScreen(ILI9341_BLACK);
          tft.setTextColor(ILI9341_YELLOW);
          #if USE_T3N
          tft.setFont(Arial_60);
          #endif
          tft.setCursor(60, 80);
          tft.print("Touch");
          #endif
          Serial.println("Touch");
        }
        #if TEST_DISPLAY
        tft.fillRect(100, 150, 140, 60, ILI9341_BLACK);
        tft.setTextColor(ILI9341_GREEN);
        #if USE_T3N
        tft.setFont(Arial_24);
        #endif
        tft.setCursor(100, 150);
        tft.print("X = ");
        tft.print(p.x);
        tft.setCursor(100, 180);
        tft.print("Y = ");
        tft.print(p.y);
        #endif
        Serial.print(", x = ");
        Serial.print(p.x);
        Serial.print(", y = ");
        Serial.println(p.y);
      } else {
        if (wastouched) {
          #if TEST_DISPLAY
          tft.fillScreen(ILI9341_BLACK);
          tft.setTextColor(ILI9341_RED);
          #if USE_T3N
          tft.setFont(Arial_48);
          #endif
          tft.setCursor(120, 50);
          tft.print("No");
          tft.setCursor(80, 120);
          tft.print("Touch");
          #endif
          Serial.println("no touch");
        }
      }
      wastouched = istouched;
      delay(100);
    }
    And it is working.

    One thing I would check with your setup, is, is there something hooked up to the RESET pin of the display. If it is floating, than may not work. May need to be set high... Normally I hook mine up to something, like in the above to pin 8... I changed your touched to 7 as the 8 for reset was in the graphics test example

  21. #596
    Junior Member
    Join Date
    Jul 2015
    Posts
    14
    in the code as posted, I see this:

    #define USE_T3N 0

    does your setup work if it's set to this:

    #define USE_T3N 1

    I appreciate your help with this!


    (and yes, my reset pin is held high)

  22. #597
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    6,899
    Nope, appears to be an issue... I will take a quick look...

  23. #598
    Junior Member
    Join Date
    Jul 2015
    Posts
    14
    Phew - thought I was crazy for a minute. Glad to see that the issue can be duplicated.
    Please let me know if there's anything on my end to assist. I'm starting to delve into the LC-specific code in t3n and am presently battling the learning curve for the low-level SPI machinations.

    I did compare Adafruit_BusIO's spi support and currently *guess* that the fact that they directly write to CS on begin/endTransaction is an example of a less speedy, but easier-to-understand approach.

  24. #599
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    6,899
    It looks like SPI library call SPI.transfer(x) has issues if the library leaves the SPI buss configured for 16 bit mode.

    So now the output data 16 bits last, now switches back to 8 bits and also reads in status register.

    This appears to get your test to run...

    Try syncing up ili9341_t3n

  25. #600
    Junior Member
    Join Date
    Jul 2015
    Posts
    14
    Wow - so far your change looks good! I'll keep this thread posted if I run into other difficulties.
    Thanks *mucho* for looking into this!

    cheers, Dana

Posting Permissions

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