BRT Community

General Category => Discussion - EVE => Topic started by: obones on September 14, 2021, 02:52:36 PM

Title: Tracking is shifted to the top
Post by: obones on September 14, 2021, 02:52:36 PM
Hello,

I'm trying to use the CMD_TRACK method with a slider and started with this command list for a BT817 chip:

Code: [Select]
CLEAR_COLOR_RGB(255,255,255)
CLEAR(1, 1, 1)
VERTEX_FORMAT(0)
LINE_WIDTH(80)

CMD_TRACK(20, 30, 100, 10, 26)

COLOR_RGB(255, 170, 0)
CMD_FGCOLOR(0x999999)
CMD_BGCOLOR(0xDDDDDD)
TAG(26);
CMD_SLIDER(20, 30, 100, 10, OPT_FLAT, 45, 100)

This draws a nice looking slider but trying to "track" it I can only get REG_TRACKER to update if I place my finder above the slider bar itself. To illustrate, I added a blue and a green rectangle to give this display:
(http://obones.free.fr/track_slider.png)

The blue rectangle is the slider itself, but I have to place my finger in the green rectangle to get any tracking effect.
At first, I thought that the calibration was not done properly, but the buttons with a tag get detected properly when pressed at their location, not above.

So to go further, I decided to change the value for y0 in the CMD_TRACK command, thinking there maybe was a need for an offset. As it did not have an effect, I went even further and created this display list:

Code: [Select]
CLEAR_COLOR_RGB(255,255,255)
CLEAR(1, 1, 1)
VERTEX_FORMAT(0)

LINE_WIDTH(80)

BEGIN (RECTS)
COLOR_RGB(255, 0, 0)
VERTEX2F(20, 200)
VERTEX2F(120, 240);
END;

BEGIN (RECTS)
COLOR_RGB(0, 0, 255)
VERTEX2F(20, 30)
VERTEX2F(120, 40)
END

BEGIN(RECTS)
COLOR_RGB(0, 180, 0)
VERTEX2F(20, 10)
VERTEX2F(120, 20)
END

CMD_TRACK(20, 200, 100, 40, 26)

COLOR_RGB(255, 170, 0)
CMD_FGCOLOR(0x999999)
CMD_BGCOLOR(0xDDDDDD)
TAG(26);
CMD_SLIDER(20, 30, 100, 10, OPT_FLAT, 45, 100)

This gives this display:
(http://obones.free.fr/track_slider_below.png)

The red rectangle represents the area given to CMD_TRACK which you can see is clearly outside the slider. But it does not have any effect on the "hot zone" that is still inside the green rectangle.
I tried replacing the slider with a simple rectangle, it shows the same behavior.

What have I missed? Is there some special option to have the tracker consider the middle of the slider and not something above it?

For now, I have made a workaround by tracking a transparent rectangle placed below the slider itself, but it's really strange to have to resort to this.
Title: Re: Tracking is shifted to the top
Post by: TFTLCDCyg on September 14, 2021, 08:56:10 PM
Two questions:

Did you calibrate the touch panel on your FT817?
Where do you store the 25 data of the touch calibration vector?
Title: Re: Tracking is shifted to the top
Post by: BRT Community on September 15, 2021, 03:03:18 PM
Hi,

We tried this code below from one of our samples on the BT817 and the touch was aligned on the slider correctly, you could try this to see if it works,

Do you have any other code in your display list which may also be affecting the tracking area?
Also, do you use any screen rotation etc.

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, 80, 30, 27, Button3D, "Button");               // Draw button
       
        EVE_TAG(5);                                                             // Tag following items with tag 5
        EVE_CMD_SLIDER(300, 100, 200, 30, 0, SlideVal, 255);                    // Draw a slider
        EVE_CMD_TRACK(300, 100, 200, 30, 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
        }
               
       
        // Result of button press and slider value will be displayed next time round
    }
}
   
Title: Re: Tracking is shifted to the top
Post by: obones on September 17, 2021, 12:47:25 PM
Ok, I went back to a "blank" display list, and the more I place the slider to the top right, the more the tracking gets shifted.

So I reran the calibration routine, this time taking the time to place myself right in front of the screen and taking the time to tap precisely.
And sure enough, now that I am using those 6 new values (A to F), there is no longer a shift at the top right location.

In the end, the error was on my side but it was very hard to track down because it was only occurring in a corner of the screen.
I'll now make sure I always calibrate properly.
Title: Re: Tracking is shifted to the top
Post by: BRT Community on September 17, 2021, 05:20:46 PM
Hi,

Glad to hear that you have resolved it,

You can store the calibration values in your MCU's Flash/EEPROM by running a calibration and once successfully completed, store the six REG_TOUCH_TRANSFORM values in your MCU and then re-write them back on each start-up.

It is worth including a way to force a re-calibration too when doing this (via a button on the screen, or by holding a touch on power-up, or by a physical button on your PCB if you prefer not to have an on-screen way of triggering it)

Best Regards, BRT Community