Devo12 with improved touch screen

  • rbe2012
  • rbe2012's Avatar Topic Author
  • Offline
  • So much to do, so little time...
More
24 Aug 2013 12:38 - 27 Aug 2013 16:09 #13208 by rbe2012
Devo12 with improved touch screen was created by rbe2012
I have improved the touch screen behavior for Devo12 (and Devo8; uses the same code but there were no issues reported afaik).
The new method reads the coordinates three times, calculates the middle point, discards the coordinate with the highest distance to the middle point and returns the middle between the two remaining coordinates. It is a simple implementation, but it might eliminate coordinated which are far away.
I have tested the code on my Devo12 and my Devo8 and had no issues. I can use the touch screen from my Devo12 with my finger nails and it is quite exact.
I would like to know if there is a real improvement. I did not have great issues with the touch screen before so I am not sure if it is really better now or if I only believe it might be...
So if you are brave, install the appended dfus and tell me if you see an improvement.
The build includes some bugfixes I have implemented for the actual nightly build (PBs last version from Aug. 12). If you want to look what else has been changed: bitbucket: rbe2012-bugfixing

EDIT:
New version with activated MAV mode, untested!

File Attachment:

File Name: devo12-MAV...sted.zip
File Size:518 KB
Attachments:
Last edit: 27 Aug 2013 16:09 by rbe2012.

Please Log in or Create an account to join the conversation.

  • rbe2012
  • rbe2012's Avatar Topic Author
  • Offline
  • So much to do, so little time...
More
24 Aug 2013 12:44 #13209 by rbe2012
Replied by rbe2012 on topic Devo12 with improved touch screen
I have not committed the changes to my repo because I am not sure if it is a good change. To whom who is interested here the code:
struct touch SPITouch_GetCoords()
{
    #define TOUCH_READS 3
    struct touch res, data[TOUCH_READS];
    u32 center_x = 0, center_y = 0;
    CS_LO();
    // read TOUCH_READS times from the touchpad and store the values
    for (int i=0; i<TOUCH_READS; i++) {
        #if _TOUCH_COORDS_REVERSE
            /* X and Y are swapped on Devo8 */
            /* and X is reversed */
            data[i].x = 255 - read_channel(READ_Y);
            data[i].y = read_channel(READ_X);
        #else
            data[i].x = 255 - read_channel(READ_X);
            data[i].y = read_channel(READ_Y);
        #endif
        // TODO: is it necessary to read all values? Must they also be calculated (or: are they used somewhere? AFAIK only in tx_configure.c for display testing)?
        data[i].z1 = read_channel(READ_Z1);
        data[i].z2 = read_channel(READ_Z2);
        // add values to calculate center of measuring points
        center_x += data[i].x;
        center_y += data[i].y;
    }
    CS_HI();
    #if TOUCH_READS > 1
        // divide by number of measurements to correct the range
        center_x /= TOUCH_READS;
        center_y /= TOUCH_READS;
        // search for the data point with the greatest distance to the calculated center
        u32 dist = 0, max_dist = 0;
        int index_max_dist = 0;
        for (int i=0; i<TOUCH_READS; i++) {
            dist = ((center_x - data[i].x) * (center_x - data[i].x) + (center_y - data[i].y) * (center_y - data[i].y));
            // rather dist^2, but 'dist > 0' and 'a > b ==> a^2 > b^2' this will suffice to search the outlier
            if (dist > max_dist) {
                max_dist = dist;
                index_max_dist = i;
            }
        }
        // reset this data point
        data[index_max_dist].x = 0;
        data[index_max_dist].y = 0;
        // recalculate the center
        center_x = 0;
        center_y = 0;
        for (int i=0; i<TOUCH_READS; i++) {
            center_x += data[i].x;
            center_y += data[i].y;
        }
        // divide by number of measurements -1 (!, one data point discarded) to correct the range and store
        res.x = center_x / (TOUCH_READS - 1);
        res.y = center_y / (TOUCH_READS - 1);
    #else
        res.x = data[0].x;
        res_y = data[0].y;
    #endif
    res.x = res.x * Transmitter.touch.xscale / 0x10000 + Transmitter.touch.xoffset;
    if(res.x & 0x8000)
        res.x = 0;
    res.y = res.y * Transmitter.touch.yscale / 0x10000 + Transmitter.touch.yoffset;
    if(res.y & 0x8000)
        res.y = 0;
    return res;
}

Please Log in or Create an account to join the conversation.

More
24 Aug 2013 16:51 #13220 by PhracturedBlue
Replied by PhracturedBlue on topic Devo12 with improved touch screen
Sorry, real life has been taking all of my free time lately, and I still haven't had time to look into the problem in depth.

The big question is what the frequency of noise is.
I'm not sure you can sample 3 points that closely together and get good results.

