Saturday, April 21st 2018, 3:31pm UTC+2

You are not logged in.

  • Login
  • Register

Dear visitor, welcome to SEGGER Forum. If this is your first visit here, please read the Help. It explains how this page works. You must be registered before you can use all the page's features. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

hamzabrahmy

Beginner

Date of registration: Mar 16th 2018

Posts: 2

1

Friday, March 16th 2018, 10:34am

Attach data to graph

Hello,

I want to know how can I attach data received from analog sensor to a Real-Time graph using STM32F746G, I found some examples but they did not help me.

Any help? ?( ?(

thanks :)

SEGGER - Schoenen

Super Moderator

Date of registration: Aug 13th 2015

Posts: 561

2

Tuesday, March 20th 2018, 4:03pm

Hi,

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

C/C++ Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#include "DIALOG.h"
#include <stdlib.h>

/*********************************************************************
*
*   	Defines
*
**********************************************************************
*/
#define ID_WINDOW_0     	(GUI_ID_USER + 0x00)
#define ID_GRAPH_0     	(GUI_ID_USER + 0x01)

/*********************************************************************
*
*   	Static data
*
**********************************************************************
*/

/*********************************************************************
*
*   	_aDialogCreate
*/
static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
  { WINDOW_CreateIndirect, "Window", ID_WINDOW_0, 0, 0, 480, 272, 0, 0x0, 0 },
  { GRAPH_CreateIndirect, "Graph", ID_GRAPH_0, 20, 20, 440, 200, 0, 0x0, 0 },
};

/*********************************************************************
*
*   	Static code
*
**********************************************************************
*/
/*********************************************************************
*
*   	_GetADValue
*/
static I16 _GetADValue(void) {
  return (rand() % 100 + 1) + 50;
}

/*********************************************************************
*
*   	_cbDialog
*/
static void _cbDialog(WM_MESSAGE * pMsg) {
  static GRAPH_DATA_Handle hData;
  WM_HWIN              	hItem;
  I16                  	Value;

  switch (pMsg->MsgId) {
  case WM_INIT_DIALOG:
	hData = GRAPH_DATA_YT_Create(GUI_ORANGE, 440, NULL, 0);
	hItem = WM_GetDialogItem(pMsg->hWin, ID_GRAPH_0);
	GRAPH_AttachData(hItem, hData);
	WM_CreateTimer(pMsg->hWin, 0, 25, 0);
	break;
  case WM_TIMER:
	Value = _GetADValue();
	GRAPH_DATA_YT_AddValue(hData, Value);
	WM_RestartTimer((WM_HTIMER)pMsg->Data.v, 0);
	break;
  default:
	WM_DefaultProc(pMsg);
	break;
  }
}

/*********************************************************************
*
*   	Public code
*
**********************************************************************
*/
/*********************************************************************
*
*   	MainTask
*/
void MainTask(void) {
  GUI_Init();
  GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);
  while (1) {
	GUI_Delay(100);
  }
}

/*************************** End of file ****************************/


Regards
Svem

hamzabrahmy

Beginner

Date of registration: Mar 16th 2018

Posts: 2

3

Friday, March 23rd 2018, 10:08am

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/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 :)

This post has been edited 4 times, last edit by "hamzabrahmy" (Mar 23rd 2018, 10:10am)


Similar threads