BRT Community

Please login or register.

Login with username, password and session length
Advanced search  

News:

Welcome to the Bridgetek Community!

Please read our Welcome Note

Technical Support enquires
please contact the team
@ Bridgetek Support

Please refer to our website for detailed information on all our products - Bridgetek - Bridging Technology

Author Topic: Touch Returns Incorrect Tag/Track Value  (Read 200 times)

dpardo

  • Newbie
  • *
  • Posts: 8
    • View Profile
Touch Returns Incorrect Tag/Track Value
« on: July 22, 2022, 05:19:19 PM »

I am working on a project with a display with a BT817.  I've been working on getting touch functionality implemented, but I keep finding that objects will return the wrong tag. 

I first noticed this when I had two buttons, one with tag 30 and another with tag 31.  Pressing either button would return the tag 31, so I figured that somehow the 30 tag was being overwritten.  However, after changing that button to tag 10, it returned 15 instead.

So to get a sense of how the expected tag mapped to the received one, I held my finger on a button, and in a while loop incremented the button tag and printed out the results.  The pattern I got was seemingly random, with some values shown below:

Sent TagReceived Tag
11
23
33
46
57
67
77
812
913
1015
1115
1214
1315
1415
1515
...and so on.

The only values where the expected tag matched the actual tag are 0, 1, 3, 7, 15, 31, 63, 127, and 255.  In other words, when all bits below the most significant 1 are also 1.

After converting these values to binary, I eventually noticed a pattern: every bit I received was the result of an OR operation with the expected bit and the next highest bit.  So bit0 = bit0 | bit1, bit1 = bit1 | bit2, etc.

I've noticed this pattern with tags for touch objects, as well as the return value for any track object I draw.  Aside from leaving me with only a few valid tags, this means any slider/dial/scrollbar objects are extremely glitchy, as they are being redrawn with  the same values I saw appearing for the tags.

Can anyone help me understand why this is happening?  I'm glad I found the pattern but I don't understand where it's coming from or how to fix it.
Logged

BRT Community

  • Administrator
  • Hero Member
  • *****
  • Posts: 586
    • View Profile
Re: Touch Returns Incorrect Tag/Track Value
« Reply #1 on: July 22, 2022, 05:41:39 PM »

Hi,

Could you post a code snippet showing an example of your co-processor list which draws a couple of buttons and tags them etc.

Best Regards. BRT Community
Logged

dpardo

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Touch Returns Incorrect Tag/Track Value
« Reply #2 on: July 22, 2022, 08:23:52 PM »

Sure, here's some of the code I've been using on my MCU:

To draw two buttons:
Code: [Select]
//Draw first button with tag = 30
Send_CMD(TAG(30));
cmd_button(Display_Width()/4-40, Display_Height()*3/4-40, 80, 80, 30, OPT_FLAT, "30");

//Draw second button with tag = 31
Send_CMD(TAG(31));
cmd_button(Display_Width()*3/4-40, Display_Height()*3/4-40, 80, 80, 30, OPT_FLAT, "31");

To take the value from a slider object and display it as a number:
Code: [Select]
  start_display_list(128,128,128);
  uint32_t tracker = rd32(RAM_REG + REG_TRACKER);
  val = tracker >> 16;
Send_CMD(TAG(31));
cmd_slider(0, Display_Height()/2, Display_Width(), Display_Height()/12, OPT_FLAT, val, 31);
cmd_track(0, Display_Height()/2, Display_Width(), Display_Height()/12, 31);
cmd_number(Display_Width()/2, Display_Height()/4 + 50, 30, OPT_CENTER, val);
finish_display_list();
HAL_Delay(30);

The Send_CMD function:
Code: [Select]
void Send_CMD(uint32_t data)
{
  wr32(FifoWriteLocation + RAM_CMD, data);                         // write the command at the globally tracked "write pointer" for the FIFO

  FifoWriteLocation += FT_CMD_SIZE;                                // Increment the Write Address by the size of a command - which we just sent
  FifoWriteLocation %= FT_CMD_FIFO_SIZE;                           // Wrap the address to the FIFO space
}

So far the Send_CMD, cmd_xxxx functions have been working perfectly fine for drawing and registering touches, it's just the tag/tracker values are messed up like I've described.
Logged

BRT Community

  • Administrator
  • Hero Member
  • *****
  • Posts: 586
    • View Profile
Re: Touch Returns Incorrect Tag/Track Value
« Reply #3 on: July 25, 2022, 02:34:18 PM »

Hi,

Thanks for your code,

We will have a look at your code but here is a small button and slider example which you could also try to see if it runs well. It displays a slider which you can slide up and down and also a button. When you press the button, a red dot appears and the button is given a non-3D 'pressed in' appearance.

Best Regards, BRT Community



