需准备的软件包:
libminigui-1.6.x-linux.tar.gz           //开发库
minigui-res-1.6.tar.gz                  //资源文件,如bmp,font,icon
minigui-dev-1.6.2-for-win32          // 用于在 windows VC 开发的程序包
下载地址: www.minigui.org
 
参考文献:
1 Hily Jiang. MiniGUI 源码走读 .http://hily.iyi.cn
2 uClinux 下显示驱动移植及 minigui 的移植
 
感谢:
qq . 嵌入式技术交流 02. 小鹤
1 开启uClinuxFrameBuffer支持
1.1 修改 /uClinux-dist/vendors/Samsung/44B0/config.linux-2.4.x
确定 CONFIG_VT=y    //VT 应该是Virtual Terminal
1.2 修改/uClinux-dist/linux-2.4.x/drivers/video/s3c44b0xfb.c
默认情况下是支持16灰度屏的,如果是256色屏,则需要将#define    LCD_GRAY_16 注释掉。
1.3 增加fb0设备
修改vendors/Samsung/44B0/Makefile
1.4 驱动确定
linux-2.4.x/drivers/video/Config.in
if [ "$CONFIG_CPU_S3C44B0X" = "y" ]; then
      tristate ' Samsung S3C44B0X built-in LCD controller frame buffer support' CONFIG_FB_S3C44B0X
fi
linux-2.4.x/drivers/video/Makefile
obj-$(CONFIG_FB_S3C44B0X)          +=s3c44b0xfb.o
linux-2.4.x/drivers/video/fbmem.c
extern int s3c44b0xfb_init(void);
extern int s3c44b0xfb_setup(void);
 
#ifdef CONFIG_FB_S3C44B0X
         {“s3c44b0xfb”,s3c440xfb_init,s3c44b0xfb_setup},
#endif
DEVICES = /
         fb0,c,29,0
