34 views
in GUI Development by
It looks like the smooth ColorEffect animations are causing excess CPU usage on a low-performance embedded CPU.

Is there a way to reduce the frame rate to maybe 10, or 5 FPS?

1 Answer

+1 vote
by

Hello JamesCavalier,

all animation effects are driven by a common timer. To reduce the frame rate, the configuration of this timer needs to be changed. The mentioned timer exists in the unit Effect of the Mosaic framework. As the Mosaic is not allowed to be modified, the configuration of the timer can't be changed directly. You can however do following:

Step 1: Search in the Browser window for the project member representing the mentioned timer. The member is an autoobject (a global object) named Effects:Effect:Timer as shown in the screenshot below. Use the filter function of the Browser window to find the member easily:

Step 2: In Composer switch to a unit belonging to your project, e.g. some Application unit.

Step 3: Press and hold down the keys CTRL+SHIFT+ALT. While pressing the keys drag & drop the member found in step 1 to the Composer window as shown below:

This operation overrides the original EffectTimer member by a variant. Note the small (v) in the icon of the resulting brick. See also Create autoobject variant.

Step 4: Select the just created variant. In Inspector appear its properties.

Step 5: Look in Inspector for the property Period. The original value of this property is 15. It means 15 milliseconds or max. ~66 FPS.

Step 6: Change the value. For example, to limit the animations to 5 FPS, change the value to 200.

As mentioned above, the timer drives all animation effects. Consequently, the here described modification will have a global effect on all animations used in your project. If this is not desired, you will need to implement the lower FPS animations using a separate Timer. Following could be the steps:

Step 1: Add a Timer object to you component.

Step 2: Configure the desired timing behaviour of the timer. For example property Period = 200.

Step 3: Activate the timer by setting its property Enabled = true.

Step 4: Add a new variable to the component. Name it e.g. progress.

Step 5: Configure the type of the variable to be int32.

Step 6: Add a slot method to the component.

Step 7: Assign the slot method to Timer's OnTrigger property.

Step 8: Implement the method with following code:

// Count the timer expirations
progress++;

In this manner the timer updates the variable progress. What is missing is the calculation to interpolate between two key values (e.g. colors) according to the value of progress. If you are using Embedded Wizard 13, you can use the built-in functions math_mix(), for example:

// Count the timer expirations
progress++;

// Interpolate between black and white colors
SomeView.Color = math_mix( #000000FF, #FFFFFFFF, float( progress % 10 ) / 10.0 );

I hope it helps you further.

Best regards

Paul Banach

Ask Embedded Wizard

Welcome to the question and answer site for Embedded Wizard users and UI developers.

Ask your question and receive answers from the Embedded Wizard support team or from other members of the community!

Embedded Wizard Website | Privacy Policy | Imprint

...