BRT Community

General Category => Discussion - EVE => Topic started by: MPW691 on April 21, 2022, 03:35:57 PM

Title: Touch register intermittently gets correct values
Post by: MPW691 on April 21, 2022, 03:35:57 PM
Hi all,

I am using the FT811 chip with an LCD screen, and have set the size of the screen and other parameters. When I press on a button, it triggers an interrupt as expected, and within the function I read the tag register and press position on the screen:
Code: [Select]
void ft811_new_interrupt() {
uint8_t press_mask = ft_read8(FT_REG_INT_MASK);
uint8_t press_tag = ft_read8(FT_REG_CTOUCH_TAG);
uint32_t tag_xy    = ft_read32(FT_REG_TOUCH_TAG_XY);
uint32_t press_xy = ft_read32(FT_REG_CTOUCH_TOUCH0_XY);
uint8_t int_flags = ft_read8(FT_REG_INT_FLAGS);

Sometimes, when I press the button, I get the expected response, that looks like:

Code: [Select]
TAG:0x06
TagXY:0x023C0160
PressXY0:0x023C0160
MASK:0x06
FLAGS:0xA7

However sometimes, I press on the button, and get this:
Code: [Select]
TAG:0x0
TagXY:0x80008000
PressXY0:0x80008000
MASK:0x06
FLAGS:0xAF

But I don't understand why its intermittent. Its not a different type of press, every press generates an interrupt correctly and I am reading the values directly (and in this case immediately printing them), so why are the tag and press registers empty? Is there a setting I need to change to get this to be more reliable?

Any help would be greatly appreciated!
Title: Re: Touch register intermittently gets correct values
Post by: BRT Community on April 22, 2022, 04:41:13 PM
Hello,

My first suggestion is to try running a touch calibration to see if that improves the reliability. To run the calibration, please create a display list and include CMD_CALIBRATE. The procedure collects three touches from the screen, then computes and loads an appropriate matrix into REG_TOUCH_TRANSFORM_A-F.

Out of interest, what size is the button used on your display? With smaller buttons there may be more instances where the touch is being detected just outside the button.

Best regards, BRT Community
Title: Re: Touch register intermittently gets correct values
Post by: Rudolph on April 22, 2022, 05:41:57 PM
A value of 0x06 in REG_INT_MASK means interrupts on touch-detected and tag value change.
While helpfull in this case, reading REG_INT_MASK is not required every time.

The tag value is 0x0, so no object is touched.
The value of 0x80008000 in both REG_TOUCH_TAG_XY and REG_CTOUCH_TOUCH0_XY means untouched.
The interrupt flags set indicate in addition to the other flags that both a touch was detected and the tag value changed.

Well, the interrupt might have been delayed so the event already passed when the registers are read.
Or the screen is not detecting events reliably.
Or the touch events are bouncing with this screen.
This is an issue I would have a closer look at with my logic analyzer.

Which display is this and what controller are you using at what SPI clock?

And why are you using an interrupt to detect touch events?
I could argue against using an interrupt but I really would like to know what your reasons are.
Title: Re: Touch register intermittently gets correct values
Post by: MPW691 on April 25, 2022, 09:41:56 AM
Hello,

Thank you for the suggestion, but unfortunately it doesn't seem to have helped. ON the Resistive Engines (FT810 etc) there are registers for settle, charge, RZThreshold etc which affect when a press is detected, is there anything similar for the Capacitive engines (Ft811)? I can't see anything in the manual so I'm assuming not...

Thanks.
Title: Re: Touch register intermittently gets correct values
Post by: MPW691 on May 03, 2022, 09:41:04 AM
Hi all,

Issue has been resolved now, thanks for the info @Rudolf! This pointed me in the right direction!
Well, the interrupt might have been delayed so the event already passed when the registers are read.


It looks like something (can't work out what) was causing the Tag and Touch registers to be cleared if I did not read the value quick enough, so I ensured that the interrupt triggered a section of code to immediately read the registers and store them (was previously setting a flag and then dealing with it when available) and that resolved the issue.

Thanks for the help, this is a great community that always seems to have the answers!
Title: Re: Touch register intermittently gets correct values
Post by: BRT Community on May 05, 2022, 11:53:09 AM
Hello,

We are pleased to hear that it is working well after Rudolphs advice,

Yes, please note that the register values for the tag and the coordinates will be updated to reflect the current touch status even after the interrupt has triggered and so it is important to read the values as soon as possible after the interrupt. If there is a delay, the touch conditions may have changed (for example the user may have moved their finger or lifted it off the screen) and so you may see newer values compared to those which triggered the interrupt.

Best Regards, BRT Community