I was goingto start by building a test firmware that wold sample the touch sensor as fast as possible to try to determine the frequency of the noise. Then to sample at a 1msec rate and then take the median of 'n' samples (where we'd need to determine a good value for 'n'). Since we never need to draw on the screen, we don't need super-fast response for moving the pen, but we need good accuracy for it.
I started plumbing this into the timer, but was unable to finish before I got busy again.

If your simple solution works (implying very high frequency noise), then it is much simpler than what I was going to do.

Please Log in or Create an account to join the conversation.

More
24 Aug 2013 17:48 #13231 by FDR
Replied by FDR on topic Devo12 with improved touch screen

PhracturedBlue wrote: ...
Since we never need to draw on the screen, we don't need super-fast response for moving the pen, but we need good accuracy for it.
...

Actually I still would like to draw my curves, and it would be great too if I could drag and drop the main form's controls quickly... ;)

Please Log in or Create an account to join the conversation.

More
26 Aug 2013 15:25 #13311 by Pattaya01
Replied by Pattaya01 on topic Devo12 with improved touch screen
I will surely try and feedback... :cheer:

Please Log in or Create an account to join the conversation.

More
26 Aug 2013 15:40 #13314 by vlad_vy
Replied by vlad_vy on topic Devo12 with improved touch screen
It works much better now, but there is a minor errors, generally when I press the screen at the left or below of any control, with about 1.5mm distance. If I press the screen at the right or from above of any control, it never happens.

Please Log in or Create an account to join the conversation.

  • rbe2012
  • rbe2012's Avatar Topic Author
  • Offline
  • So much to do, so little time...
More
26 Aug 2013 16:46 #13317 by rbe2012
Replied by rbe2012 on topic Devo12 with improved touch screen

vlad_vy wrote: It works much better now, but there is a minor errors, generally when I press the screen at the left or below of any control, with about 1.5mm distance. If I press the screen at the right or from above of any control, it never happens.

Did you recalibrate your touch screen?

Please Log in or Create an account to join the conversation.

More
26 Aug 2013 16:54 #13318 by vlad_vy
Replied by vlad_vy on topic Devo12 with improved touch screen
Several times, no great changes.

Please Log in or Create an account to join the conversation.

  • rbe2012
  • rbe2012's Avatar Topic Author
  • Offline
  • So much to do, so little time...
More
27 Aug 2013 12:33 - 27 Aug 2013 12:37 #13336 by rbe2012
Replied by rbe2012 on topic Devo12 with improved touch screen
I have done some reading in the spi touch controller datasheet as referenced for Devo8 in the articles. I assume the Devo12 has the same controller.
There is a mode called MAV (median value filter and averaging filter) which is actually not used. This does what I have implemented: it measures 7 values and throws the two highest and the to lowest away and takes the average (this costs the time for 7 measurements but should not matter).
I looked into the code. There is no real difference between the command mode and the data mode, but the lower 4 bits have different meanings in command mode. This is why the MAV mode is disabled.
An other test could be to use the differential mode (contrary to single ending mode which is actually used). This does not need a voltage reference and might be more independent from variations of the supply voltage, but needs more power.
I will make some testing in the evening if this MAV mode works and if so, I will update the dfu files for further testing.
Last edit: 27 Aug 2013 12:37 by rbe2012.

Please Log in or Create an account to join the conversation.

  • rbe2012
  • rbe2012's Avatar Topic Author
  • Offline
  • So much to do, so little time...
More
27 Aug 2013 17:36 #13338 by rbe2012
Replied by rbe2012 on topic Devo12 with improved touch screen
The MAV version works, but again I don't see much improvements.
I have no more time today; maybe more tomorrow.

Please Log in or Create an account to join the conversation.

More
28 Aug 2013 00:01 #13342 by Pattaya01
Replied by Pattaya01 on topic Devo12 with improved touch screen
I don't know if this is of any use:

1)

The original Devention SW works fundamentally different from Deveation. A command is executed on releasing the stylus, not on pressing. So I guess they just keep on reading for as long as the screen is touched, probably hundreds of readings.

2)

I was electronic hardware engineer before and we also had to de-bounce switches. The procedure was:

- Do nothing for a few miliseconds (for sure is bouncing)
- Read and compare to previous reading
- Having at least XX same readings after each other, debouncing is done

Don't know if this is of any help to you, but better share to much than to little.

Please Log in or Create an account to join the conversation.

  • rbe2012
  • rbe2012's Avatar Topic Author
  • Offline
  • So much to do, so little time...
More
28 Aug 2013 06:26 #13349 by rbe2012
Replied by rbe2012 on topic Devo12 with improved touch screen
You are right, we need all info we can get.

Pattaya01 wrote: The original Devention SW works fundamentally different from Deveation. A command is executed on releasing the stylus, not on pressing. So I guess they just keep on reading for as long as the screen is touched, probably hundreds of readings.

This will take us the "repeat press" ability which is often used when you press an arrow for longer time (e.g. positioning a screen element). If we only check the position when releasing we can get only one press event (maybe we could difference between short and long presses).

- Do nothing for a few miliseconds (for sure is bouncing)
- Read and compare to previous reading
- Having at least XX same readings after each other, debouncing is done

