2.8 ILI9341 restive touch miso not connected ?

Status
Not open for further replies.
P#22 displays 'Pressure' - is that a 3D pressure on the display value you can easily reference? If you see a high pressure value do you see less noise in the reported readings?

When I did a BING - everything with correlation quickly devolved to statistical analysis - i.e. lots of samples and math.

Are samples polled or interrupt supplied? How much response time is lost with a 2 or 4 oversample that you could sum, then shift away? That would minimize but not ignore errant readings, but also make dragging lag.
 
I've added 3X oversampling, where the best 2 of 3 are averaged.

Not sure if it really makes much of a difference. Curious to hear feedback from anyone who uses it with real displays.
 
A qualitative look at the serial output stream of x&y position shows that the 3x oversampling works.

For these plots I'm trying to hold my finger as steady as I can.
Capture125.JPG
This is X and Y coordinates plotted vs time.
Yellow is X and Blue is Y
Each horizontal grid line is about 190 counts out of 3800 (Maximum)

Edit: The plot is created by a nice little Windows program I recently found called Serial Chart by Starlino.com
It plots a realtime strip chart from comma separated variable data read directly from the COM port.

Edit 2: Pressure Value displayed is spewed directly from the library as the Z value.
I didn't notice any correlation between X-Y noise and changing Z pressure.
I have a capacitive touch stylus around here somewhere... I will try that next.
 
Last edited:
Wow! That was quick. I'm still amazed these things can be so inexpensive. Just out of curiosity, how much current does this display need? I assume there is a built-in backlight, which probably draws most of the power, but if you turn off the backlight the display is probably unreadable?

PS. @Wozzy: I like the KST Plot program which can do live-update plots from .csv file as it is being written. Windows/Mac/Linux versions available. I think KST can do more complex plots, but it looks like SerialChart is easier to use.
 
Last edited:
Good question. I haven't measured precisely, but a Teensy 3.2 (running at 96 MHz) and the display are together drawing approx 72 mA from my power supply.
 
Found and ordered! :) Priority shipping (to allow protective packaging) from Oregon will be must faster than Hong Kong- now I can have a distraction with nearly instant gratification!

Hehe, my recent distraction resulted in my first teensy 3.1 murdered. :)
It lives its second life as a keychain as a constant reminder to be more careful.
 
I'm about to update my GOOD efforts with your that distraction - if only you hadn't distracted yourself during that distraction that Teensy would be alive and well.

Now I MUST order from OSH ASAP to get the PJRC Carrier board - if only PJRC stocked them to drop one in my package :)
 
I've added 3X oversampling, where the best 2 of 3 are averaged.

Not sure if it really makes much of a difference. Curious to hear feedback from anyone who uses it with real displays.

Works good. Dividing by ten ( tft.print(p.x / 10); ) gives very good results.
 
If samples come that fast then doing 8 and a bit shift divide would be trivial. Doing logic to exclude one could throw out the right one and take more cycles. Making that oversample user adjustable [2,4,8] might allow fine tuning on 'noise versus speed' critical systems.
 
yup, something like that. Or
x &= ~0x7;

Then, increasing the Z_THRESHOLD gives better results (at least for my display).


@paul:
The touchpaint example is ok with these lines changed in XPT2046_Touchscreen.cpp
Code:
    if (z >= Z_THRESHOLD) {
        xraw = 4096-y;
        yraw = x;
    }

That's not the "correct" solution, but gives a hint what to change.

Edit:
The edited "Touchpaint" (if someone wants to try it):
Code:
/***************************************************
  This is our touchscreen painting example for the Adafruit ILI9341 Shield
  ----> http://www.adafruit.com/products/1651

  Check out the links above for our tutorials and wiring diagrams
  These displays use SPI to communicate, 4 or 5 pins are required to
  interface (RST is optional)
  Adafruit invests time and resources providing this open source code,
  please support Adafruit and open-source hardware by purchasing
  products from Adafruit!

  Written by Limor Fried/Ladyada for Adafruit Industries.
  MIT license, all text above must be included in any redistribution
 ****************************************************/


#include <SPI.h>
#include <Wire.h>      // this is needed even tho we aren't using it
#include <ILI9341_t3.h>
#include <XPT2046_Touchscreen.h>


// This is calibration data for the raw touch data to the screen coordinates
#define TS_MINX 150
#define TS_MINY 130
#define TS_MAXX 3800
#define TS_MAXY 4000

// The XPT2046 uses hardware SPI on the shield, and #8
#define CS_PIN  8
XPT2046_Touchscreen ts(CS_PIN);
// The display also uses hardware SPI, plus #9 & #10
#define TFT_CS 10
#define TFT_DC  9
ILI9341_t3 tft = ILI9341_t3(TFT_CS, TFT_DC);


