Loading GRAPH with an array of values

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

    • Loading GRAPH with an array of values

      Hello,
      I am using a GRAPH to display an FFT spectrum. So all Y/T values in the diagram need to be updated at least once in a second.
      The common method calling GRAPH_DATA_YT_AddValue in a loop for each horizontal pixel is too slow for updating the diagram within one second.
      Can I call the GRAPH_DATA_YT_Create function in a loop with my array of values as pData parameter to increase speed?


      Regards

      Jan
    • Hi Florian,
      this would be not enough in my case. I want to update my FFT at least once in a second. My display can show 750 frequency lines. That means I have to do 750 times GRAPH_DATA_YT_AddValue, correct? And this seems to be impossible within one second.
      I was hoping that GRAPH_DATA_YT_Create would allow the transfer of data arrays. What is the 'pData' parameter good for? In the manual it says "Pointer to data to be added to the object. The pointer should point to an array of I16 values". That sounds like whole arrays of data can be transferred at once.

      Or may be, I should just use 'draw line' commands instead of the GRAPH widget?
      Or, GUI_DrawGraph() might be even faster.

      Regards
      Jan

      The post was edited 1 time, last by JanBurg ().

    • Hi Jan,

      I suppose drawing the graph using GUI_DrawGraph() would be faster rather than constantly creating and deleting new widgets.

      Running this, I was able to draw several graphs per second, like 5-8 per second, depending on the delay.

      Source Code

      1. /*********************************************************************
      2. *
      3. * MainTask
      4. */
      5. void MainTask(void) {
      6. int Value;
      7. int i;
      8. I16 aData[750];
      9. //
      10. // Init GUI
      11. //
      12. GUI_Init();
      13. GUI_SetBkColor(GUI_BLACK);
      14. WM_MULTIBUF_Enable(1);
      15. while (1) {
      16. GUI_Delay(25);
      17. GUI_Clear();
      18. for(i = 0; i < 750; i++) {
      19. Value = rand() % 100;
      20. aData[i] = Value;
      21. }
      22. GUI_DrawGraph(aData, 750, 10, 50);
      23. }
      24. }
      Display All

      Best regards,

      Florian
    • Hi Florian,
      thank you for your support.
      I noticed that GUI_DrawGraph, which draws a polyline, is not the right function for drawing a set of spectral lines starting all at the X axis. I was able to get the desired result drawing each of the 750 vertical lines using GUI_DrawVLine. This happens in a user draw function and takes less than 1 second.


      Regards

      Jan