1.5 编译uClinux
FrameBuffer部分配置的选择
/********************************************************************************
*
* Console drivers
*
VGA text console (CONFIG_VGA_CONSOLE) [N/y/?] (NEW) n
Support Frame buffer devices (CONFIG_FB) [N/y/?] (NEW) y
*
* Frame-buffer support
*
Support for frame buffer devices (EXPERIMENTAL) (CONFIG_FB) [Y/n/?]
Acorn VIDC support (CONFIG_FB_ACORN) [N/y/?] (NEW) n
  CLPS711X LCD support (CONFIG_FB_CLPS711X) [N/y/?] (NEW) n
  Cyber2000 support (CONFIG_FB_CYBER2000) [N/y/?] (NEW) n
  SA-1100 LCD support (CONFIG_FB_SA1100) [N/y/?] (NEW) n
  Advanced low level driver options (CONFIG_FBCON_ADVANCED) [N/y/?] (NEW) y
  Monochrome support (CONFIG_FBCON_MFB) [N/y/?] (NEW) n
  2 bpp packed pixels support (CONFIG_FBCON_CFB2) [N/y/?] (NEW) n
  4 bpp packed pixels support (CONFIG_FBCON_CFB4) [N/y/?] (NEW) n
  8 bpp packed pixels support (CONFIG_FBCON_CFB8) [N/y/?] (NEW) y
  16 bpp packed pixels support (CONFIG_FBCON_CFB16) [N/y/?] (NEW) n
  24 bpp packed pixels support (CONFIG_FBCON_CFB24) [N/y/?] (NEW) n
  32 bpp packed pixels support (CONFIG_FBCON_CFB32) [N/y/?] (NEW) n
  Amiga bitplanes support (CONFIG_FBCON_AFB) [N/y/?] (NEW) n
  Amiga interleaved bitplanes support (CONFIG_FBCON_ILBM) [N/y/?] (NEW) n
  Atari interleaved bitplanes (2 planes) support (CONFIG_FBCON_IPLAN2P2) [N/y/?] (NEW) n
  Atari interleaved bitplanes (4 planes) support (CONFIG_FBCON_IPLAN2P4) [N/y/?] (NEW) n
  Atari interleaved bitplanes (8 planes) support (CONFIG_FBCON_IPLAN2P8) [N/y/?] (NEW) n
  Amiga bitplanes support (CONFIG_FBCON_AFB) [N/y/?] (NEW) n
  Amiga interleaved bitplanes support (CONFIG_FBCON_ILBM) [N/y/?] (NEW) n
  Atari interleaved bitplanes (2 planes) support (CONFIG_FBCON_IPLAN2P2) [N/y/?] (NEW) n
  Atari interleaved bitplanes (4 planes) support (CONFIG_FBCON_IPLAN2P4) [N/y/?] (NEW) n
  Atari interleaved bitplanes (8 planes) support (CONFIG_FBCON_IPLAN2P8) [N/y/?] (NEW) n
  Mac variable bpp packed pixels support (CONFIG_FBCON_MAC) [N/y/?] (NEW) n
  VGA 16-color planar support (CONFIG_FBCON_VGA_PLANES) [N/y/?] (NEW) n
  VGA characters/attributes support (CONFIG_FBCON_VGA) [N/y/?] (NEW) n
  HGA monochrome support (EXPERIMENTAL) (CONFIG_FBCON_HGA) [N/y/?] (NEW) n
  Support only 8 pixels wide fonts (CONFIG_FBCON_FONTWIDTH8_ONLY) [N/y/?] (NEW) n
  Select compiled-in fonts (CONFIG_FBCON_FONTS) [N/y/?] (NEW) y
  VGA 8x8 font (CONFIG_FONT_8x8) [N/y/?] (NEW) y
  VGA 8x16 font (CONFIG_FONT_8x16) [N/y/?] (NEW) y
  Sparc console 8x16 font (CONFIG_FONT_SUN8x16) [N/y/?] (NEW) n
  Pearl (old m68k) console 8x8 font (CONFIG_FONT_PEARL_8x8) [N/y/?] (NEW) n
  Acorn console 8x8 font (CONFIG_FONT_ACORN_8x8) [N/y/?] (NEW) n
 
Virtual terminal (CONFIG_VT) [Y/n/?]
  Support for console on virtual terminal (CONFIG_VT_CONSOLE) [N/y/?] (NEW) n
*********************************************************************************/
因为LCD256色的,所以选择下项
8 bpp packed pixels support (CONFIG_FBCON_CFB8) [N/y/?] (NEW) y
如果下载内核后进不去系统,则Virtual Terminal 不选,如果进去后fb0不能用,则要选,因为不选的话会屏蔽Support Frame buffer devices (CONFIG_FB) [N/y/?] (NEW) y的设置Virtual Terminal 意思是超级终端显示的数据在LCD上显示,同时超级终端也显示。
1.6 测试/dev/fb0
1测度程序 test1.c
测试/dev/fb0 有没存在,以及其属性
/*******************************************************************************
#include <linux/fb.h>
#include <unistd.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
 
int main ()
{
int fp=0;
struct fb_var_screeninfo vinfo;
struct fb_fix_screeninfo finfo;
fp = open ("/dev/fb0",O_RDWR);
 
if (fp < 0){
printf("Error : Can not open framebuffer device/n");
return 0;
}
 
if (ioctl(fp,FBIOGET_FSCREENINFO,&finfo)){
printf("Error reading fixed information/n");
return 0;
}
 
if (ioctl(fp,FBIOGET_VSCREENINFO,&vinfo)){
printf("Error reading variable information/n");
return 0;
}
 
printf("The mem is :%d/n",finfo.smem_len);
printf("The line_length is :%d/n",finfo.line_length);
printf("The xres is :%d/n",vinfo.xres);
printf("The yres is :%d/n",vinfo.yres);
printf("bits_per_pixel is :%d/n",vinfo.bits_per_pixel);
close (fp);
return 0;
}
*******************************************************************************/
2) 测试程序test2.c
LCD上显示一张图片
/**********************************************************************************
#include <linux/fb.h>
#include <unistd.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
 
const unsigned char gImage_bmp[76560]={……}
//该数组可能过Image2LCD软件生成,该软件可在www.baidu.com找到
int main()
{
 int framebuffer_device;
 int line_size,buffer_size,i;
 char *screen_memory;
 struct fb_var_screeninfo var_info;
 struct fb_fix_screeninfo fix_info;
 
 framebuffer_device=open("/dev/fb0",O_RDWR);
 ioctl(framebuffer_device,FBIOGET_VSCREENINFO,&var_info);
 ioctl(framebuffer_device,FBIOGET_FSCREENINFO,&fix_info);
 line_size=var_info.xres*var_info.bits_per_pixel/8;
 buffer_size=line_size*var_info.yres;
 var_info.xoffset=0;
 var_info.yoffset=0;
 
 screen_memory=(char*)mmap(0,buffer_size,PROT_READ|PROT_WRITE,0,framebuffer_device,0);
 for(i=0;i<buffer_size;i++)
 {
    *(screen_memory+i)=gImage_bmp[i];
 }
 sleep(2);
 return 0;
}
**********************************************************************************/
3) 将程序编译进内核
uClinux-dist/romfs/ 里的文件是最终生成的内核文件,也是开发板上系统能看到的文件,要将文件编译进内核,只需把文件放到这里就行,然后make
arm-elf-gcc –elf2flt –o test1 test1.c
arm-elf-gcc –elf2flt –o test2 test.c
test1 test2 放到uClinux-dist/romfs/usr/
Make 两次,我发现make一次没装进去。
内核编译后下载进开发板,进入系统,运行程序就可测出/dev/fb0有没存在,FrameBuffer有没配置成功。
2 minigui移植
2.1 安装库和资源
1) 解压 minigui-res-1.6.tar.gz , 设置config.linux文件,将编译器设置为arm-elf-gcc。并将安装路径设置为arm-elf-gcc所在的目录。
tar –zxvf minigui-res-1.6.tar.gz
修改config.linux
prefix = $(TOPDIR)/usr/local/
CC     = arm-elf-gcc
然后
Make install
安装到/usr/local/lib/minigui/res
该res 是MiniGUI.cfg 里面资源引用的位置,也是进行移植的资源。
prefix = $(TOPDIR)/usr/local/arm-elf
CC     = arm-elf-gcc
然后
Make install
安装到/usr/local/arm-elf/lib/minigui/res 编译器库里的资源
2) 解压 libminigui-1.6.x-linux.tar.gz, 修改编译参数
tar –zxvf libminigui-1.6.x-linux.tar.gz
修改 libminigui-1.6.2-linux/scripts/mkconfig
if check_value "CONFIG_COMPILER_ARM_ELF"; then
   # CFLAGS="$CFLAGS -D__PIC__ -fpic -msingle-pic-base"
     CFLAGS="$CFLAGS -D__PIC__ -fno-pic -fno-PIC"