If we would compare different readings we would have to introduce a range to allow slight movements (depends on the accuracy of the chip). I have no idea how stable the values are if the stick is not moved. I believe it might be even worse it not using the stick but the finger (nail) where pressure could change (in time, over the pressing area) and with this the value read.
Your last point could cost many time (again depending on the accuracy) for reading a single coordinate - not sure if we have it or if we would have to do this asynchronously and implement a buffer for the readings, what could make things more difficult.

What vlad has told is quite interesting: the values read are shifted in a special direction (have to look: to -X/-Y or +X/+Y). If we know this we could also eliminate values which are in this direction and keep those closer to the wanted point. Can anybody confirm this?

BTW: I have a protection foil on the screen. Has anybody tested if it makes things better or worse or just doesn't change anything? I don't remember a significant change, but I changed the original foil to one for an iPad and never used the screen without. If I will run out of ideas I will remove mine to see...

Please Log in or Create an account to join the conversation.

More
28 Aug 2013 06:55 - 28 Aug 2013 06:59 #13350 by vlad_vy
Replied by vlad_vy on topic Devo12 with improved touch screen
Before patch I've tested, the values read generally were shifted to the right and down, but not to the left and down.

I have not any protection foil on the screen.
Last edit: 28 Aug 2013 06:59 by vlad_vy.

Please Log in or Create an account to join the conversation.

More
28 Aug 2013 10:39 #13351 by vlad_vy
Replied by vlad_vy on topic Devo12 with improved touch screen
First patch is much better than version with activated MAV mode. With accurate calibration it almost perfect.

Do you see small artifact at right edge of screen, after pages with scroll bar? It seems that backgroung BMP shifted one pixel to the left.

Please Log in or Create an account to join the conversation.

  • rbe2012
  • rbe2012's Avatar Topic Author
  • Offline
  • So much to do, so little time...
More
28 Aug 2013 14:24 #13355 by rbe2012
Replied by rbe2012 on topic Devo12 with improved touch screen
Vlad, you have written above

vlad_vy wrote: It works much better now, but there is a minor errors, generally when I press the screen at the left or below of any control, with about 1.5mm distance. If I press the screen at the right or from above of any control, it never happens.

Is there a "white" area at the top and right of an element where a touch is not registered? Or: is the sensitive area bigger than it should be or slightly shifted?

I don't have my tx here and will look later at the background.

Please Log in or Create an account to join the conversation.

More
28 Aug 2013 15:15 - 28 Aug 2013 15:24 #13356 by vlad_vy
Replied by vlad_vy on topic Devo12 with improved touch screen
After several attempts I get perfect calibration, without any sensitive area shifts. The only zone with errors is right side of the screen (1.5-2cm), where all sensitive areas extended to the right, up to 2mm (timers page). I.e. pressed left side of 'right arrow' = OK, pressed 2mm to the right from 'right arrow' = also pressed.
Last edit: 28 Aug 2013 15:24 by vlad_vy.

Please Log in or Create an account to join the conversation.

  • rbe2012
  • rbe2012's Avatar Topic Author
  • Offline
  • So much to do, so little time...
More
28 Aug 2013 15:37 - 28 Aug 2013 16:26 #13358 by rbe2012
Replied by rbe2012 on topic Devo12 with improved touch screen
You have written

After several attempts I get perfect calibration...

Do you mean you recalibrated the touch screen several times?

Sounds like good news. If the behavior you have seen can be confirmed for more Devo12 we might be able to correct the values in this area.
Possibly we could extend the calibration screen with more points so we can make a base calibration with coordinates a little away from the right edge and combine this with some readings from the right.
I will try to add some points to the calibration screen (e.g. diagonal from upper left to lower right) and see if any two points result in the same calibration parameters or if somewhere is a recognizable difference.
Last edit: 28 Aug 2013 16:26 by rbe2012.

Please Log in or Create an account to join the conversation.

More
29 Aug 2013 00:45 #13362 by Pattaya01
Replied by Pattaya01 on topic Devo12 with improved touch screen
If the calibration uses the same routine, logically there may be deviations in the points during calibration as well. So it might be necessary to use another routine for calibration to have a higher accuracy for the points touched during calibration.

Please Log in or Create an account to join the conversation.

More
29 Aug 2013 02:13 - 29 Aug 2013 02:14 #13363 by Pattaya01
Replied by Pattaya01 on topic Devo12 with improved touch screen
This morning I had time to play with the files you posted. They are dated 27 Aug, I hope they are the most recent ones.

I have tried to get an error, couldn't get !!!!!!

Seems you are on the right track. As far as I am concerned, this solves the problem. Congrats.....

I am also using screen protector.
Last edit: 29 Aug 2013 02:14 by Pattaya01.

Please Log in or Create an account to join the conversation.

More
29 Aug 2013 02:16 #13364 by Pattaya01
Replied by Pattaya01 on topic Devo12 with improved touch screen

rbe2012 wrote: I will try to add some points to the calibration screen (e.g. diagonal from upper left to lower right) and see if any two points result in the same calibration parameters or if somewhere is a recognizable difference.


Why not like most devices: all 4 corners and the center..

Please Log in or Create an account to join the conversation.

Time to create page: 0.067 seconds
Powered by Kunena Forum