|
各位大神,最近在用emwin5.48的波形显示控件GRAPH时,波形无法显示,图形上显示像波浪的擦除动作,以为是波形颜色设置问题,更改多种颜色同样看不到波形,不知道哪个环节出了问题
贴出代码,请各位帮忙指点一二,感激不尽。
#include "DIALOG.h"
#include <stdlib.h>
/*********************************************************************
*
* Defines
*
**********************************************************************
*/
#define ID_FRAMEWIN_0 (GUI_ID_USER + 0x00)
#define ID_GRAPH_0 (GUI_ID_USER + 0x01)
#define ID_BUTTON_0 (GUI_ID_USER + 0x03)
// USER START (Optionally insert additional defines)
// USER END
/*********************************************************************
*
* Static data
*
**********************************************************************
*/
// USER START (Optionally insert additional static data)
// USER END
/*********************************************************************
*
* _aDialogCreate
*/
static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
{ FRAMEWIN_CreateIndirect, "Waveform", ID_FRAMEWIN_0, 0, 0, 480, 272, 0, 0x0, 0 },
{ GRAPH_CreateIndirect, "Graph", ID_GRAPH_0, 0, 0, 474, 254, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "close", ID_BUTTON_0, 431, 1, 40, 252, 0, 0x0, 0 },
// USER START (Optionally insert additional widgets)
// USER END
};
/*********************************************************************
*
* Static code
*
**********************************************************************
*/
// USER START (Optionally insert additional static code)
GRAPH_DATA_Handle Graphdata;
unsigned int pBuffer;
// USER END
/*********************************************************************
*
* _cbDialog
*/
static void _cbDialog(WM_MESSAGE * pMsg) {
WM_HWIN hItem;
GRAPH_SCALE_Handle hScaleV;
int NCode;
int Id;
int i = 0;
// USER START (Optionally insert additional variables)
// USER END
switch (pMsg->MsgId) {
case WM_INIT_DIALOG:
//
// Initialization of 'Graph'
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_GRAPH_0);
Graphdata = GRAPH_DATA_YT_Create(GUI_GREEN, 300, (const short*)&pBuffer, 1);
GRAPH_AttachData(hItem, Graphdata);
GRAPH_SetBorder(hItem, 0, 0, 40, 0);
GRAPH_SetColor(hItem, GUI_WHITE, GRAPH_CI_BK);
GRAPH_SetColor(hItem, GUI_ORANGE, GRAPH_CI_GRID);
GRAPH_SetGridDistX(hItem, 50);
GRAPH_SetGridDistY(hItem, 50);
GRAPH_SetLineStyleH(hItem, GUI_LS_DOT);
GRAPH_SetLineStyleV(hItem, GUI_LS_DOT);
GRAPH_SetGridVis(hItem, 3);
hScaleV = GRAPH_SCALE_Create(15, GUI_TA_HCENTER | GUI_TA_LEFT,
GRAPH_SCALE_CF_VERTICAL, 50);
GRAPH_AttachScale(hItem, hScaleV);
GRAPH_SCALE_SetFactor(hScaleV, 10);
// USER START (Optionally insert additional code for further widget initialization)
// USER END
break;
case WM_NOTIFY_PARENT:
Id = WM_GetId(pMsg->hWinSrc);
NCode = pMsg->Data.v;
switch(Id) {
case ID_BUTTON_0: // Notifications sent by 'close'
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
case WM_NOTIFICATION_RELEASED:
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
// USER START (Optionally insert additional code for further notification handling)
// USER END
}
break;
// USER START (Optionally insert additional code for further Ids)
// USER END
}
break;
case WM_PAINT:
GRAPH_DATA_YT_AddValue(Graphdata, pBuffer);
break;
// USER START (Optionally insert additional message handling)
// USER END
default:
WM_DefaultProc(pMsg);
break;
}
}
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* CreateWaveform
*/
WM_HWIN CreateWaveform(void);
WM_HWIN CreateWaveform(void) {
WM_HWIN hWin;
hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);
return hWin;
}
// USER START (Optionally insert additional public code)
void TaskMenuGraph(void)
{
static short int i = 300;
i ++;
if(i > 500) i = 300;
pBuffer = i;
GRAPH_DATA_YT_AddValue(Graphdata, rand()%100);
}
// USER END
|
|