Fi
不然在开发板运行程序时会出现如下错误码:
Unhandled fault:external abort on linefetch (F4) at 0x00000001
Fault-common.c(97):start_code=0xc2b9ca0,start_stack=0xc63ff98)
Pid 28:failed 7
3) 配置编译环境
make menuconfig

System wid option
选择
Clipboard support
Unit of timer is 10ms
Mouse button can do double click 

Gal engine option

选择

GAL and its engines:NEWGAL

Include Advanced 2D Graphics APIs

NEWGAL dummy engine

NEWGAL engine on Linux FrameBuffer console

Have console on

IAL engine options

选择

Dummy IAL engine

Font options

选择

Raw bitmap font

Image option

选择

GIF file support

Appearance options

选择

Flat

Ext library options

选择

TreeView control

ListView control

MonthCalendor control

SpinBox control

CoolBar control

Animation control

IconView control

Grid control

Development environment options

The target operating system:uClinux

Compiler:arm-elf-gcc

Libc:uClibc

uClinux-dist directory:/opt/uClinux-dist         //uClinux-dist 的位置

Path prefix:/usr/local/arm-elf                              //arm-elf-gcc 的位置

CFLAGSLDFLAGS I 不填。

Tarball baler options

选择

uClinux

保存退出

make

make install

