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

📄 commlcd.c

📁 在ADS环境下MiniGUI的源码
💻 C
字号:
/*** $Id: commlcd.c,v 1.1 2004/08/02 02:57:47 snig Exp $** ** commlcd.c: GAL driver for common lcd.** ** Copyright (C) 2004 Feynman Software.**** Create Date: 2003/07/04 by Wei Yongming*//*** This program is free software; you can redistribute it and/or modify** it under the terms of the GNU General Public License as published by** the Free Software Foundation; either version 2 of the License, or** (at your option) any later version.**** This program is distributed in the hope that it will be useful,** but WITHOUT ANY WARRANTY; without even the implied warranty of** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the** GNU General Public License for more details.**** You should have received a copy of the GNU General Public License** along with this program; if not, write to the Free Software** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA*/#include <stdio.h>#include <stdlib.h>#include <stdarg.h>#include "native.h"#ifdef _NATIVE_GAL_COMMLCD#include "lcddrive.h"#include "fb.h"static PSD fb_open(PSD psd){    PSUBDRIVER subdriver;    TftInit();#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->planes = 1;    psd->bpp = 16;    psd->linelen = psd->xres * 2;    psd->ncolors = 1 << 16;    if (!(psd->addr = malloc(GUI_LCM_XMAX * GUI_LCM_YMAX * 2))) {        fprintf(stderr, "ERROR: Couldn't allocate buffer!(COMMLCD_VideoInit) \n");          return -1;    }    psd->gr_mode = MODE_SET;    psd->size = 0;    psd->flags = PSF_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);        goto fail;    }    if (!set_subdriver(psd, subdriver, TRUE)) {        fprintf(stderr,"GAL Common LCD engine: Driver initialize failed for bpp %d\n", psd->bpp);        goto fail;    }    return psd;fail:    return NULL;}/* close framebuffer*/static void fb_close (PSD psd){    if (psd->addr)        free(psd->addr);    psd->addr = NULL;}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 update_rect(PSD psd, int l, int t, int r, int b){    int  bak;    	if(l > r) 	{			bak = l;		l = r;		r = bak;	}	if(t > b) 	{			bak = t;		t = b;		b = bak;	}		TFT_UpdateRects(l, t, r +1 - l, b +1 - t, psd->addr);}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 subdriver */    NULL,           /* ReadPixel subdriver */    NULL,           /* DrawHLine subdriver */    NULL,           /* DrawVLine subdriver */    NULL,           /* Blit subdriver */    NULL,           /* PutBox subdriver */    NULL,           /* GetBox subdriver */    NULL,           /* PutBoxMask subdriver */    NULL,           /* CopyBox subdriver */    update_rect};#endif /* _NATIVE_GAL_COMMLCD */

⌨️ 快捷键说明

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