Code: [Select]
void eve_display(void)
{
    uint32_t TrackerVal = 0;
    uint8_t TagVal = 0;
    uint16_t SlideVal = 0;
    uint16_t Button3D = 0;
    uint8_t color = 0;

    while(1)
    {
        EVE_LIB_BeginCoProList();                                               // Begin new screen
        EVE_CMD_DLSTART();                                                      // Tell co-processor to create new Display List

        EVE_CLEAR_COLOR_RGB(0, 0, 0);                                           // Specify color to clear screen to
        EVE_CLEAR(1,1,1);                                                       // Clear color, stencil, and tag buffer

        EVE_TAG_MASK(1);                                                        // Enable tagging

        EVE_TAG(2);                                                             // Tag following items with tag 2
        EVE_CMD_FGCOLOR(0x0000FF);                                              // Blue foreground color
        EVE_CMD_BUTTON(100, 200, 150, 60, 27, Button3D, "Button");               // Draw button

        EVE_TAG(5);                                                             // Tag following items with tag 5
        EVE_CMD_SLIDER(300, 100, 16, 200, 0, SlideVal, 255);                    // Draw a slider
        EVE_CMD_TRACK(300, 100, 16, 200, 5);                                    // Place a tracker

        EVE_TAG_MASK(0);                                                        // Mask tagging so that following items won't be tagged

        EVE_BEGIN(EVE_BEGIN_POINTS);                                                    // Draw a dot in red at 140, 100)
        EVE_POINT_SIZE(30*16);
        EVE_COLOR_RGB(color, 0, 0);                                             // Set colour to blue and write some text
        EVE_VERTEX2F((140*16), (100*16));
        EVE_END();

        EVE_DISPLAY();                                                          // Tell EVE that this is end of list
        EVE_CMD_SWAP();                                                         // Swap buffers in EVE to make this list active

        EVE_LIB_EndCoProList();                                                 // Finish the co-processor list burst write
        EVE_LIB_AwaitCoProEmpty();                                              // Wait until co-processor has consumed all commands

        // ------ read tag and tracker values --------
        TagVal = HAL_MemRead8(EVE_REG_TOUCH_TAG);                                   // Get Tag value
        TrackerVal = HAL_MemRead32(EVE_REG_TRACKER);                                // Read the value of the tag and track register

        if(TagVal == 2)
        {// If button pushed tag register will read 2
            color = 0xFF;                                                       // change red amount to 255
            Button3D = 256;                                                     // Give the button a pushed-in appearance
        }
        else
        {// Otherwise...
            color = 0x00;                                                       // change red amount to 0 so dot is not visible
            Button3D = 0;                                                       // Button has 3D effect (not pushed in))
        }

        if(TagVal == 5)                                                         // if slider touched...
        {
            SlideVal = (TrackerVal >> 24);                                      // ... then get the tracker value.
            // Note: Value of tracking is 16 bits but we only use upper 8 bits since the slider is set for 8 bit resolution
        }

        //APP_SnapShot2PPM();                                                   // Un-comment to take snapshot (see BRT_AN_014)

        // Result of button press and slider value will be displayed next time round
    }
}





void eve_example(void)
{
    // Initialise the display
    EVE_Init();

    // Calibrate the display
    eve_calibrate();

    // Start example code
    eve_display();
}
Logged

dpardo

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Touch Returns Incorrect Tag/Track Value
« Reply #4 on: July 25, 2022, 03:55:37 PM »

Hello, would you mind including eve_calibrate as well?  I can't seem to find it in the EVE-MCU-BRT_AN_025 library.
Logged

BRT Community

  • Administrator
  • Hero Member
  • *****
  • Posts: 586
    • View Profile
Re: Touch Returns Incorrect Tag/Track Value
« Reply #5 on: July 25, 2022, 05:33:15 PM »

Hi,

You can find the files in this repository (this is the one for FT900 MCU but the other MCU platforms covered by this BRT_AN_025 code are also in the Bridgetek repository)

https://github.com/Bridgetek/EVE-MCU-BRT_AN_025-Example-FT900

Please see eve_calibrate.c here https://github.com/Bridgetek/EVE-MCU-BRT_AN_025-Example-FT900/tree/main/example

and for the calibrate command definition itself you can get this here: https://github.com/Bridgetek/EVE-MCU-BRT_AN_025-Example-FT900/tree/main/lib/eve/source

The BRT_AN_025 for some MCUs (including FT900) stores the values but if you want to run calibration manually you can just use this list in your calibrate function.

      EVE_LIB_BeginCoProList();
      EVE_CMD_DLSTART();
      EVE_CLEAR_COLOR_RGB(0, 0, 0);
      EVE_CLEAR(1,1,1);
      EVE_COLOR_RGB(255, 255, 255);
      EVE_CMD_TEXT(EVE_DISP_WIDTH/2, EVE_DISP_HEIGHT/2,
            28, EVE_OPT_CENTERX | EVE_OPT_CENTERY,"Please tap on the dots");
      EVE_CMD_CALIBRATE(0);
      EVE_LIB_EndCoProList();
      EVE_LIB_AwaitCoProEmpty();