安装到/usr/local/arm-elf-gcc/

2.2 移植配置文件和资源

1) 配置文件 MiniGUI.cfg

配置文件的名称必需是MiniGUI.cfg,放在/etc/ 下。

由于DRAM的大小限制,我对MiniGUI的资源进行了裁减,主要是字体部分。fbcon 表示采用Framebufferdummy表示没有输入设备,如触摸屏。

[varbitmapfonts]

font_number=0

表示没有varbitmapfonts,会忽略该字段下的资源引用。

/******************************************************************************

[system]

# GAL engine

gal_engine=fbcon

 

# IAL engine

ial_engine=dummy

 

mdev=none

mtype=none

 

[fbcon]

defaultmode=320x240-8bpp

 

[qvfb]

defaultmode=320x240-8bpp

display=0

 

# The first system font must be a logical font using RBF device font.

[systemfont]

font_number=1

font0=rbf-fixed-rrncnn-8-16-ISO8859-1

#font1=*-fixed-rrncnn-*-16-GB2312

#font2=*-Courier-rrncnn-*-16-GB2312

#font3=*-Times-rrncnn-*-16-GB2312

#font4=*-Helvetica-rrncnn-*-16-GB2312

 

default=0

wchar_def=0

fixed=0

caption=0

menu=0

control=0

 

[rawbitmapfonts]

font_number=1

name0=rbf-fixed-rrncnn-8-16-ISO8859-1

fontfile0=/usr/res/font/8x16-iso8859-1.bin

#name1=rbf-fixed-rrncnn-16-16-GB2312.1980-0

#fontfile1=/usr/res/font/song-16-gb2312.bin

 

[varbitmapfonts]

font_number=0

name0=vbf-Courier-rrncnn-10-15-ISO8859-1

fontfile0=/usr/res/font/Courier-rr-10-15.vbf

name1=vbf-Helvetica-rrncnn-15-16-ISO8859-1

fontfile1=/usr/res/font/Helvetica-rr-15-16.vbf

name2=vbf-Times-rrncnn-13-15-ISO8859-1

fontfile2=/usr/res/font/Times-rr-13-15.vbf

 

[mouse]

dblclicktime=300

 

[event]

timeoutusec=300000

repeatusec=50000

 

[cursorinfo]

# Edit following line to specify cursor files path

cursorpath=/usr/res/cursor/

cursornumber=4

cursor0=d_arrow.cur

cursor1=d_beam.cur

cursor2=d_pencil.cur

cursor3=d_cross.cur

 

[iconinfo]

# Edit following line to specify icon files path

iconpath=/usr/res/icon/

# Note that max number defined in source code is 5.

iconnumber=5

icon0=form.ico

icon1=w95mbx01.ico

icon2=w95mbx02.ico

icon3=w95mbx03.ico

icon4=w95mbx04.ico

 

[bitmapinfo]

# Edit following line to specify bitmap files path

bitmappath=/usr/res/bmp/

# Note that max number defined in source code is 7

bitmapnumber=2

bitmap0=capbtns.bmp

# bitmap1=arrows.bmp

# use large bitmap if your default font is 16 pixel height.

bitmap1=arrows16.bmp

bitmap2=none

bitmap3=none

bitmap4=none

bitmap5=none

 

# background picture, use your favirate photo

bitmap6=none

 

# bitmap used by BUTTON control

button=button.bmp

pushbutton=none

pushedbutton=none

 

# bitmap used by LISTBOX control

checkmark=checkmark.bmp

 

# bitmap used by COMBOBOX control

downarrow=downarrow.bmp

updownarrow=updownarrow.bmp

leftrightarrow=leftrightarrow.bmp

 

# bitmap used by IME window

IMEctrlbtn=shurufa.bmp

 

# bitmap used by About dialog box

logo=MiniGUI256.bmp

# logo=MiniGUI16.bmp

 

[bgpicture]

position=center

# position=upleft

# position=downleft

# position=upright

# position=downright

# position=upcenter

# position=downcenter

# position=vcenterleft

# position=vcenterright

# position=none

 

[mainwinmetrics]

minwidth=50

minheight=50

border=2

thickframe=2

thinframe=1

captiony=+4

iconx=16

icony=16

menubary=+0

menubaroffx=8

menubaroffy=5

menuitemy=+0

intermenuitemx=12

intermenuitemy=2

menuitemoffx=18

menutopmargin=4

menubottommargin=4

menuleftmargin=4

menurightmargin=4

menuitemminx=64

menuseparatory=4

menuseparatorx=4

sb_height=14

sb_width=16

sb_interx=2

cxvscroll=16

cyvscroll=16

cxhscroll=16

cyhscroll=16

minbarlen=9

defbarlen=18

 

[windowelementcolors]

bkc_caption_normal=0x00808080

fgc_caption_normal=0x 00C 0C 0C 0

bkc_caption_actived=0x00800000

fgc_caption_actived=0x00FFFFFF

bkc_caption_disabled=0x00808080

fgc_caption_disabled=0x 00C 0C 0C 0

wec_frame_normal=0x00000000

wec_frame_actived=0x00FF0000

wec_frame_disabled=0x00000000

bkc_menubar_normal=0x 00C 0C 0C 0

fgc_menubar_normal=0x00000000

bkc_menubar_hilite=0x00800000

fgc_menubar_hilite=0x00FFFFFF

fgc_menubar_disabled=0x00808080

bkc_menuitem_normal=0x 00C 0C 0C 0

fgc_menuitem_normal=0x00000000

bkc_menuitem_hilite=0x00800000

fgc_menuitem_hilite=0x00FFFFFF

fgc_menuitem_disabled=0x00808080

bkc_pppmenutitle=0x 00C 0C 0C 0

fgc_pppmenutitle=0x00FF0000

fgc_menuitem_frame=0x 00C 66931

wec_3dbox_normal=0x 00C 0C 0C 0

wec_3dbox_reverse=0x00000000

wec_3dbox_light=0x00FFFFFF

wec_3dbox_dark=0x00808080

wec_flat_border=0x00808080

bkc_control_def=0x 00C 0C 0C 0

fgc_control_normal=0x00000000

fgc_control_disabled=0x 00C 0C 0C 0

bkc_hilight_normal=0x00FF0000

bkc_hilight_lostfocus=0x00BDA 69C

fgc_hilight_normal=0x00FFFFFF

fgc_hilight_disabled=0x 00C 0C 0C 0

bkc_desktop=0x00FF0000

bkc_dialog=0x 00C 0C 0C 0

bkc_tip=0x 00C 8FCF8

 

[imeinfo]

imetabpath=/usr/res/imetab/

imenumber=0

ime0=pinyin

 

[appinfo]

apprespath=/usr/local/lib/shared/miniguiapps/

********************************************************************/

