Skip to main content
Professional
Associate III
August 5, 2019
Question

draw a circle during 100ms on each touch screen press with touchGFX

  • August 5, 2019
  • 25 replies
  • 4533 views

Hello,

Do you know if there is a simple way to make touchGFX draw a circle during a few ms on each touch screen press ?

best regards

This topic has been closed for replies.

25 replies

Martin KJELDSEN
Principal III
August 5, 2019

Hi,

What do you mean by "during a few ms" ? Are you putting a requirement on the render effeciency of the circle or do you mean that it has to animate from 0 to 100% filled or something like that?

Thanks!

/Martin

Professional
Associate III
August 5, 2019

Hi,

no just print a circle for a few ms (just to tell the user the press has been detected)

Best regards

Martin KJELDSEN
Principal III
August 5, 2019

Ah, you mean show a circle for a few ms then hide it again?

Professional
Associate III
August 5, 2019

Yes

Martin KJELDSEN
Principal III
August 5, 2019

The simple thing to do is just to use MyView::handleClickEvent() to show the Circle at the pressed x,y and in the MyView::handleTickEvent() method just keep track of ticks and hide the circle once a certain amount of ticks have passed.

/Martin

Professional
Associate III
August 5, 2019

thanks a lot for the help,

now compilation is OK.

But

1) from my function handleClickEvent, how can i get the coordinates (i have to print the circle at the press position...) : call TS_GetState ?

2) i have to implement this functions for all my screens ?

best regards

Professional
Associate III
August 5, 2019

Hello

I can't make it work....!!!

here is my implementation :

void DigicodeView::handleClickEvent(const ClickEvent& evt)

{

 TS_StateTypeDef state;

 touchgfx::Circle circle1;

   touchgfx::PainterRGB888 circle1Painter;

    TS_GetState(&state);   

        if (state.touchDetected == 1)

        {

          circle1.setPosition(0, 0, 144, 80);

   circle1.setCenter(52, 41);

   circle1.setRadius(40);

   circle1.setLineWidth(4);

   circle1.setArc(0, 360);

   circle1.setCapPrecision(180);

   circle1Painter.setColor(touchgfx::Color::getColorFrom24BitRGB(199, 16, 16));

   circle1.setPainter(circle1Painter);

circle1.setVisible(true);

circle1.invalidate();

        }

}

best regards

Martin KJELDSEN
Principal III
August 6, 2019

Hi,

No, you don't have to call TS_GetState. This is already called in the TouchController implementation. Notice the arguments to handleClickEvent. You can get x and y from

evt.getX()
evt.getY()

/Martin

Professional
Associate III
August 6, 2019

Hello

thank you for your reply

I still can't make it work : the circle doesn't appear; do you have any idea why ?

In the setup screen i add a circle :

void DigicodeView::setupScreen()

{

   DigicodeViewBase::setupScreen();

  

   circle1.setPosition(0, 0, 480, 272);

   circle1.setCenter(x,y);

   circle1.setRadius(40);

   circle1.setLineWidth(4);

   circle1.setArc(0, 360);

   circle1.setCapPrecision(180);

   circle1Painter.setColor(touchgfx::Color::getColorFrom24BitRGB(199, 16, 16));

   circle1.setPainter(circle1Painter);

   add(circle1);

   circle1.setVisible(false);

   circle1.invalidate();

}

In the handleClickEvent i try to show the circle

void DigicodeView::handleClickEvent(const ClickEvent& evt)

{

  int16_t x = evt.getX();

  int16_t y = evt.getY();

   circle1.setPosition(0, 0, 480, 272);

   circle1.setCenter(52, 41);

   circle1.setRadius(40);

   circle1.setLineWidth(4);

   circle1.setArc(0, 360);

   circle1.setCapPrecision(180);

   circle1Painter.setColor(touchgfx::Color::getColorFrom24BitRGB(199, 16, 16));

   circle1.setPainter(circle1Painter);

   circle1.setVisible(true);

   circle1.invalidate();

}

best regards

Martin KJELDSEN
Principal III
August 6, 2019

Hi,

You need to add() the circle to the root container. Did you remember to do that? Just add all your circles in setupScreen() (even if they are invisible).

/Martin