|
发表于 2013-1-21 09:08:18
|
显示全部楼层
Are you from Poland? My English is very bad, but I will try to answer your question in English
To question 1
IT is very easy to import uCGUI without using any RTOS compared with using RTOS, Chinese New Year is coming,
so there is a lot of things to do, Somedays later, I will provide an examples for you, But now, I want to give you some tips
(1) without using RTOS, config for ucGUI, you can find these funtion in your project
/*
********************************************************************
*
* Global data
*
********************************************************************
*/
extern __IO int32_t g_iRunTime; // this variable is from bsp_timer.c file
// without using RTOS, we just need to provide time tick
/*********************************************************************
*
* Timing:
* GUI_X_GetTime()
* GUI_X_Delay(int)
Some timing dependent routines require a GetTime
and delay function. Default time unit (tick), normally is
1 ms.
*/
int GUI_X_GetTime(void)
{
return g_iRunTime;
}
void GUI_X_Delay(int ms)
{
int tEnd = g_iRunTime + ms;
while ((tEnd - g_iRunTime) > 0);
}
/*********************************************************************
*
* GUI_X_Init()
*
* Note:
* GUI_X_Init() is called from GUI_Init is a possibility to init
* some hardware which needs to be up and running before the GUI.
* If not required, leave this routine blank.
*/
void GUI_X_Init(void) {}
/*********************************************************************
*
* GUI_X_ExecIdle
*
* Note:
* Called if WM is in idle state
*/
void GUI_X_ExecIdle(void)
{
GUI_X_Delay(1);
}
/*********************************************************************
*
* Logging: OS dependent
Note:
Logging is used in higher debug levels only. The typical target
build does not use logging and does therefor not require any of
the logging routines below. For a release build without logging
the routines below may be eliminated to save some space.
(If the linker is not function aware and eliminates unreferenced
functions automatically)
*/
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); }
/*********************************************************************
*
* Multitasking:
*
* GUI_X_InitOS()
* GUI_X_GetTaskId()
* GUI_X_Lock()
* GUI_X_Unlock()
*
* Note:
* The following routines are required only if emWin is used in a
* true multi task environment, which means you have more than one
* thread using the emWin API.
* In this case the
* #define GUI_OS 1
* needs to be in GUIConf.h
*/
void GUI_X_InitOS(void) { }
void GUI_X_Unlock(void) { }
void GUI_X_Lock(void) { }
U32 GUI_X_GetTaskId(void) { return 1; }
/*********************************************************************
*
* Event driving (optional with multitasking)
*
* GUI_X_WaitEvent()
* GUI_X_WaitEventTimed()
* GUI_X_SignalEvent()
*/
void GUI_X_WaitEvent(void) { }
void GUI_X_SignalEvent(void) { }
void GUI_X_WaitEventTimed(int Period) { }
/*************************** End of file ****************************/
(2)using RTOS
#include "ucos_ii.h"
#include "GUI_Private.H"
#include "stdio.H"
/*
*********************************************************************************************************
* When porting OS_SEM_EN flag must be enabled
*********************************************************************************************************
*/
static OS_EVENT *DispSem;
static OS_EVENT *EventMbox;
static OS_EVENT *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());
}
void GUI_X_Delay(int period)
{
INT32U ticks;
ticks=(period*1000)/OS_TICKS_PER_SEC;
OSTimeDly((INT16U)ticks);
}
/*
*********************************************************************************************************
* GUI_X_ExecIdle()
*********************************************************************************************************
*/
void GUI_X_ExecIdle(void)
{
//OS_X_Delay(1);
OSTimeDly(50);
}
/*
*********************************************************************************************************
* 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);
}
void GUI_X_Lock(void)
{
INT8U err;
OSSemPend(DispSem,0,&err);
}
void GUI_X_Unlock(void)
{
OSSemPost(DispSem);
}
U32 GUI_X_GetTaskId(void)
{
return ((U32)(OSTCBCur->OSTCBPrio));
}
/*
*********************************************************************************************************
* GUI_X_WaitEvent()
* GUI_X_SignalEvent()
*********************************************************************************************************
*/
void GUI_X_WaitEvent(void)
{
INT8U err;
(void)OSMboxPend(EventMbox,0,&err);
}
void GUI_X_SignalEvent(void)
{
(void)OSMboxPost(EventMbox,(void *)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==0)
{
KeyIsInited = 1;
GUI_X_Init();
}
}
void GUI_X_Init(void)
{
KeySem = OSSemCreate(0);
}
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);
}
r= KeyPressed;
KeyPressed = 0;
return (r);
}
void GUI_X_StoreKey(int k)
{
KeyPressed = k;
OSSemPost(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);
} |
|