/*
最简单的GUI移植
方案:
用户:编写简单程序,以验证GUI。
GUI :访问TFT接口即可实现。
驱动:使用一个C文件包装opengl及windows模拟1788的TFT访问接口。(此层可以改变,以模拟所有的驱动)。
LCD :开2个线程opengl模拟lcd显示。
平台:VS2008
语言:C uC\GUI3.90
编者:张永辉 2012年12月21日
***************************************************************************************************/
1 使用VS2008新建项目: C/C++win控制台应用程序 空项目
名字:ucGUI_sim_1788_min 及模拟1788平台仅ucGUI最小配置。
2 将源码包中Start的 Config文件夹 剪切到 GUI文件夹中
将GUI剪切到ucGUI_sim_1788_min工程目录。
3 在工程中新建如下目录 (至少需要的目录),并添加相应的C H文件,并添加路径到工程
GUI/
Config 配置文件
GUIConf.h --见附
LCDConf.h --见附
LCDDriver LCD驱动
GUI_X_1788.h --见附
GUI_X_1788.c --见附
OpenglLcd.h --见另外一篇文章
OpenglLcd.c --见另外一篇文章
sim_1788.h --见附
sim_1788.c --见附
Core 核心文件(uCGUI库)
包含Core下的所有h c文件
注:文件夹下文件很多,可以仅包含必要的和需要调用的文件。每个函数都是一个C文件。
ConvertMomo 黑白,灰度转换程序
暂时不用加入
ConvertColor 色彩转换程序
LCDP565.c --我这里使用的565模式
Font 字体文件(uCGUI库)
F6x8.c --必须要的默认字体
F10S_1.c --字体
F10S_ASCII.c
FComic24B_1.c --字体
FComic24B_ASCII.c
main/
main.c --调用MainTask即可
MainTask.c --(uCGUI自带)
MicriumLogo.C --(uCGUI自带)
MicriumLogo_1bpp.c --(uCGUI自带)
4 按如上配置后编译即可。
5 附 需要的文件内容
GUIConf.h
LCDConf.h
GUI_X_1788.h
GUI_X_1788.c
sim_1788.h
sim_1788.c
6 文件的实现
//**************************************************************************************************
//文 件 名: main.c
#include<Windows.h>
void MainTask(void);
int main(void)
{
MainTask();
system("pause");
return 0;
}
/***************************************************************************************************
File : GUIConf.h
功 能: GUI高层配置
*/
#ifndef GUICONF_H
#define GUICONF_H
#define GUI_OS (0) /* Compile with multitasking support */
#define GUI_SUPPORT_TOUCH (0) /* Support a touch screen (req. win-manager) */
#define GUI_SUPPORT_UNICODE (0) /* Support mixed ASCII/UNICODE strings */
#define GUI_DEFAULT_FONT &GUI_Font6x8
#define GUI_ALLOC_SIZE 2048 /* Size of dynamic memory ... For WM and memory devices*/
/***************************************************************************************************
* Configuration of available packages
*/
#define GUI_WINSUPPORT 0 /* Window manager package available */
#define GUI_SUPPORT_MEMDEV 0 /* Memory devices available */
#define GUI_SUPPORT_AA 0 /* Anti aliasing available */
//**************************************************************************************************
#endif
/***************************************************************************************************
文 件:LCDConf.h
功 能: LCD配置
***************************************************************************************************/
#ifndef LCDCONF_H
#define LCDCONF_H
/***************************************************************************************************
* General configuration of LCD
***************************************************************************************************/
#define LCD_XSIZE (480) //* X-resolution of LCD, Logical coor. */
#define LCD_YSIZE (272) //* Y-resolution of LCD, Logical coor. */
#define LCD_BITSPERPIXEL (16) //16位颜色 按565模式
#define LCD_CONTROLLER (1788) //控制器 LPC1788
//**************************************************************************************************
#endif
/***************************************************************************************************
文 件: GUI_X_1788.h
***************************************************************************************************/
#ifndef __GUI_X_1788_H
#define __GUI_X_1788_H
//**************************************************************************************************
int GUI_X_GetTime (void); //还回系统当前时间 ms
void GUI_X_Delay (int period); //延时 单位:ms
void GUI_X_ExecIdle(void); //视窗的非阻塞调用,求解。
void GUI_X_Init (void); //硬件初始化
void GUI_X_Log(const char *s); //调试用的,发送字符串
void GUI_X_Warn(const char *s);
void GUI_X_ErrorOut(const char *s);
unsigned char GetKey(void);
//**************************************************************************************************
#endif
/***************************************************************************************************
文 件: GUI_X_1788.C
***************************************************************************************************/
#include<Windows.h>
#include "OpenglLcd.h"
#include "GUI_X_1788.h"
/***************************************************************************************************
* TIMING FUNCTIONS
* Default time unit (tick), normally is 1 ms.
***************************************************************************************************/
//还回系统当前时间 ms
int GUI_X_GetTime (void)
{
return ((int)GlTimeGetMs());
}
//延时 单位:ms
void GUI_X_Delay (int period)
{
//OSTimeDly(period);
while(period > 0)
{
period--;
Sleep(1);
}
}
//视窗的非阻塞调用,求解。
void GUI_X_ExecIdle(void)
{
Sleep(1);
}
/***************************************************************************************************
* KEYBOARD INTERFACE FUNCTIONS
仅某些窗口需要键盘,否则可以不用
****************************************************************************************************/
//硬件初始化
void GUI_X_Init (void)
{
GlInit();
}
//调试用的,发送字符串
void GUI_X_Log(const char *s)
{ ;
}
void GUI_X_Warn(const char *s)
{ ;
}
void GUI_X_ErrorOut(const char *s)
{ ;
}
unsigned char GetKey(void)
{
return 0xff;
}
/***************************************************************************************************
* 触摸屏支持函数
*
****************************************************************************************************/
//常量激活
void GUI_TOUCH_X_ActivateX(void)
{
}
void GUI_TOUCH_X_ActivateY(void)
{
}
//返回AD转换的X轴结果
int GUI_TOUCH_X_MeasureX(void)
{
return GlTouchGetAdX();
}
//返回AD转换的Y轴结果
int GUI_TOUCH_X_MeasureY(void)
{
return GlTouchGetAdY();
}