// Size of the color selection boxes and the paintbrush size
#define BOXSIZE 40
#define PENRADIUS 3
int oldcolor, currentcolor;

void setup(void) {
 // while (!Serial);     // used for leonardo debugging
 
  Serial.begin(9600);
  Serial.println(F("Touch Paint!"));
  
  tft.begin();
    ts.begin();
  tft.fillScreen(ILI9341_BLACK);
  
  // make the color selection boxes
  tft.fillRect(0, 0, BOXSIZE, BOXSIZE, ILI9341_RED);
  tft.fillRect(BOXSIZE, 0, BOXSIZE, BOXSIZE, ILI9341_YELLOW);
  tft.fillRect(BOXSIZE*2, 0, BOXSIZE, BOXSIZE, ILI9341_GREEN);
  tft.fillRect(BOXSIZE*3, 0, BOXSIZE, BOXSIZE, ILI9341_CYAN);
  tft.fillRect(BOXSIZE*4, 0, BOXSIZE, BOXSIZE, ILI9341_BLUE);
  tft.fillRect(BOXSIZE*5, 0, BOXSIZE, BOXSIZE, ILI9341_MAGENTA);
 
  // select the current color 'red'
  tft.drawRect(0, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE);
  currentcolor = ILI9341_RED;
}


void loop()
{
  // See if there's any  touch data for us
  if (ts.bufferEmpty()) {
    return;
  }
  /*
  // You can also wait for a touch
  if (! ts.touched()) {
    return;
  }
  */

  // Retrieve a point  
  TS_Point p = ts.getPoint();
  
 /*
  Serial.print("X = "); Serial.print(p.x);
  Serial.print("\tY = "); Serial.print(p.y);
  Serial.print("\tPressure = "); Serial.println(p.z);  
 */
 
  // Scale from ~0->4000 to tft.width using the calibration #'s
  p.x = map(p.x, TS_MINX, TS_MAXX, 0, tft.width());
  p.y = map(p.y, TS_MINY, TS_MAXY, 0, tft.height());

  /*
  Serial.print("("); Serial.print(p.x);
  Serial.print(", "); Serial.print(p.y);
  Serial.println(")");
  */

  if (p.y < BOXSIZE) {
     oldcolor = currentcolor;

     if (p.x < BOXSIZE) { 
       currentcolor = ILI9341_RED; 
       tft.drawRect(0, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE);
     } else if (p.x < BOXSIZE*2) {
       currentcolor = ILI9341_YELLOW;
       tft.drawRect(BOXSIZE, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE);
     } else if (p.x < BOXSIZE*3) {
       currentcolor = ILI9341_GREEN;
       tft.drawRect(BOXSIZE*2, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE);
     } else if (p.x < BOXSIZE*4) {
       currentcolor = ILI9341_CYAN;
       tft.drawRect(BOXSIZE*3, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE);
     } else if (p.x < BOXSIZE*5) {
       currentcolor = ILI9341_BLUE;
       tft.drawRect(BOXSIZE*4, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE);
     } else if (p.x < BOXSIZE*6) {
       currentcolor = ILI9341_MAGENTA;
       tft.drawRect(BOXSIZE*5, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE);
     }

     if (oldcolor != currentcolor) {
        if (oldcolor == ILI9341_RED) 
          tft.fillRect(0, 0, BOXSIZE, BOXSIZE, ILI9341_RED);
        if (oldcolor == ILI9341_YELLOW) 
          tft.fillRect(BOXSIZE, 0, BOXSIZE, BOXSIZE, ILI9341_YELLOW);
        if (oldcolor == ILI9341_GREEN) 
          tft.fillRect(BOXSIZE*2, 0, BOXSIZE, BOXSIZE, ILI9341_GREEN);
        if (oldcolor == ILI9341_CYAN) 
          tft.fillRect(BOXSIZE*3, 0, BOXSIZE, BOXSIZE, ILI9341_CYAN);
        if (oldcolor == ILI9341_BLUE) 
          tft.fillRect(BOXSIZE*4, 0, BOXSIZE, BOXSIZE, ILI9341_BLUE);
        if (oldcolor == ILI9341_MAGENTA) 
          tft.fillRect(BOXSIZE*5, 0, BOXSIZE, BOXSIZE, ILI9341_MAGENTA);
     }
  }
  if (((p.y-PENRADIUS) > BOXSIZE) && ((p.y+PENRADIUS) < tft.height())) {
    tft.fillCircle(p.x, p.y, PENRADIUS, currentcolor);
  }
}
Obviously, the comments (first lines) are wrong :)
 
Last edited:
If samples come that fast then doing 8 and a bit shift divide would be trivial.