2) 资源包 res

res/ 放在/usr/ 下。

RES/

BMP/              包含位图文件

CURSOR/              包含光标文件

FONT/             包含字体文件

ICON/             包含图标文件

IMETAB/              包含输入法文件

FONT/ 里只放8x16-iso8859-1.bin文件,由于字体只有一种,所以下面都选0.

default=0

wchar_def=0

fixed=0

caption=0

menu=0

control=0

资源文件不要配置得太多,如果DRAM不够,而配置资源多的话,会出现如下错误:

Allocation of length 1259251 from process 16 failed

Buffer memory: 356kB

Cache memory: 344kB

Free pages: 2384kB ( 0kB HighMem)

Zone:DMA freepages: 0kB

Zone: Normal freepages: 2384kB

Zone:HighMem freepages: 0kB

( Active: 138, inactive: 37, free: 596 )

= 0kB)

0*4kB 0*8kB 1*16kB 0*32kB 1*64kB 0*128kB 1*256kB 0*512kB 0*1024kB 1*2048kB = 23)= 0kB)

Unable to allocate RAM for process text/data, errno 12

或者

pid 16: failed 4

或者

直接重启

3 测试程序

Hello.c

/**********************************************************************************

#include <minigui/common.h>

#include <minigui/minigui.h>

#include <minigui/gdi.h>

#include <minigui/window.h>

#include <minigui/control.h>

 

//#pragma comment(lib,"minigui.lib")

//#pragma comment(lib,"pthreadVC1.lib") 用于VC编译

 

 

static int MainWinProc(HWND hWnd, int message, WPARAM wParam, LPARAM lParam)

 

{

 

    HDC           hdc;

    switch (message)

         {

        case MSG_CREATE:   

            break;

        case MSG_PAINT:

            hdc = BeginPaint (hWnd);//得到绘图设备                     

            EndPaint (hWnd, hdc);//结束绘图

                            break;

        case MSG_CLOSE://当窗口关闭时该消息产生

                       DestroyMainWindow (hWnd);//注销窗口

            PostQuitMessage (hWnd);

            return 0;

    }

    return DefaultMainWinProc(hWnd, message, wParam, lParam);//未处理的函数在此默认处理

}

 

int MiniGUIMain (int argc, const char* argv[])//main函数对应WindowsWinMaincmain

 

{

 

    MSG Msg;//定义消息

    HWND hMainWnd;//生成主窗口句柄

    MAINWINCREATE CreateInfo;//定义主窗口结构

 

#ifdef _LITE_VERSION//预处理:判断是否Lite版本

 

    SetDesktopRect(0, 0, 1024, 768);

 

#endif

 

    CreateInfo.dwStyle = WS_VISIBLE| WS_BORDER | WS_CAPTION;//设置主窗口风格

    CreateInfo.dwExStyle = WS_EX_NONE;//设置主窗口扩展风格

    CreateInfo.spCaption = "Sk.";//设置主窗口标题

    CreateInfo.hMenu = 0; //设置主窗口菜单

    CreateInfo.hCursor = GetSystemCursor(0); //设置主窗口鼠标光标

    CreateInfo.hIcon = 0; //设置主窗口图标

    CreateInfo.MainWindowProc = MainWinProc; //设置主窗口消息处理函数过程

    CreateInfo.lx = 0; //设置主窗口位置x坐标

    CreateInfo.ty = 0; //设置主窗口位置y坐标

    CreateInfo.rx = 320; //设置主窗口宽度

    CreateInfo.by = 240; //设置主窗口高度

    CreateInfo.iBkColor = COLOR_green; //设置主窗口客户区背景色

    CreateInfo.dwAddData = 0; //设置主窗口的附加数据,通常不需要

    CreateInfo.hHosting = NULL; //设置主窗口的托管窗口,通常为桌面DESKTOP

 

    hMainWnd = CreateMainWindow (&CreateInfo);//创建主窗口 

    if (hMainWnd == HWND_INVALID)//失败则退出

        return -1;

 

    ShowWindow(hMainWnd, SW_SHOWNORMAL);//显示主窗口

 

    while (GetMessage(&Msg, hMainWnd))

         {//进入消息处理

        TranslateMessage(&Msg);

        DispatchMessage(&Msg);

    }

 

    MainWindowThreadCleanup (hMainWnd);

    return 0;

}

**********************************************************************************/

编译 arm-elf-gcc –elf2flt –fno-pic –fno-PIC –o hello hello.c –lminigui –lpthread –lm

在配置minigui采用newgal方式 时,编译程序必须加上-lm,不然会出现 sin ,cos 之类没定义的错误。

-l lmnl

 

 

 

 

 

 

 

GitHub 加速计划 / li / linux-dash
10.39 K
1.2 K
下载
A beautiful web dashboard for Linux
最近提交(Master分支:23 天前 )
186a802e added ecosystem file for PM2 4 年前
5def40a3 Add host customization support for the NodeJS version 4 年前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