2.4" 320x240 Touchscreen Issue

Please tell us which board you are using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
snx
 
Posts: 3
Joined: Mon Jul 26, 2021 3:18 pm

2.4" 320x240 Touchscreen Issue

Post by snx »

Hi

Recently i purchased the 2.4" 320x240 Touchscreen For All Feathers (Product ID:3315), and loaded the example-sketch from arduino (touchpaint_feather). It works on the screen, the colors paint where i put my finger, but i was curious how the boxes work, but they did not work at all.

Now what i've tried, is to find out why it does not work correctly and for this i used a arduino sketch to print out original values, and mapped values:

Code: Select all

oid loop() {
   // Retrieve a point  
  TS_Point p = ts.getPoint();
  
  // Store  unmapped
  int16_t raw_x = p.x;
  int16_t raw_y =p.y; 

  // 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("Touchpoints are: [unm. / map.]   x-axis:[");
 Serial.print(raw_x);
 Serial.print("/");
 Serial.print(p.x);
 Serial.print("] y-axis:[");
 Serial.print(raw_y);
 Serial.print("/");
 Serial.print(p.y);
 Serial.println("]");
 delay(2500);

 //copied from original adafruit example
if (p.y < BOXSIZE) {
     oldcolor = currentcolor;
     if (p.x < BOXSIZE) { 
       currentcolor = ILI9341_RED; 
       tft.drawRect(0, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE);
       Serial.println("Box Used RED\n");
     } else if (p.x < BOXSIZE*2) {
       currentcolor = ILI9341_YELLOW;
       tft.drawRect(BOXSIZE, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE);
       Serial.println("Box Used YELLOW\n");
     } else if (p.x < BOXSIZE*3) {
       currentcolor = ILI9341_GREEN;
       tft.drawRect(BOXSIZE*2, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE);
       Serial.println("Box Used GREEN\n");
     } else if (p.x < BOXSIZE*4) {
       currentcolor = ILI9341_CYAN;
       tft.drawRect(BOXSIZE*3, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE);
       Serial.println("Box Used CYAN\n");
     } else if (p.x < BOXSIZE*5) {
       currentcolor = ILI9341_BLUE;
       tft.drawRect(BOXSIZE*4, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE);
       Serial.println("Box Used BLUE \n");
     } else if (p.x < BOXSIZE*6) {
       currentcolor = ILI9341_MAGENTA;
       tft.drawRect(BOXSIZE*5, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE);
       Serial.println("Box Used MAGENTA\n");
     }
 }
When the screen is untouched, i get the following console output
Touchpoints are: [unm. / map.] x-axis:[16379/-815] y-axis:[-260/-40]
Box Used RED
When i touch somewhere middle of the screen i get:
Touchpoints are: [unm. / map.] x-axis:[1800/130] y-axis:[2054/167]
Touchpoints are: [unm. / map.] x-axis:[1777/131] y-axis:[2053/167]
Touchpoints are: [unm. / map.] x-axis:[1808/129] y-axis:[2051/167]
Touchpoints are: [unm. / map.] x-axis:[1817/129] y-axis:[1998/162]]
And when i press and hold on the pink/magenta box i get:
Touchpoints are: [unm. / map.] x-axis:[392/221] y-axis:[337/12]
Box Used MAGENTA
but obviously, after relasing the finger, the touchscreen is returning to relaxed state, and says that the red box is used.
To check if the TFT Format is correct, i've printed out the tft parameters "tft.width()" and "tft.height()" and they are correctly 320x240px

Now i wonder how i can fix this issue? Any tips on this?

Also, think its rather inconvenient to have negative cordinates from the map function.

User avatar
adafruit_support_carter
 
Posts: 29056
Joined: Tue Nov 29, 2016 2:45 pm

Re: 2.4" 320x240 Touchscreen Issue

Post by adafruit_support_carter »

Seems odd that it is reporting a touch location when not touched.

Try also printing out the pressure/z value and see what you get when pressed/not pressed. It looks like the FeatherWing Touch Paint sketch does not check that value after getting the touch event:
https://github.com/adafruit/Adafruit_IL ... g.ino#L105

As a comparison, the PyPortal version has a simple threshold check for actual presses:
https://github.com/adafruit/Adafruit_IL ... al.ino#L64
and does nothing if "not pressed".

So this *might* be a bug.

User avatar
snx
 
Posts: 3
Joined: Mon Jul 26, 2021 3:18 pm

Re: 2.4" 320x240 Touchscreen Issue

Post by snx »

I have printed out the pressure

it is and stays exactly 31 when unpressed, and becomes 44-80, depending on press force when pressed

User avatar
adafruit_support_carter
 
Posts: 29056
Joined: Tue Nov 29, 2016 2:45 pm

Re: 2.4" 320x240 Touchscreen Issue

Post by adafruit_support_carter »

Seems like a cutoff would work then. But those touch values are also pretty low. Can you get them higher, like over 100, if you use something like the edge of fingernail instead of fingertip?

Locked
Please be positive and constructive with your questions and comments.

Return to “Feather - Adafruit's lightweight platform”