Real time Graph

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

  • Real time Graph

    How to plot a graph using the XY Graph in emWin and vary the data dynamically, like the signal that is view in real time in an oscilloscope?I tried updating the graph later using Addpoint function but it works good only in the INIT_Dialog case not in other cases. So Kindly let me know how to draw a signal in Realtime using EMWIN graph.
  • Hi,

    Take a look into the sample attached. There I have created two graphs. One uses YT data and the other one uses XY data.

    Both are getting updated while running.

    Regards,
    Sven
    Files
    • GraphSample.zip

      (1.26 kB, downloaded 841 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.
  • Thank you Schoenen for your helpful code.

    It is grateful if you can help me about following issues:

    1. How I can use Title (Label) for horizontal axis? I use below code to create vertical axis title:

    static void _UserDraw(WM_HWIN hWin, int Stage) {
    if (Stage == GRAPH_DRAW_LAST) {
    char acText[] = "Temperature";
    GUI_RECT Rect, RectInvalid;
    int FontSizeY;
    GUI_SetFont(&GUI_Font13_ASCII);
    FontSizeY = GUI_GetFontSizeY();
    WM_GetInsideRect(&Rect);
    WM_GetInvalidRect(hWin, &RectInvalid);
    Rect.x1 = Rect.x0 + FontSizeY;
    GUI_SetColor(GUI_BLACK);
    GUI_DispStringInRectEx(acText, &Rect, GUI_TA_HCENTER, strlen(acText), GUI_ROTATE_CCW);
    }
    }

    static void _cbDialog(WM_MESSAGE * pMsg) {
    switch (pMsg->MsgId) {
    case WM_INIT_DIALOG:
    hItem = pMsg->hWin;
    WINDOW_SetBkColor(hItem, GUI_BLUE);
    hItem = WM_GetDialogItem(pMsg->hWin, ID_GRAPH_0);
    _hDataYT0 = GRAPH_DATA_YT_Create(GUI_RED, 300, NULL, 0);
    GRAPH_AttachData(hItem, _hDataYT0);
    GRAPH_SetGridVis(hItem, 1);

    GRAPH_SetUserDraw(hItem, _UserDraw);
    ......
    ......

    break;

    default:
    WM_DefaultProc(pMsg);
    break;
    }
    }

    2. How I can show a real time variable inside the graph widget area and/or outside of that (other areas of LCD)?

    Thank you in advance.