Plotting graphs

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

    • Hey Sven,

      I thank you for your reply, and also for the PID file. That is great!

      So, the codes work correctly as they are meant to : touch screen button works and so the graph. This will give a good starting point to rework on my project.

      Have a great day and with kind regards,

      Sue
    • Dear Sven,

      I have got one question while working on my project :
      #1. When I work with the array, how can I convert the type uint32_t to the type GUI_POINT ?
      I have been trying to resolve this issue, but fail so far.....

      I thank you in advance for your technical assistance and with my kind regards,

      Sue
    • Hi,

      there are two types of graph data. One is using points (the XY version) and the other one uses values (YT).

      Call GRAPH_DATA_XY_GetPoint() to get a point of the given index. If you added 3 points use an index of 1 to get the second point. The point values are getting stored where pPoint points to.

      If you want to get the data stored in a YT graph call GRAPH_DATA_YT_GetValue(). Although, this data object doesn't work with GUI_POINTs you can create your own:



      Source Code

      1. GUI_POINT Point;
      2. Point.x = 10;
      3. GRAPH_DATA_YT_GetValue(hData, &Point.y, Point.x);

      You can use the return value of GRAPH_DATA_YT_GetValue() to check if there is a value at the given index.


      Regards,

      Sven
    • Good morning Sven,

      I thank you very much for your quick and great reply : that helps me to move forward in my project.

      Further, I am going to implement this in my codes, and also to learn better the GUI chapter from your manual.
      Then, I will give you a feedback on how things work.....

      Have a nice day and with my kind regards,

      Sue
    • Good morning Sven,

      I managed to get your example code of WIDGET_GraphXY.c and learn from it about the GUI_POINT.
      This part interests me a lot :
      ...
      _aPoint[0].x = (int) (100 - r * cos(Rad));
      _aPoint[0][i].y = (int) (100 + r * sin(Rad) * Deg / 360);
      ....

      So, inspiring from the above codes, I have done something similar :
      ...
      _aI[i].x = (int) Axis_U_Array[i];
      _aI[i].y = (int) Axis_I_Array[i];
      ...

      However, I have experienced the following issue with those codes :
      #1. Putting the break point just after those codes, the Axis_U_Array[i] and Axis_I_Array[i] have got the correct values. However, the _aI[i].x and _aI[i].y registers have got null values.
      Do you know what is wrong with that operation ?
      #2. I have been trying to use the function GRAPH_DATA_XY_GetPoint() to put the measurement values (from an array) to GUI_POINT, but fail so far.
      May I ask you an example or a tip on how to do this ?

      I thank you in advance for your useful help and with my kind regards,

      Sue
    • Hey Sven,

      Learning from the WIDGET_GraphXY.c, I have managed to read and to display the measurement points. So, this is okay now.
      And I thank you for your technical support and help so far.

      Nowadays I have 2 questions regarding the graph display :
      #1. Plotting 2 graphs on the same display window, is it possible to have 2 different vertical Y axis sharing the same horizontal X axis ?
      The first Y axis for current measurements, and the second Y axis for power measurements.
      If this is possible, how could I do this ?
      #2. Is it possible to display a logo on the graph display window ? Do you have an example on how to do this ?

      I thank you in advance for your reply and have a nice day.

      With kind regards,

      Sue
    • Hi Sven,

      I thank you very much for your reply.

      #1. Yes, I have done this. I had thought that the 2nd scale could be more complicated to do....

      #2. I have been working on this function GRAPH_SetUserDraw() to implement the company logo.
      Indeed, the WIDGET_GraphXY.c example has got this function, so it helps to understand how it should be done.

      Have a nice day and with kind regards,

      Sue
    • Hey Sven,

      I hope that you have been going okay.... :)

      My project has been progressing finely, and I thank you very much for your technical support in resolving the problems. The STemWin is a great tool and I am pleased on how it works for the graphics application.
      So far, I have managed to display 2 graphs (Current and Power) as shown on the previous page, with some values and scales. Also, the WIDGET_GraphXY.c example has helped me a lot.

      However, I have been experiencing the following issue with the graph :
      #1. Using the "_OwnerDraw()" function and the "case WIDGET_ITEM_DRAW:" to display the circle (GUI_FillCircle), the circle is shown in around 2ms or less then disappears. This happens on the second graph.
      #2. On the first graph, I am able to display these points normally. But the points are not displayed / shown when their heights are near to 0.
      #3. Could I ask you how to resolve these problems ?

      Please feel free to say if you need further information about this (c file, for example).

      I thank you in advance and with kind regards,

      Sue
      Files
      • WindowDLG.txt

        (19.78 kB, downloaded 42 times, last: )
    • Hi Sue,


      The GRAPH widget has no owner draw function. Instead it has a user draw which works slightly different. It uses different commands (although it might work cause they use similar values).

      Just refer to the API description of GRAPH_SetUserDraw(). It makes use of the following commands:

      GRAPH_DRAW_FIRST
      GRAPH_DRAW_AFTER_BORDER
      GRAPH_DRAW_LAST

      A user draw func might look like this (pretty similar to a owner draw function):

      C Source Code

      1. /*********************************************************************
      2. *
      3. * _UserDraw
      4. */
      5. static void _UserDraw(WM_HWIN hWin, int Stage) {
      6. GUI_POINT Point;
      7. switch (Stage) {
      8. case GRAPH_DRAW_FIRST:
      9. GUI_DrawBitmap(&bmGradient_240x200, 40, 0);
      10. break;
      11. case GRAPH_DRAW_LAST:
      12. GUI_SetLineStyle(GUI_LS_DASH);
      13. if (GRAPH_DATA_XY_GetPoint(_hDataI, &Point, 1) == 0) {
      14. GUI_SetColor(GUI_BLUE);
      15. Point.x += BORDER_L;
      16. Point.y = 200 - (Point.y + BORDER_B);
      17. GUI_DrawLine(BORDER_L, Point.y, Point.x, Point.y);
      18. GUI_DrawLine(Point.x, Point.y, Point.x, 200 - BORDER_B);
      19. }
      20. GUI_SetColor(GUI_WHITE);
      21. GUI_FillCircle(Point.x, Point.y, 5);
      22. GUI_SetColor(GUI_BLUE);
      23. GUI_DrawCircle(Point.x, Point.y, 5);
      24. if (GRAPH_DATA_XY_GetPoint(_hDataP, &Point, 1) == 0) {
      25. GUI_SetColor(GUI_RED);
      26. Point.x += BORDER_L;
      27. Point.y = 200 - (Point.y + BORDER_B);
      28. GUI_DrawLine(BORDER_L, Point.y, Point.x, Point.y);
      29. GUI_DrawLine(Point.x, Point.y, Point.x, 200 - BORDER_B);
      30. }
      31. GUI_SetColor(GUI_WHITE);
      32. GUI_FillCircle(Point.x, Point.y, 5);
      33. GUI_SetColor(GUI_RED);
      34. GUI_DrawCircle(Point.x, Point.y, 5);
      35. break;
      36. }
      37. }
      Display All
      Also refer to the sample I have posted some time ago in this thread.

      Regards,
      Sven
    • Hi Sven,

      I thank you very much for your reply, and also for having put me in the right direction.
      Your technical support is really helpful and valuable to work with STemWin. :) :thumbsup:

      So, I am going to work on this for my project and will keep you informed on the results.

      Thanks a lot again and I wish you a nice day. :)

      With kind regards,

      Sue