新聞中心

EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > ucos II+ucGUI+s3c2410+LCD+觸摸屏整合

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

作者: 時(shí)間:2016-10-08 來(lái)源:網(wǎng)絡(luò) 收藏

#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);

}

修改如下函數(shù)為:(位于GUIAlloc.c)

void GUI_ALLOC_Init(void) {

........

GUI_ALLOC.NumUsedBytes = 0;

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

aBlock[0].Size = (1

.......

}

修改如下函數(shù)為:(位于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)自己編寫如下函數(shù)(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;

}

該函數(shù)應(yīng)在GUI_Init()調(diào)用之前調(diào)用。

6、改寫GUI_Init()函數(shù):

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();//啟動(dòng)即顯示鼠標(biāo)

return r;

}

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

1、定義信號(hào)量及全局量:

static OS_EVENT *DispSem;

static OS_EVENT *EventMbox;

static OS_EVENT *KeySem;

static int KeyPressed;

static char KeyIsInited;

2、實(shí)現(xiàn)結(jié)合函數(shù):

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();//此處接入觸摸屏的中斷設(shè)置

GUI_TOUCH_SetDefaultCalibration();//用默認(rèn)值校準(zhǔn)觸摸屏

}

四、與觸摸屏有關(guān)的函數(shù):

1、4個(gè)功能函數(shù):

void GUI_TOUCH_X_ActivateX(void) {//空}

void GUI_TOUCH_X_ActivateY(void) {//空}

int GUI_TOUCH_X_MeasureX(void) {

return TX;//返回觸摸坐標(biāo)x

}

int GUI_TOUCH_X_MeasureY(void){

return TY; //返回觸摸坐標(biāo)y

}

2、觸摸屏校準(zhǔn)任務(wù)(進(jìn)程, 來(lái)自示例程序: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 = Rect.y0 = 0;

Rect.x1 = LCD_GetXSize() - 1;

Rect.y1 = LCD_GetYSize() - 1;

GUI_DispStringInRect(pString, Rect, GUI_TA_HCENTER | GUI_TA_VCENTER);

}

static void _GetPhysValues(int LogX, int LogY, int * pPhysX, int * pPhysY, const char * pString) {



關(guān)鍵詞:

評(píng)論


相關(guān)推薦

技術(shù)專區(qū)

關(guān)閉