uc gui如何动态显示一根曲线
答案:3 悬赏:0 手机版
解决时间 2021-02-04 22:02
- 提问者网友:疯子也有疯子的情调
- 2021-02-04 02:43
uc gui如何动态显示一根曲线
最佳答案
- 五星知识达人网友:妄饮晩冬酒
- 2021-02-04 03:35
代码张贴如下:
其中关键是:
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;
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);
}
}
其中关键是:
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;
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);
}
}
全部回答
- 1楼网友:北方的南先生
- 2021-02-04 05:34
GRAPH_DATA_YT_AddValue(hData,50);
for(a = 0; a< 100; a++)
{
GRAPH_DATA_YT_AddValue(hData,a + 10);
- 2楼网友:由着我着迷
- 2021-02-04 05:08
你好!
GRAPH_DATA_YT_AddValue(hData,50);
for(a = 0; a< 100; a++)
{
GRAPH_DATA_YT_AddValue(hData,a + 10);
仅代表个人观点,不喜勿喷,谢谢。
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