cancel
Showing results for 
Search instead for 
Did you mean: 

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

Professional
Senior

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

25 REPLIES 25
Martin KJELDSEN
Chief III

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
Senior

Hi,

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

Best regards

Martin KJELDSEN
Chief III

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

Professional
Senior

Yes

Martin KJELDSEN
Chief III

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
Senior

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
Senior

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
Chief III

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
Senior

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