Create and Display a Graph

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • Create and Display a Graph

    Hi,

    I am trying to display a graph on the right hand side of the screen. I have tried using GRAPH_CreateEx but I am basically getting a plain black box with some values on the side. I could really do with a good detailed example code that could help me understand how to configure it. Can someone please help me.
  • Hi,

    You have to create a data item and attach it to the graph. To update the graph simply add values to the item.

    Attached is an example which shows a simple graph with two data items (sine, cosine).

    Regards,
    Sven
    Files
    • SimpleGraph.zip

      (1.45 kB, downloaded 851 times, last: )
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • thanks for the example,
    Now do you have to use the messages/setting callback method.
    Can't you just set the graph in your main function and then add the values in the while loop or do you need the wm message/callbacks method to redraw the graph background.
  • Also I have tried implementing your example in my main function. But there no scales in the example. I have tried
    the following to add a scale and it adds values on the right and the bottom with no relation to the graph. Also I want an X and Y axis like the example pictures. How do I make it do this ?

    hScale = GRAPH_SCALE_Create(28, GUI_TA_RIGHT, GRAPH_SCALE_CF_VERTICAL, 10);
    GRAPH_AttachScale(hGraph, hScale);
    hScale = GRAPH_SCALE_Create(380, GUI_TA_BOTTOM, GRAPH_SCALE_CF_HORIZONTAL, 10);
    GRAPH_AttachScale(hGraph, hScale);