By linhua QQ:273896333
Minigui移植的主要工作是移植GAL和IAL。在Mini2440开发板上安装linux 使用kernel 2.6.13内核,已经提供了Framebuffer设备的驱动,因此GAL可以直接使用fbcon。 Mini2440的输入部分有触摸屏和6个用户按键,因此在mini2440上移植minigui主要工作是编写IAL驱动。
下载libminigui-str- 1.6.2 .tar.gz
(http://blog.21ic.com/user1/5108/archives/2008/50737.html)
使用MSDK2410()做为修改的蓝本,修改/libminigui-str- 1.6.2 /src/ial/2410.c和/libminigui-str-1.6.2/src/ial/2410.h。
触摸屏部分:
使用MSDK2410的IAL会使触摸屏Y轴方向相反。在以下程序做修改:
在2410.c 文件wait_event()函数中
if (ts_event.pressure > 0)
{
mousex = ts_event.x;
mousey = ts_event.y;
}
修改为
if (ts_event.pressure > 0)
{
mousex = ts_event.x;
mousey = 319 - ts_event.y;
}
按键部分:
通过阅读Mini2440中按键的驱动程序源码(mini2440光盘/linux/linux- 2.6.13 -mini2440-20080910/kernel-2.6.13/drivers/micro2440_buttons.c),可以得知按键的状态为用一个数组表示:
static volatile int key_values [] = {0, 0, 0, 0, 0, 0};
分别代表K1~K6六个按键的状态。当按键按下时,对应值的值为各个按键的值(K1~K6分别为1,2,……6),当松开瞬间,对应值为按键的值加上0x80。不按时值为0。
将K1~K6分别映射为:
K1:Enter键
K2:B键
K3:Tab键
K4:BackSpace键
K5:A键
K6:Esc键
在2410.h中添加三个宏定义:
#define KBD_DEVICE "/dev/buttons"
#define NR_KEYS 128
#define KEY_RELEASED 0x80
在2410.c文件中添加:
定义全局变量:
static unsigned char state [NR_KEYS];
static int get_state[6];
static int get_flag[6];
static int ts = -1;
static int btn_fd = -1;
添加两个函数keyboard_update(void)和keyboard_getstate(void)
修改三个函数: Init2410Input()、wait_event()和Term2410Input()
具体修改见附件(修改后的2410.h,2410.c)。
|
然后就可以编译libminigui库
./configure --host=arm-linux --enable-jpgsupport=yes --enable-pngsupport=yes --enable-gifsupport=yes --disable-lite --prefix=/usr/local/arm/2.95.3/arm-linux --enable-smdk2410ial=yes
make
make install
minigui程序还需移植以下一些库和资源,具体步骤网络上资料已经相当详细了,可参考http://blog.chinaunix.net/u2/72877/showart_1083580.html上的那篇文章。
ZLIB库的移植
PNG库的移植
jpeg 库的移植
libttf 库的移植
MINIGUI资源文件的移植
注:若所有工作做完后运行minigui程序出现
GAL fbcon engine: Can't open /dev/tty0: No such file or directory
GAL: Init GAL engine failure: fbcon.
GDI: Can not initialize graphics engine!
则需输入:
[root@FriendlyARM /]# mknod /dev/tty 0 c 4 0
然后再运行即可。