⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 commlcd.c

📁 基于周立功公司smartarm2200的minigui实验程序
💻 C
字号:
// 使用native图形引擎的数据结构和fb(Framebuffer)的驱动程序#include "native.h"#include "fb.h"#include "lcddrive.h"// 图形引擎始化函数// 初始化正确返回PSD结构,否则返回NULLstatic PSD  fb_open(PSD psd){   PSUBDRIVER  subdriver;    // 初始化液晶    TftInit();    fprintf(stderr, "GAL Common LCD engine: Init LCM!\n");    // 设置液晶属性    psd->planes = 1;				// 单屏    #if SWAP_XY_EN==1       psd->xres = GUI_LCM_YMAX;    psd->yres = GUI_LCM_XMAX;#else    psd->xres = GUI_LCM_XMAX;    psd->yres = GUI_LCM_YMAX;#endif 	// 设置屏幕颜色深度    psd->bpp = 16;	psd->linelen = 2 * (psd->xres);	    psd->ncolors = (psd->bpp >= 24) ? (1 << 24) : (1 << psd->bpp);	// 分配Framebuffer空间    psd->addr = malloc(GUI_LCM_XMAX * GUI_LCM_YMAX * 2);	// 每一个点要2字节数据    if ( ! psd->addr )    	{  fprintf(stderr, "GAL Common LCD engine: Couldn't allocate buffer!\n");       return(NULL);			// 内存不足,初始化失败(返回NULL)    }        psd->gr_mode = MODE_SET;	// 画图模式为设置模式(非AND、XOR模式)    psd->size = 0;             	// 分配的内存(由fb驱动程序设置)    psd->flags = PSF_MEMORY;	// 采用MEMORY驱动方式        psd->flags |= PSF_MSBRIGHT;     // 设置象素格式    psd->pixtype = PF_TRUECOLOR565;    // 子驱动程序选择(画点、线)    subdriver = select_fb_subdriver (psd);    if (!subdriver)     {   fprintf(stderr,"GAL Common LCD engine: No driver for bpp %d\n", psd->bpp);        return(NULL);    }    // 子驱动程序入口点设置    if (!set_subdriver (psd, subdriver, TRUE))     {   fprintf(stderr,"GAL Common LCD engine: Driver initialize failed for bpp %d\n", psd->bpp);        return(NULL);    }    return(psd);  }// 关闭fbstatic void fb_close (PSD psd){	free(psd->addr);}// 设置调色板static void fb_setpalette (PSD psd, int first, int count, GAL_Color *palette){}// 取得调色板static void fb_getpalette (PSD psd, int first, int count, GAL_Color *palette){}// 更新显示区域static void  fb_UpdateRects(PSD psd, int l, int t, int r, int b){	int  bak;	if(l > r) 	{	//fprintf(stderr,"GAL Common LCD engine: UpdateRect l >= r !\n");		bak = l;		l = r;		r = bak;	}	if(t > b) 	{	//fprintf(stderr,"GAL Common LCD engine: UpdateRect t >= b !\n");		bak = t;		t = b;		b = bak;	}		TFT_UpdateRects( l, t, 		// 起始点坐标    	             r+1-l, b+1-t, 		// 区域宽度、高度    	             psd->addr);	  	// Framebuffer起始地址       }// COMMLCD图形引擎的数据结构SCREENDEVICE commlcd = {    0, 0, 0, 0, 0,     0, 0, 0, 0, 0,     0, 0, 0, 0, 0,     0, 0, 0, 0,     NULL, NULL,    fb_open,    fb_close,    fb_setpalette,    fb_getpalette,    native_gen_allocatememgc,    fb_mapmemgc,    native_gen_freememgc,    native_gen_clippoint,    native_gen_fillrect,    NULL,           // DrawPixel 使用fb的驱动程序    NULL,           // ReadPixel 使用fb的驱动程序    NULL,           // DrawHLine 使用fb的驱动程序    NULL,           // DrawVLine 使用fb的驱动程序    NULL,           // Blit 使用fb的驱动程序    NULL,           // PutBox 使用fb的驱动程序    NULL,           // GetBox 使用fb的驱动程序    NULL,           // PutBoxMask 使用fb的驱动程序    NULL,           // CopyBox 使用fb的驱动程序    fb_UpdateRects 	// UpdateRect更新显示函数};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -