|
本帖最后由 QQ373466062 于 2012-5-7 14:20 编辑
本想在Graph控件中画一个简单的曲线,想使用用GRAPH_DATA_YT_AddValue()函数来增加数据,可是写了后却是另一番效果
我猜想应该是没有设置GRAPH_DATA_YT_AddValue()之间的间隔吧,否则应该不会是竖线了??
那么有两个问题:
1. AddValue这个函数该如何使用才可以绘出连续的曲线而不是图中的竖线 ?
2. 在3.9.8版本的uCGUI中没有GRAPH_DATA_YT_MirrorX()函数?
没有这个函数我该如何才可以是曲线是从左到右绘制,而非默认的从右向左绘制呢?
代码张贴如下:
其中关键是:
GRAPH_DATA_YT_AddValue(hData,50);
for(a = 0; a< 100; a++)
{
GRAPH_DATA_YT_AddValue(hData,a + 10);
}
我该如何才可以绘制出一条简单的曲线呢?- #include "GUI.h"
- #include "GUIDEMO.h"
- #include "GRAPH.h"
- GRAPH_DATA_Handle hData;
- GRAPH_SCALE_Handle hScale;
- I16 m = 50;
- I16 *aData0 = &m;
- WM_HWIN hGraph;
- WM_HWIN hWM_HBKWIN;
-
-
- /*********************************************************************
- *
- * _cbBk
- */
- static void _cbBk(WM_MESSAGE * pMsg) {
- static unsigned int GirdFlag = 0;
- switch (pMsg->MsgId) {
- case WM_PAINT:
- // GUIDEMO_DrawBk(1);
- break;
- case WM_TOUCH:
- GirdFlag++;
- GRAPH_SetGridVis(hGraph,GirdFlag%3); //!< Display the if touch the screen
- break;
- default:
- WM_DefaultProc(pMsg);
- }
- }
- void MainTask(void) {
- int a = 0;
- GUI_Init();
-
- //!< Create a window as desktop
- hWM_HBKWIN =
- WM_CreateWindow(5,5,380,230,WM_CF_SHOW,0,0);
-
- // Set Callback function for background window
- WM_SetCallback(hWM_HBKWIN, _cbBk);
-
- WM_SetDesktopColor(GUI_BLUE); //!< SetDesktopColor
-
- //!< Create a graph widget
- hGraph = GRAPH_CreateEx(30, 15, 300, 200, hWM_HBKWIN, WM_CF_SHOW, 0, 100);
- //GRAPH_DATA_YT_MirrorX(hGraph , 1);
- //!< Create a YT_data
- hData = GRAPH_DATA_YT_Create(GUI_RED, 10, aData0, 10);
-
-
- GRAPH_DATA_YT_AddValue(hData,50);
-
- for(a = 0; a< 100; a++)
- {
- GRAPH_DATA_YT_AddValue(hData,a + 10);
- }
-
- hScale = GRAPH_SCALE_Create(28, GUI_TA_RIGHT, GRAPH_SCALE_CF_VERTICAL, 20);
- GRAPH_AttachScale(hGraph, hScale);
- GRAPH_SetGridDistX(hGraph,20);
- GRAPH_SetGridDistY(hGraph,20);
- GRAPH_SetGridVis(hGraph,1); //!< Display the Grid
-
- GRAPH_SetBorder(hGraph,30,5,5,5); //!< Set the frame border
-
- GRAPH_AttachData(hGraph, hData); //!< Attach the data to graph
- while(1) {
- // GUIDEMO_main();
- GUI_Exec();
- // OSTimeDlyHMSM(0,0,0,100);
- }
- }
复制代码 |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
阿莫论坛20周年了!感谢大家的支持与爱护!!
该献的血还是要献的。你不献他不献。难道让我去献? --- 出自坛友:lovejp1981
|