微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > ucos II+ucGUI+s3c2410+LCD+触摸屏整合

ucos II+ucGUI+s3c2410+LCD+触摸屏整合

时间:10-08 来源:互联网 点击:

int LCD_L0_Init(void) {

return LCD2410_Init();//调用lcd初始化函数

}

5、某些编译器(如:ads1.2)不会初始化全局变量,因此做如下事:

1) 修改如下函数为:(位于GUICore.c)

static void _InitContext(GUI_CONTEXT* pContext) {

memset(pContext,0,sizeof(GUI_CONTEXT));//add

#if GUI_SUPPORT_MEMDEV

GUI_SelectLCD();

#else

LCD_SetClipRectMax();//LCD_L0_GetRect

#endif

pContext->pLCD_HL = LCD_HL_APIList;

pContext->pAFont = GUI_DEFAULT_FONT;

pContext->pClipRect_HL = GUI_Context.ClipRect;

pContext->PenSize = 1;

pContext->DrawMode = GUI_DRAWMODE_NORMAL;//add

pContext->TextMode = GUI_TEXTMODE_NORMAL;//add

pContext->TextAlign = GUI_TA_LEFT|GUI_TA_TOP;//add

pContext->AA_HiResEnable = 0;//add

/* Variables in WM module */

#if GUI_WINSUPPORT

pContext->hAWin = WM_GetDesktopWindow();

#endif

/* Variables in GUI_AA module */

pContext->AA_Factor = 3;

LCD_SetBkColor(GUI_DEFAULT_BKCOLOR);

LCD_SetColor(GUI_DEFAULT_COLOR);

}

修改如下函数为:(位于GUIAlloc.c)

void GUI_ALLOC_Init(void) {

........

GUI_ALLOC.NumUsedBytes = 0;

memset(aBlock,0,sizeof(aBlock[0])*GUI_MAXBLOCKS);/////self

aBlock[0].Size = (1

.......

}

修改如下函数为:(位于WM.c)(DDDDDDDDDDNew)

void WM_Init(void) {

if (!_IsInited) {

……….

memset(_ClipContext,0,sizeof(WM_IVR_CONTEXT));//add

NextDrawWin = WM__FirstWin = WM_HWIN_NULL;

……………….

_IsInited =1;

}

}

2)自己编写如下函数(ads1.2):

void MyInit()

{

IsInitialized = 0;//MemDev

_IsInited = 0;//Win

WM__CreateFlags = 0;

GUI_CURSOR_pfTempHide = NULL;

GUI_Context.hDevData = 0;

WM__hCapture=0;

WM__hWinFocus=0;

WM_pfPollPID = 0;

WM_pfHandlePID = 0;

GUI_pfTimerExec = 0;

_KeyMsgCnt = 0;

}

该函数应在GUI_Init()调用之前调用。

6、改写GUI_Init()函数:

int GUI_Init(void) {

int r;

GUI_DEBUG_LOG(\nGUI_Init());

/* Init system wide globals first */

GUI_DecChar = '.';

/* Init context */

_InitContext(GUI_Context);

GUITASK_INIT();

r = LCD_Init();

#if GUI_WINSUPPORT

WM_Init();

#endif

GUITASK_COPY_CONTEXT();

GUI_Clear();

GUI_X_Init();

GUI_CURSOR_Show();//启动即显示鼠标

return r;

}

三、ucGUI与ucOS的整合,主要修改GUI_X.c文件:

1、定义信号量及全局量:

static OS_EVENT *DispSem;

static OS_EVENT *EventMbox;

static OS_EVENT *KeySem;

static int KeyPressed;

static char KeyIsInited;

2、实现结合函数:

int GUI_X_GetTime(void)

{

return ((int)OSTimeGet());

}

void GUI_X_Delay(int period)

{

INT32U ticks;

ticks = (period * 1000) / OS_TICKS_PER_SEC;

OSTimeDly((INT16U)ticks);

}

void GUI_X_Unlock(void)

{

OSSemPost(DispSem);

}

void GUI_X_Lock(void)

{

U8 err;

OSSemPend(DispSem, 0, err);

}

U32 GUI_X_GetTaskId(void)

{

return ((U32)(OSTCBCur->OSTCBPrio));

}

void GUI_X_WaitEvent (void)

{

INT8U err;

(void)OSMboxPend(EventMbox, 0, err);

}

void GUI_X_SignalEvent (void)

{

(void)OSMboxPost(EventMbox, (void *)1);

}

void GUI_X_InitOS(void)

{

DispSem = OSSemCreate(1);

EventMbox = OSMboxCreate((void *)0);

}

void GUI_X_ExecIdle(void) {GUI_X_Delay(1);}

void GUI_X_Init(void) {

SetTSInterrupt();//此处接入触摸屏的中断设置

GUI_TOUCH_SetDefaultCalibration();//用默认值校准触摸屏

}

四、与触摸屏有关的函数:

1、4个功能函数:

void GUI_TOUCH_X_ActivateX(void) {//空}

void GUI_TOUCH_X_ActivateY(void) {//空}

int GUI_TOUCH_X_MeasureX(void) {

return TX;//返回触摸坐标x

}

int GUI_TOUCH_X_MeasureY(void){

return TY; //返回触摸坐标y

}

2、触摸屏校准任务(进程, 来自示例程序:TOUCH_Calibrate.c):

#if TOUCH_NEED_CALIBRATE

static const char * _acPos[] = {

(upper left position),

(lower right position)

};

static void _WaitForPressedState(int Pressed) {

GUI_PID_STATE State;

/* Wait until touch is pressed */

do {

GUI_TOUCH_GetState(State);

if (State.Pressed == Pressed) {

break;

}

GUI_Delay (100);

} while (1);

}

static void _DispStringCentered(const char * pString) {

GUI_RECT Rect;

Rect.x0 = Re

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top