cancel
Showing results for 
Search instead for 
Did you mean: 

How can I make my custom containers to update with specific frequency?

RMoli.3
Associate III

I have a complex GUI that has many custom containers displaying information. This information shall be updated at specific perios to avoid confusing the end user.

For example the voltage shall be updated every second while the frequency shall be updated every 200ms

Currently my custom containers have the following code which updates the values every 16ms and depends on the refresh rate of the screen.

void MyCustomContainer::initialize() {
    MyCustomContainer::initialize();
    /* Register tick functions */
    Application::getInstance()->registerTimerWidget(this);
}
 
void MyCustomContainer::handleTickEvent(void) {
    /* ... get value () */
    /*... update text gui() */
}

I could add to every widged something in the lines of (pseudo code):

void MyCustomContainer::handleTickEvent(void) {
   static uint8_t counter = 0;
   if (counter >= SOME_VALUE {
       /* ... get value () */
       /*... update text gui() */
      counter =0;
   } else {
    counter ++;
   }
}

...or make the parent widget in charge of handling the update of the child custom containers. Both solution seem do not look the right path to go as:

  • In the first case a change in the refresh rate would have an impact on when the GUI update values
  • In the second scenario each parent container needs to call the child containers with the correct periodicity.

Does touchGFX support registering the containers to configurable period calls? Am I missing something?

1 ACCEPTED SOLUTION

Accepted Solutions
RMoli.3
Associate III

This has been solved as of touchgfx 4.21.3 as there is the trigger event that can trigger a custom container ever N ticks

View solution in original post

3 REPLIES 3
MM..1
Chief II

Seems you miss. Your idea waste graphics power ,

In normal situation exist two ways

  1. Event based = real value is changed = screen is updated on next tick ... here is used multitasking RTOS queues MVP
  2. Screen or model ticks handles updates as you show based on counters.
//get new value used in gui task tick only if is time efficient otherwise require other task
newVal = maincodestruct.voltage;
if(showed.voltage != newVal)
{
container.updatemethod(newVal);
}

In container registered tick is effective only for animate container.

RMoli.3
Associate III

@MM..1​ My GUI basically shows sensor data. Each container shows different types of sensors and may be reused between multiple screens. The sensor data can be retrieved fast with getter function (no calculation necessary). The issue is that the sensor data is updated at a different rate that rate at which it needs to be displayed. For example:

  • RPM sensor values are updated every 20 ms but the GUI sensor information needs to be updated every 200ms
  • Temperature sensor values updated every 100ms but the GUI sensor information needs to be updated every 1000ms

What I want to avoid is that each view having to know which is the desired update rate of each type of container and calling it according to its rate.

But the fact that each container shall have its own tick event that can only be dependent on the refresh rate of the screen and not on a "time" seems a completely waste of uC power.

RMoli.3
Associate III

This has been solved as of touchgfx 4.21.3 as there is the trigger event that can trigger a custom container ever N ticks