Within the library, each measurement on each axis takes approx 8 us. Version 1.1 does 3 measurements on each axis, plus the 2 needed to determine the touch pressure. With some overheard, the whole process is probably between 70 to 75 us to read the touch sensor.

Doing logic to exclude one could throw out the right one and take more cycles.

In an attempt to throw out the worst sample, the code currently computes the distance between each pair. The pair with the least distance apart is kept and averaged. That seems to be pretty effective. But of course more work could be done on better ways.....

[/QUOTE]
Making that oversample user adjustable [2,4,8] might allow fine tuning on 'noise versus speed' critical systems.[/QUOTE]

Please feel free to dig into the library source!

At this moment I'm pretty happy with the performance of version 1.1, so I'm not personally planning to spend much more time on this. But if you or anyone else comes up with a much better way, I'd be happy to merge a good pull request.
 
I am excited about this. I am confused though regarding choosing a ili9341 with xpt2046 touchscreen that is compatible with the OSH board pointed to by Paul.
Seems like the board has one row of connectors but many of the displays I see have two rows.

Can someone point me to an actual display (preferably 3.2") that is compatible with the OSH board and Touchscreen library?

thanks,

Richard
 
Post #30 above has this link to a 'one' row supported unit in the PJRC Store. It is a 2.8" board though.

I ordered a couple yesterday and I'll have them by Friday according to the tracking number I got today. I could have ordered them from Hong Kong and saved a couple bucks - per Paul these are tested to work so I won't get any lemons and they will be the model supported by the PJRC library - and I won't forget I ordered them before they get here.

I placed my first OSH board order today too - they are scheduled on panels to be made 10/15 so I suppose I'll see them by the end of next week.
 
Last edited:
Seems like the board has one row of connectors but many of the displays I see have two rows.

You need the type with 1 row of 14 pins.

The 2 row types usually have 40 pins (20 per row). Those are meant for parallel connection. They can be used with the UTFT library. The parallel interface is very fast, but it requires a lot of wires that use up nearly all the pins on Teensy.

We should have more in stock in about 1 week. If you buy from PJRC, you'll get a display we actually tested.

But you'll probably do fine to get one from China. Just make sure it has 1 row of 14 pins. Take a moment to count the number of pins in the photos. If there's a photo of the back side where signal names are printed, compare the names to the "ILI9341 Pin" column in the connections table. There's always some small risk when you build stuff directly from Chinese merchants, but if the photo has 14 pins and you can see the same signal names in the same order, odds are very good it'll work.

If ordering from China, I highly recommend buying a spare.
 
...The added components are two 10K resistors, as pullups on the two CS signals....

And it looks like you switched from surface mount to a through hole capacitor on the ground leg of the fuse. Thank you.

Ordered some screens and the boards from OSH Park, now just rounding out my Digi-Key order...

Digi-Key has a 14 position 0.100" housing for the connector - Digikey 609-2329-ND (to make a pig-tail for enclosure mounting)

And I found what looks to be an equivalent DC power jack to the one you use - Digikey CP-002A-ND (a few cents more, but I seem order more from Digi-Key than Mouser these days)

Thanks for adding these screens and the work on the library too!

--Jon
 
Jon - thanks for the digikey jack part# - with my display and OSH order I'll need to finish Digikey too for some of the 6 OSH boards. What part # did you use for the 1uF capacitor? So many parts - so many distractions.
 
Tim — On the older OSH test boards for the smaller non-touchscreen Paul used a surface mount 1uF 0805 capacitor - Digikey 1276-1066-1-ND.

Thanks, I saw the update to the board as you noted so knew the SMD was out of date. Being new to this - my desk doesn't have those kind of drawers. I may have picked up a suitable cap assortment. Searching on Digikey is daunting knowing a few functional words can take you to the wrong list - or even the right one with a few thousand parts on many pages to differentiate - and caps having so many material types . . . and then when you find a suitable through hole - there is the the leg distance. It looks like the OSH turn around is longer than I thought so I have time it seems for Paul to update. Though looking now at the OSH images it seems the cap legs are .10"
 
Not to hijack the original thread, but when re-starting in electronics a few years ago, I found it easy to buy some of the assortments from Jameco...

This catalog page has their most popular assortments, and I'd get the ceramic capacitors, radial electrolytics and tantalum's. Just the "refill" part numbers, unless you want to buy in to their whole drawer organization system (which I didn't).

They also have various E12 and other combinations of resistors on a separate catalog page.

I got a couple sets of Akro-Mils 44 drawer sets and hung them on the wall. But talking about component organization here, is probably like discussing religion, so just take this as one person's opinion.

Digi-Key and Mouser probably have similar assortments, if you know how to search for them, like E12 or E24 1/4 watt resistor assortments.

HTH,

--Jon
 
Status
Not open for further replies.
Back
Top