Best Regards, BRT Community
Logged

dpardo

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Touch Returns Incorrect Tag/Track Value
« Reply #6 on: July 25, 2022, 06:36:00 PM »

Hi, I added the provided eve_calibrate to my project but when I tap on the third dot, it stops flashing and the example screen never shows.  If I comment out the call to calibrate, the example screen shows but no touches are registered.  The calibrate screen registers touches however.

For context, I am using an STM32F446RE processor, and I have been able to have touches register without a calibration routine with my previous code.  I based my project on Matrix Orbital's example:
https://github.com/MatrixOrbital/EVE-Basic-Demo-STM32
Logged

BRT Community

  • Administrator
  • Hero Member
  • *****
  • Posts: 586
    • View Profile
Re: Touch Returns Incorrect Tag/Track Value
« Reply #7 on: July 25, 2022, 08:24:31 PM »

Hi,

Could you advise which EVE module part # you have and which capacitive touch controller is used on it?

You may be able to also use the same sequence of commands and register reads as the button and slider code which we posted, on the Matrix Orbital code.

Calibration may not be essential if the CTP resolution matches that of the screen (but in any case should work well with BT817 and so would be good to find out why it hangs).

Best Regards,  BRT Community
Logged

dpardo

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Touch Returns Incorrect Tag/Track Value
« Reply #8 on: July 25, 2022, 08:42:28 PM »

I am using a CFAF800480E1-050SR-A2 (resistive) display with a BT817 EVE4 processor.  I've also now ported one of my previous demo functions to the new project with the BRT_AN_025 library but can't get it to run continuously.  For example, when I put this simple screen-clearing code in a while(1) and run/debug, the loop will run all the way through once and then get stuck. 

However, with my old project, this was never an issue.  I'm sure it would be good to solve this secondary issue, but my main priority is getting rid of the tag errors I discussed earlier.  Would I be able to send my code to the support team and have them take a look at it?

Edit: Upon further debugging with the old project, I've determined that my functions used to write/read work fine.  I've been reading various register values then printing them back to the display using cmd_number, and they match the defaults as specified in the user guide.  The only registers where the results are incorrect are REG_TOUCH_TAG and REG_TRACKER.  Is there any other register or setting that would affect how those register values behave?
« Last Edit: July 26, 2022, 02:46:51 PM by dpardo »
Logged

BRT Community

  • Administrator
  • Hero Member
  • *****
  • Posts: 586
    • View Profile
Re: Touch Returns Incorrect Tag/Track Value
« Reply #9 on: July 26, 2022, 03:02:00 PM »

Hi,

Yes, you can email us at support.emea@brtchip.com if you would like us to have a look at your code,

Best Regards, BRT Community
Logged

dpardo

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Touch Returns Incorrect Tag/Track Value
« Reply #10 on: July 26, 2022, 03:55:51 PM »

Got it working!  Turns out my MCU's SPI clock was a little too fast for the display to handle.  I didn't even think to try slowing it down because my writes and everything were working.  I was reading more register values, such as REG_ID, and noticed those were actually following the same pattern as the tags.  In hindsight it seems like the problem was caused by the display not being able to drive the data line low as fast as my MCU wanted.
Logged

Rudolph

  • Sr. Member
  • ****
  • Posts: 296
    • View Profile
Re: Touch Returns Incorrect Tag/Track Value
« Reply #11 on: July 26, 2022, 05:59:55 PM »

I posted this yesterday and somehow it got lost.
I asked about your SPI clock and if you tried to lower it.

I am seeing this with my hardware as well, in the last test I conducted I got to 17MHz before touch stopped working
but could use 40MHz just fine for the writes.

What does your hardware up to the FFC connector look like?
I am using one of these https://github.com/RudolphRiedel/EVE_display-adapter/tree/master/L-D5019-08
And this one may work a bit higher for the reads.

My guess is that the turnaround-delay is getting too high between the clock-signal and MISO, especially with glue-logic in between.
Logged

dpardo

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Touch Returns Incorrect Tag/Track Value
« Reply #12 on: July 29, 2022, 02:18:14 PM »

I'm using a Nucleo-F446RE board with some jumper wires connecting to a FFC breakout board:
https://www.amazon.com/uxcell-Converter-Couple-Extend-Adapter/dp/B07RWNFKCR

I imagine this one isn't super premium, but yeah I lowered my sclk from 24MHz to 12MHz and that did the trick.  Your guess makes sense though.
Logged