回复: ucgui在rtt中的移植

4 views
Skip to first unread message

weety

unread,
Sep 15, 2014, 11:57:04 PM9/15/14
to rt-threa...@googlegroups.com
赞一个!



-------- 原始邮件 --------
主题:ucgui在rtt中的移植
发件人:tup...@qq.com
收件人:rt-thread-cnusers
抄送:



最近刚刚搞定ucgui3.90在rtt中的移植,
绘图没问题,触摸屏还有些问题,估计是U32 GUI_X_GetTaskId(void) 没有搞明白。

GUI_X_OS.C代码分享出来,其它代码不用动。

#include "GUI_Private.H" 
#include <rtthread.h> 


/* 
********************************************************************************************************* 
* GLOBAL VARIABLES 
********************************************************************************************************* 
*/ 

// static OS_EVENT *DispSem; 
static struct rt_semaphore DispSem ; 

// static OS_EVENT *EventMbox; 
static struct rt_mailbox EventMbox; 
static char mb_pool[128]; 

static struct rt_semaphore KeySem; 
static int KeyPressed; 
static char KeyIsInited; 


/* 
********************************************************************************************************* 
* TIMING FUNCTIONS 

* Notes: Some timing dependent routines of uC/GUI require a GetTime and delay funtion. 
* Default time unit (tick), normally is 1 ms. 
********************************************************************************************************* 
*/ 

int GUI_X_GetTime(void) 

// return ((int)OSTimeGet()); 
return ((int)rt_tick_get()); 


void GUI_X_Delay(int period) 

rt_tick_t ticks; 
ticks=(period*100)/RT_TICK_PER_SECOND; 
rt_thread_delay(ticks); 



/* 
********************************************************************************************************* 
* GUI_X_ExecIdle() 
********************************************************************************************************* 
*/ 

/* WM空闲时调用 */ 
void GUI_X_ExecIdle(void) 

// OSTimeDly(50); 
rt_thread_delay(10); 



/* 
********************************************************************************************************* 
* MULTITASKING INTERFACE FUNCTIONS 

* Note(1): 1) The following routines are required only if uC/GUI is used in a true multi task environment, 
* which means you have more than one thread using the uC/GUI API. In this case the #define 
* GUI_OS 1 needs to be in GUIConf.h 
********************************************************************************************************* 
*/ 

void GUI_X_InitOS (void) 

// DispSem = OSSemCreate(1); /* 建立一个互斥型信号量 */ 
// EventMbox = OSMboxCreate((void *)0); /* 建立一个邮箱 */ 
rt_sem_init(& DispSem,"gui_sem",0, RT_IPC_FLAG_FIFO); 
//rt_mb_create(const char * name, rt_size_t size, rt_uint8_t flag) 
rt_mb_init( &EventMbox,"gui_mb",&mb_pool[0], /* 邮箱用到的内存池是mb_pool */ 
sizeof(mb_pool)/4, /* 大小是mb_pool/4,因为每封邮件的大小是4字节*/ 
RT_IPC_FLAG_FIFO); /* 采用FIFO方式进行线程等待*/ 



void GUI_X_Lock(void) 

// INT8U err; 
// OSSemPend(DispSem,0,&err); 
rt_sem_take(&DispSem,0); 



void GUI_X_Unlock(void) 

// OSSemPost(DispSem); 
rt_sem_release(&DispSem); 



U32 GUI_X_GetTaskId(void) 

rt_thread_t task; 
// return ((U32)(OSTCBCur->OSTCBPrio)); 
task = rt_thread_self(); 
return (U32)(task->current_priority);


/* 
********************************************************************************************************* 
* GUI_X_WaitEvent() 
* GUI_X_SignalEvent() 
********************************************************************************************************* 
*/ 


void GUI_X_WaitEvent(void) 

// INT8U err; 
// (void)OSMboxPend(EventMbox,0,&err); 
rt_uint32_t value; 
rt_mb_recv( &EventMbox, &value, 0); 



void GUI_X_SignalEvent(void) 

// (void)OSMboxPost(EventMbox,(void *)1); 
rt_mb_send(&EventMbox,( rt_uint32_t )1); 


/* 
********************************************************************************************************* 
* KEYBOARD INTERFACE FUNCTIONS 

* Purpose: The keyboard routines are required only by some widgets. 
* If widgets are not used, they may be eliminated. 

* Note(s): If uC/OS-II is used, characters typed into the log window will be placed in the keyboard buffer. 
* This is a neat feature which allows you to operate your target system without having to use or 
* even to have a keyboard connected to it. (useful for demos !) 
********************************************************************************************************* 
*/ 

static void CheckInit(void) 

if(KeyIsInited==RT_FALSE) 

KeyIsInited = RT_TRUE; 
GUI_X_Init(); 




/* 被GUI_Init()调用,用来初始化一些GUI运行之前需要用的硬件,如键盘或者鼠标之类的.如果不需要的话,可以为空 */ 
void GUI_X_Init(void) 

//KeySem = OSSemCreate(0); 
rt_sem_init(&KeySem,"key_sem",0, RT_IPC_FLAG_FIFO); 



int GUI_X_GetKey(void) 

int r; 
r = KeyPressed; 
CheckInit(); 
KeyPressed = 0; 
return (r); 



int GUI_X_WaitKey(void) 

int r; 
//INT8U err; 
CheckInit(); 
if(KeyPressed==0) 

//OSSemPend(KeySem,0,&err); /* 等待信号量 */ 
rt_sem_take(&KeySem,0); 


r= KeyPressed; 
KeyPressed = 0; 
return (r); 



void GUI_X_StoreKey(int k) 

KeyPressed = k; 
//OSSemPost(KeySem); /* 释放信号量 */ 
rt_sem_release(&KeySem); 


void GUI_X_Log(const char *s) 

GUI_USE_PARA(s); 


void GUI_X_Warn(const char *s) 

GUI_USE_PARA(s); 


void GUI_X_ErrorOut(const char *s) 

GUI_USE_PARA(s); 


--
You received this message because you are subscribed to the Google Groups "rt-thread用户组" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rt-thread-cnus...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages