cancel
Showing results for 
Search instead for 
Did you mean: 

Static Graph

sasmithadilshan
Associate II

I want to add custom wave forms like square, sine and etc, so how I could achieve this easily?

1 ACCEPTED SOLUTION

Accepted Solutions

Hello @sasmithadilshan ,

The form of your waves depends on the formulation you are using for adding data. In other words, there is no specific way to show a sine wave or a square one. You just need to calculate your values and then use the addDataPoint(value) function of either Dynamic graph or Static graph depending on your use case. 
For instance you can use create a sine wave like this:
 

#include <cmath>
...

void Screen1View::handleTickEvent()
{
    static float degree = 0.0;
    tickCounter++;

    if (tickCounter % 2 == 0)
    {
        float radian = (degree * 3.14159f) / 180.0f;
        dynamicGraph.addDataPoint((float)sin(radian));
        degree += 10;
    }
}

which results in:

Sine waveSine wave

 

Keep in mind that you need to configure the settings of the graph in the TouchGFX designer as well to make your graph look good. 

You can read more about the graphs here: Dynamic Graph  and Static Graph 

 

I hope this helps you

Mohammad MORADI
ST Software Developer | TouchGFX

View solution in original post

3 REPLIES 3

Hello @sasmithadilshan ,

The form of your waves depends on the formulation you are using for adding data. In other words, there is no specific way to show a sine wave or a square one. You just need to calculate your values and then use the addDataPoint(value) function of either Dynamic graph or Static graph depending on your use case. 
For instance you can use create a sine wave like this:
 

#include <cmath>
...

void Screen1View::handleTickEvent()
{
    static float degree = 0.0;
    tickCounter++;

    if (tickCounter % 2 == 0)
    {
        float radian = (degree * 3.14159f) / 180.0f;
        dynamicGraph.addDataPoint((float)sin(radian));
        degree += 10;
    }
}

which results in:

Sine waveSine wave

 

Keep in mind that you need to configure the settings of the graph in the TouchGFX designer as well to make your graph look good. 

You can read more about the graphs here: Dynamic Graph  and Static Graph 

 

I hope this helps you

Mohammad MORADI
ST Software Developer | TouchGFX

yeah, i already inserted the required graph using the static graph method I couldn't let you know,,, thank you for your information as well. i followed the same way that you have mentioned.

Glad to hear you resolved it :D

Mohammad MORADI
ST Software Developer | TouchGFX