Attach data to graph

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

    • Hi,

      Try the code below. Each 25ms I create a random value and add it to the graph data.

      C Source Code

      1. #include "DIALOG.h"
      2. #include <stdlib.h>
      3. /*********************************************************************
      4. *
      5. * Defines
      6. *
      7. **********************************************************************
      8. */
      9. #define ID_WINDOW_0 (GUI_ID_USER + 0x00)
      10. #define ID_GRAPH_0 (GUI_ID_USER + 0x01)
      11. /*********************************************************************
      12. *
      13. * Static data
      14. *
      15. **********************************************************************
      16. */
      17. /*********************************************************************
      18. *
      19. * _aDialogCreate
      20. */
      21. static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
      22. { WINDOW_CreateIndirect, "Window", ID_WINDOW_0, 0, 0, 480, 272, 0, 0x0, 0 },
      23. { GRAPH_CreateIndirect, "Graph", ID_GRAPH_0, 20, 20, 440, 200, 0, 0x0, 0 },
      24. };
      25. /*********************************************************************
      26. *
      27. * Static code
      28. *
      29. **********************************************************************
      30. */
      31. /*********************************************************************
      32. *
      33. * _GetADValue
      34. */
      35. static I16 _GetADValue(void) {
      36. return (rand() % 100 + 1) + 50;
      37. }
      38. /*********************************************************************
      39. *
      40. * _cbDialog
      41. */
      42. static void _cbDialog(WM_MESSAGE * pMsg) {
      43. static GRAPH_DATA_Handle hData;
      44. WM_HWIN hItem;
      45. I16 Value;
      46. switch (pMsg->MsgId) {
      47. case WM_INIT_DIALOG:
      48. hData = GRAPH_DATA_YT_Create(GUI_ORANGE, 440, NULL, 0);
      49. hItem = WM_GetDialogItem(pMsg->hWin, ID_GRAPH_0);
      50. GRAPH_AttachData(hItem, hData);
      51. WM_CreateTimer(pMsg->hWin, 0, 25, 0);
      52. break;
      53. case WM_TIMER:
      54. Value = _GetADValue();
      55. GRAPH_DATA_YT_AddValue(hData, Value);
      56. WM_RestartTimer((WM_HTIMER)pMsg->Data.v, 0);
      57. break;
      58. default:
      59. WM_DefaultProc(pMsg);
      60. break;
      61. }
      62. }
      63. /*********************************************************************
      64. *
      65. * Public code
      66. *
      67. **********************************************************************
      68. */
      69. /*********************************************************************
      70. *
      71. * MainTask
      72. */
      73. void MainTask(void) {
      74. GUI_Init();
      75. GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);
      76. while (1) {
      77. GUI_Delay(100);
      78. }
      79. }
      80. /*************************** End of file ****************************/
      Display All


      Regards
      Svem
    • Hi,
      Thank you for yor answer it so was so useful ,
      after creation of the graph I would like to make hScaleH dynamic as a Time Scale

      C Source Code

      1. hGra=GRAPH_CreateEx(10,60,260,190,hWin,WM_CF_SHOW,0,0);hScaleV = GRAPH_SCALE_Create(20, GUI_TA_RIGHT, GRAPH_SCALE_CF_VERTICAL, 25); hScaleH = GRAPH_SCALE_Create(10, GUI_TA_TOP, GRAPH_SCALE_CF_HORIZONTAL, 50); GRAPH_AttachScale(hGra, hScaleV);GRAPH_AttachScale(hGra, hScaleH);



      Thanks :)

      The post was edited 4 times, last by hamzabrahmy ().