📄 commlcd.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; LCM_Init(); fprintf(stderr, "GAL Common LCD engine: Init LCM!\n"); // 设置液晶属性 psd->planes = 1; // 单屏 psd->xres = GUI_LCM_XMAX; psd->yres = GUI_LCM_YMAX; // 设置屏幕颜色深度 psd->bpp = 8; psd->linelen = psd->xres; // 一行使用的字节数 psd->ncolors = 1 << (psd->bpp); // 最大颜色数 // 分配Framebuffer空间 psd->addr = malloc(GUI_LCM_XMAX * GUI_LCM_YMAX ); // 每一个点要1字节数据 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_TRUECOLOR332; 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; } LCM_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 + -