Hello everybody,
I have following problem:
I want to visualize ADC-Values as a Graph.
Every x ms a new value from the ADC is sampled and visualized.
The shown data is correct ---> So everything works fine.
But if I switch to another dialog and come back to the "graph screen" the values are gone. I think the whole dialog is newly created. But how can I manage that?
Logging data in the background and draw graph if the screen is created? Is there any possibility not to kill that dialog while another dialog is shown? (I tried to create all dialogs/windows once and call them by GUI_ExecCreatedDialog() but that does not work)
What do you think?
Image0 ---> after switching back
Image1 ---> while being on the screen
Code snippet of the "graph screen":
Display All
Example how the dialog is called:
Display All
Thank you very much!
I have following problem:
I want to visualize ADC-Values as a Graph.
Every x ms a new value from the ADC is sampled and visualized.
The shown data is correct ---> So everything works fine.
But if I switch to another dialog and come back to the "graph screen" the values are gone. I think the whole dialog is newly created. But how can I manage that?
Logging data in the background and draw graph if the screen is created? Is there any possibility not to kill that dialog while another dialog is shown? (I tried to create all dialogs/windows once and call them by GUI_ExecCreatedDialog() but that does not work)
What do you think?
Image0 ---> after switching back
Image1 ---> while being on the screen
Code snippet of the "graph screen":
C Source Code
- static void _cbScreen3(WM_MESSAGE * pMsg)
- {
- WM_HWIN hItem;
- int NCode,Id;
- static GRAPH_DATA_Handle hGraph1, hGraph2;
- int Value;
- static int Angle;
- static int Stop;
- static WM_HTIMER hTimer1;
- GRAPH_SCALE_Handle hScaley;
- GRAPH_SCALE_Handle hScalex;
- int NumItems;
- switch (pMsg->MsgId)
- {
- case WM_INIT_DIALOG:
- hItem = pMsg->hWin;
- WINDOW_SetBkColor(hItem, GUI_WHITE);
- hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_30);
- TEXT_SetTextAlign(hItem, TEXT_CF_LEFT);
- TEXT_SetTextColor(hItem, GUI_BLUE);
- TEXT_SetFont(hItem, GUI_FONT_24B_1);
- TEXT_SetText(hItem, "Graph");
- hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_BACK_MENU_3);
- BUTTON_SetText(hItem, "Menu");
- BUTTON_SetDefaultSkin(BUTTON_SKIN_FLEX);
- hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_SCREEN_3);
- BUTTON_SetText(hItem, "Screen 2 ");
- hItem = WM_GetDialogItem(pMsg->hWin, ID_GRAPH_0);
- WM_SetCallback(hItem, _cbGraph);
- GRAPH_SetGridVis(hItem, 1); //Gatter sichtbar?
- GRAPH_SetColor(hItem, GUI_WHITE,GRAPH_CI_BK);
- GRAPH_SetColor(hItem, GUI_GREEN,GRAPH_CI_GRID);
- hScaley =GRAPH_SCALE_Create(5,GUI_TA_VCENTER,GRAPH_SCALE_CF_VERTICAL,10);
- GRAPH_SCALE_SetPos(hScaley,1);
- GRAPH_SCALE_SetTextColor(hScaley,GUI_BLACK);
- GRAPH_SCALE_SetFactor(hScaley,0.1);
- GRAPH_SCALE_SetTickDist(hScaley,50);
- GRAPH_AttachScale(hItem,hScaley);
- hScalex = GRAPH_SCALE_Create(5,GUI_TA_HCENTER,GRAPH_SCALE_CF_HORIZONTAL,50); //Scala für die X-Achse
- GRAPH_SCALE_SetPos(hScalex,140);
- GRAPH_SCALE_SetTextColor(hScalex,GUI_BLACK);
- GRAPH_SCALE_SetFactor(hScalex,0.5);
- GRAPH_AttachScale(hItem,hScalex);
- NumItems = WM_GetWindowSizeX(hItem); //--> Anzahl der Items abhängig von der Größe des Widgets (x-Achse)
- // 2 Datenobjekte für Graphen
- hGraph1 = GRAPH_DATA_YT_Create(GUI_BLUE, NumItems, NULL, 0);
- GRAPH_AttachData(hItem, hGraph1);
- // GRAPH_AttachData(hItem, hGraph2);
- // alle x ms ein neues Wertepaar je Graph
- hTimer1 = WM_CreateTimer( pMsg->hWin, 1, TIMER_VALUE, 0);
- break;
- case WM_TIMER:
- if (Stop == 0)
- {
- WM_RestartTimer(hTimer1, 0);
- }
- if(Mode_Timer !=1)
- {
- }
- GRAPH_DATA_YT_AddValue(hGraph1, g_Voltage*10);
- break;
- case MESSAGE_STARTSTOP:
- Stop ^= 1;
- if (Stop == 0)
- {
- WM_RestartTimer(hTimer1, 0);
- }
- break;
- case WM_NOTIFY_PARENT:
- Id = WM_GetId(pMsg->hWinSrc);
- NCode = pMsg->Data.v;
- switch(Id)
- {
- case ID_BUTTON_SCREEN_3:
- switch(NCode)
- {
- case WM_NOTIFICATION_CLICKED:
- break;
- case WM_NOTIFICATION_RELEASED:
- WM_DeleteWindow(pMsg->hWin);
- GUI_CreateDialogBox(_aScreen2Create, GUI_COUNTOF(_aScreen2Create), _cbScreen2, WM_HBKWIN, 0, 0);
- break;
- }
- break;
- case ID_BUTTON_BACK_MENU_3:
- switch(NCode)
- {
- case WM_NOTIFICATION_RELEASED:
- WM_DeleteWindow(pMsg->hWin);
- GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);
- break;
- }
- break;
- case ID_BUTTON_3: // Notifications sent by 'Iconview'
- switch(NCode)
- {
- case WM_NOTIFICATION_RELEASED:
- hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_30);
- }
- }
- default:
- WM_DefaultProc(pMsg);
- break;
- }
- }
Example how the dialog is called:
C Source Code
Thank you very much!