cancel
Showing results for 
Search instead for 
Did you mean: 

Disable ticks in handleTickEvent() / Exit from handleTickEvent()

KNara.2
Associate III

Hi @Romain DIELEMAN  @Yoann KLEIN  @JTP1 @Mohammad MORADI ESFAHANIASL ...Please guide.....

 

 

 

I'm in the process of developing a screen which takes input from main board and the down timer keeps ticking. 

LED blinks until the progress bar fills.

The requirement for the LED is to blink when the progress bar is filling and become stable green once the down timer displays 0:00.

The calculation for the down timer is done inside handleTickEvent() and I get to know that the timer has reached 0:00 inside handleTickEvent() and this is how my code looks.

if (testDuration == 0) //To set LED intensity to stable green
{
      StableRGB(GREEN);
}
else if ((tickCounter % 30) == 0) //To set LED intensity to blinking green
 {

          if ((BlinkingGREEN() != HAL_OK))
         {
           //Report error
         }
}
Since the check, whether timer has reached 0:00 is done inside handleTickEvent(), stable LED looks a bit flickering.
I would like to exit from handleTickEvent() once the timer reaches 0:00...How can that be achieved?
Please suggest a solution for this.
1 ACCEPTED SOLUTION

Accepted Solutions

Hello @KNara.2 ,

You cannot use "Application::getInstance()->unregisterTimerWidget(this);" because it is used for registering and unregistering widgets not a View (or screen). So, you cannot stop receiving the tick and you have to change the logic of your code. 
A simple solution would be to have a flag next to to your testDuration so, when it is called once you won't pass the condition again. Like this:

if (testDuration == 0 && !greenLEDIsOn) //To set LED intensity to stable green
{
      StableRGB(GREEN);
      greenLEDIsON = true;
}
else if ((tickCounter % 30) == 0) //To set LED intensity to blinking green
 {

          if ((BlinkingGREEN() != HAL_OK))
         {
           //Report error
         }
}

I hope this helps, good luck

 

Mohammad MORADI
ST Software Developer | TouchGFX

View solution in original post

4 REPLIES 4
KNara.2
Associate III

In other words can somebody guide me how to stop the tick counter when the timer reaches 0:00.

I saw this post and tried adding this code in handleTickEvent()

https://community.st.com/t5/stm32-mcus-touch-gfx-and-gui/handletickevent-not-working-with-container/td-p/263835

  if (testDuration == 0) //To set LED intensity to stable green
  {
  StableRGB(GREEN);
 
  Application::getInstance()->unregisterTimerWidget(this);
  }

This is giving me compilation errors.

Can we stop the  receiving ticks every frame from handleTickEvent()?

Hello @KNara.2 ,

You cannot use "Application::getInstance()->unregisterTimerWidget(this);" because it is used for registering and unregistering widgets not a View (or screen). So, you cannot stop receiving the tick and you have to change the logic of your code. 
A simple solution would be to have a flag next to to your testDuration so, when it is called once you won't pass the condition again. Like this:

if (testDuration == 0 && !greenLEDIsOn) //To set LED intensity to stable green
{
      StableRGB(GREEN);
      greenLEDIsON = true;
}
else if ((tickCounter % 30) == 0) //To set LED intensity to blinking green
 {

          if ((BlinkingGREEN() != HAL_OK))
         {
           //Report error
         }
}

I hope this helps, good luck

 

Mohammad MORADI
ST Software Developer | TouchGFX

Thank you so much @Mohammad MORADI ESFAHANIASL that worked.

Glad to hear, you're very welcome 

Mohammad MORADI
ST Software Developer | TouchGFX