初级会员
积分 77
金钱 77
注册时间 2013-5-10
在线时间 17 小时
10 金钱
请问,哪位知道,在只有底窗口没有窗口控件的情况下使用BUTTON, 我想在原子例程中的 “分段存储管理设备” 例子中增加一个带位图的按钮切换到别的窗口, 可是,如何在死循环中用按BUTTON? 这时没有什么回调函数啊,如何用?
#define USE_BANDING_MEMDEV (1) //定义使用分段存储
#define SIZE_OF_ARRAY(Array) (sizeof(Array) / sizeof(Array[0]))
#define BUTTON_ID_1 1
extern GUI_BITMAP bmJLEM; //绘制金龙LOGO 320x50
//多边形点坐标
static const GUI_POINT aPoints[] = {
{-50, 0},
{-10, 10},
{ 0, 50},
{ 10, 10},
{ 50, 0},
{ 10,-10},
{ 0,-50},
{-10,-10}
};
typedef struct
{
int XPos_Poly;
int YPos_Poly;
int XPos_Text;
int YPos_Text;
GUI_POINT aPointsDest[8];
float Speedvalue;
float Currentvalue;
} tDrawItContext;
static void _DrawIt(void * pData)
{
tDrawItContext * pDrawItContext = (tDrawItContext *)pData;
GUI_Clear();
// GUI_SetFont(&GUI_Font8x8);
// GUI_SetTextMode(GUI_TM_TRANS);
//绘制背景
GUI_SetColor(GUI_GREEN);
GUI_FillRect(pDrawItContext->XPos_Text,
pDrawItContext->YPos_Text - 25,
pDrawItContext->XPos_Text + 100, //这里的100是长条的长度
pDrawItContext->YPos_Text - 5);
//绘制多边形
GUI_SetColor(GUI_BLUE);
// GUI_FillPolygon(pDrawItContext->aPointsDest, SIZE_OF_ARRAY(aPoints), 120, 120);
GUI_FillPolygon(pDrawItContext->aPointsDest, SIZE_OF_ARRAY(aPoints), 160, 110); //旋转的中点
//绘制前景
GUI_SetColor(GUI_RED);
GUI_FillRect(220 - pDrawItContext->XPos_Text, //这里220是左右移动的长度
pDrawItContext->YPos_Text + 5,
220 - pDrawItContext->XPos_Text + 100, //这里的100是长条的长度 这里220是左右移动的长度
pDrawItContext->YPos_Text + 25);
//
}
//分段存储演示程序
void _DemoBandingMemdev(void)
{
BUTTON_Handle hButton;
tDrawItContext DrawItContext;
static int i, swap=0;
static int RefreshCounter1=0;
static int RefreshCounter2=0;
GUI_SetBkColor(GUI_BLACK);
GUI_Clear();
GUI_SetColor(GUI_YELLOW);
GUI_SetFont(&GUI_FontHZ24);
GUI_DispStringHCenterAt("金龙永磁电机控制", 160, 5);
GUI_SetFont(&GUI_Font16_ASCII);
GUI_DispStringHCenterAt("JLEM PM control system", 160, 28);
DrawItContext.XPos_Poly = 160; //160
DrawItContext.YPos_Poly = 120; //120
DrawItContext.YPos_Text = 116;
//GUI_DrawBitmap(&bmJLEM,0,190);//金龙LOGO
hButton = BUTTON_Create(0,190,320,50,GUI_ID_OK,WM_CF_SHOW);
BUTTON_SetBitmapEx(hButton, 0, &bmJLEM, 2, 4);
while (1)
{
/*******************************************动态屏*****************************************************/
float angle;
angle = i * 3.1415926 / 55;
DrawItContext.XPos_Text = (swap) ? i : 220 - i; //这里220是左右移动的长度
//旋转多边形
GUI_RotatePolygon(DrawItContext.aPointsDest, aPoints,
SIZE_OF_ARRAY(aPoints), angle);
i++;
if(i>220) //这里220是左右移动的长度
{
i=0;
swap = ~swap;
}
#if USE_BANDING_MEMDEV
{
GUI_RECT Rect = {0, 50, 320,167}; //动态范围窗口{0, 70, 240,170}
GUI_MEMDEV_Draw(&Rect,&_DrawIt,&DrawItContext,0,0);//使用分段存储绘制
}
#else
//如果没有开启分段存储的话就使用普通绘制方式
_DrawIt((void *)&DrawItContext);
#endif
/************************************************************************************************/
RefreshCounter1++;
if(RefreshCounter1>50) //每50毫秒执行一次
{
RefreshCounter1=0;
GUI_ClearRect(0, 168, 320, 188); //(50, 278, 205, 320)
GUI_SetColor(GUI_RED);
// GUI_SetFont(&GUI_Font32_ASCII);
GUI_SetFont(&GUI_Font24_ASCII);
GUI_DispStringHCenterAt("rpm",111,166);
GUI_DispStringHCenterAt("A",300,166);
GUI_SetColor(GUI_WHITE);
GUI_SetFont(&GUI_Font24_ASCII);
DrawItContext.Speedvalue++;
if(DrawItContext.Speedvalue>20000.0) DrawItContext.Speedvalue=0.0; //自加测试
GUI_GotoXY(10,166); //移动光标
GUI_DispFloatFix(DrawItContext.Speedvalue,7,1); //显示浮点数速度
DrawItContext.Currentvalue++;
if(DrawItContext.Currentvalue>40.0) DrawItContext.Currentvalue=0.0;
GUI_GotoXY(250,166); //移动光标
GUI_DispFloatFix(DrawItContext.Currentvalue,4,1); //显示浮点数速度
}
GUI_Delay(50);
//
}
}
请教请教,在这种请况下如何知道按键按下?
我来回答