📄 lcd44b0.c
字号:
/*---------------------------------------------------------文件 : LcdDrv1335.c目的 : 1335的lcd控制器的驱动,用于uC/GUI编程 :罗良涛日期 : 2005-6-24 ---------------------------------------------------------*/#include <stddef.h> /* needed for definition of NULL */#include "LCD_Private.H" /* private modul definitions & config */#include "GUI_Private.H"#include "GUIDebug.h"#include "LCD_0.h" /* Defines for first display *///********************************************************//#include <string.h>#include "..\inc\const.h"#include "..\inc\44b.h"#include "..\inc\44blib.h"#include "..\inc\def.h"#define SedWrtCmdAdd (0x04160000)#define SedWrtDatAdd (0x04140000)#define SedReadStatusAdd (0x04140000)#define SedReadDatAdd (0x04160000)/*define LCD code */#define SYSSET 0x40#define SCROLL 0x44#define SLEEP 0x53#define DISPON 0x59#define DISPOFF 0x58#define OVLAY 0x5b#define HDOTSCR 0x5a#define CSRFORM 0x5d#define CGRAMADR 0x5c#define CSRRGT 0x4c#define CSRLFT 0x4d#define CSRUP 0x4e#define CSRDOWN 0x4f#define CSRW 0x46#define CSRR 0x47#define MWRITE 0x42#define MREAD 0x43#define AP 40/*LCD initial parameters*/uchar SYSTAB[8] = {0x30,0x07,0x0f,0x27,0x50,0xf0,0x28,0x00};uchar SCRTAB[10] = {0x00,0x00,0xf0,0x80,0x25,0xf0,0x00,0x4b,0x00,0x00};//********************************************************#if (LCD_CONTROLLER == 0 ) && (!defined(WIN32) | defined(LCD_SIMCONTROLLER))/*********************************************************** ** Compiler specific settings ** ***********************************************************/#ifdef WIN32 /* Avoid warnings in MS-compiler */ #pragma warning(disable : 4244) // warning C4244: '=' : conversion from 'long ' to 'unsigned char ', possible loss of data #pragma warning(disable : 4761) // warning C4761: integral size mismatch in argument; conversion supplied#endif/*********************************************************** ** Defaults for configuration ** ***********************************************************/#define COLOR LCD_COLORINDEX#ifdef LCDMONO U32 frameBuffer1[SCR_YSIZE][SCR_XSIZE/32];#endif#ifdef LCDG4 U32 (*frameBuffer4)[SCR_XSIZE/16];#endif#ifdef LCDG16 U32 (*frameBuffer16)[SCR_XSIZE/8];#endif#ifdef LCDCOLOR U32 (*frameBuffer256)[SCR_XSIZE/4];#endif/************************* General Library **********************//*SBUROUTINES OF LCD DRIVE*///写LCD控制命令void InputLCDCmd(uchar cmd ) { volatile uchar *p; p = (uchar *)SedWrtCmdAdd; *p = cmd;}//写LCD控制参数和显示字符数据void InputLCDData(uchar dat ) { volatile uchar *p; p = (uchar *)SedWrtDatAdd; *p = dat;}/*读1335控制器显示内存,* ramadd为内存地址*/uchar ReadLCDRamDat(uint ramadd){ volatile uchar *p; uchar result; uchar high,low; low = ramadd & 0xff; high = (ramadd>>8) & 0xff; InputLCDCmd(CSRW); InputLCDData(low); InputLCDData(high); InputLCDCmd(MREAD); p = (uchar *)SedReadDatAdd; result = *p; return(result);}//显示存储器清零void ClrDispRAM(void) { ulong i; InputLCDCmd(CSRRGT); InputLCDCmd(CSRW); InputLCDData(0x00); InputLCDData(0x00); InputLCDCmd(MWRITE); for(i = 0; i <= 32 * 1024; i++) { InputLCDData(0x00); }}//初始化LCD显示参数以及界面void InitLCD(void) { uchar i; InputLCDCmd(SYSSET); for(i = 0; i < 8; i++) { InputLCDData(SYSTAB[i]); } InputLCDCmd(SCROLL); for(i = 0; i < 10; i++) { InputLCDData(SCRTAB[i]); } InputLCDCmd(HDOTSCR); InputLCDData(0X00); InputLCDCmd(OVLAY); InputLCDData(0X1c); //InputLCDData(0X00); InputLCDCmd(DISPOFF); InputLCDData(0X56); ClrDispRAM(); InputLCDCmd(CSRFORM); InputLCDData(0X07); InputLCDData(0X8f); InputLCDCmd(DISPON); InputLCDData(0X16);// InputLCDData(0X10);// ClrDispRAM();}/*********************************************************** ** Internal set pixel routines ** ***********************************************************/static void SetPixel(U32 x, U32 y, LCD_PIXELINDEX c) { U16 temp; uchar hi,lo; uchar i,*p; // c=LCD_NUM_COLORS-1-c;//黑白 #ifdef LCDMONO if(x<SCR_XSIZE && y<SCR_YSIZE) frameBuffer1[(y)][(x)/32]=( frameBuffer1[(y)][(x)/32] & ~(0x80000000>>((x)%32)*1) ) | ( (1)<< ((32-1-((x)%32))*1) ); if(x<SCR_XSIZE && y<SCR_YSIZE) { //写数据 /*temp = y*AP + x/8; hi = (temp >> 8) & 0xff; lo = temp & 0xff; InputLCDCmd(CSRRGT); InputLCDCmd(CSRW); InputLCDData(lo); InputLCDData(hi); p = (uchar *)&frameBuffer1[(y)][(x)/32]; InputLCDCmd(MWRITE); for( i = 0; i < 4; i++ ) InputLCDData(*p++);*/ //InputLCDData(frameBuffer1[(y)][(x)/32]); }#endif//4级灰度#ifdef LCDG4 if(x<SCR_XSIZE && y<SCR_YSIZE) frameBuffer4[(y)][(x)/16]=( frameBuffer4[(y)][x/16] & ~(0xc0000000>>((x)%16)*2) ) | ( (c)<<((16-1-((x)%16))*2) );#endif//16级灰度#ifdef LCDG16 if(x<SCR_XSIZE && y<SCR_YSIZE) frameBuffer16[(y)][(x)/8]=( frameBuffer16[(y)][x/8] & ~(0xf0000000>>((x)%8)*4) ) | ( (c)<<((8-1-((x)%8))*4) );#endif//256色#ifdef LCDCOLOR if(x<SCR_XSIZE && y<SCR_YSIZE) frameBuffer256[(y)][(x)/4]=( frameBuffer256[(y)][x/4] & ~(0xff000000>>((x)%4)*8) ) | ( (c)<<((4-1-((x)%4))*8) );#endif }unsigned int GetPixelIndex(int x, int y) { LCD_PIXELINDEX col;//黑白 #ifdef LCDMONO col=( frameBuffer1[(y)][(x)/32] >> ( 32-1-(x%32)*1 ) ) & 0x1; return col;#endif//4级灰度#ifdef LCDG4 col=( frameBuffer4[(y)][(x)/16] >> ( 32-2-(x%16)*2 ) ) & 0x3; return col;#endif//16级灰度#ifdef LCDG16 col=( frameBuffer16[(y)][(x)/8] >> ( 32-4-(x%8)*4 ) ) & 0xf; return col;#endif//256色#ifdef LCDCOLOR col=( frameBuffer256[(y)][(x)/4] >> ( 32-8-(x%4)*8 ) ) & 0xff; return col;#endif}static void XorPixel (int x, int y) { LCD_PIXELINDEX Index = GetPixelIndex(x,y); SetPixel(x,y,LCD_NUM_COLORS-1-Index);}/*********************************************************** ** LCD_L0_XorPixel ** **********************************************************Purpose: This routine is called by emWin. It writes 1 pixel into the display.*/void LCD_L0_XorPixel(int x, int y) { XorPixel(x, y);}void LCD_L0_SetPixelIndex(int x, int y, int ColorIndex) { SetPixel(x, y, ColorIndex);}/*********************************************************** ** LCD_L0_DrawHLine optimized ** ** 16 bit bus, Using BITBLT ** ***********************************************************/void LCD_L0_DrawHLine (int x0, int y, int x1) { if (GUI_Context.DrawMode & LCD_DRAWMODE_XOR) { while (x0 <= x1) { XorPixel(x0, y); x0++; } } else { while (x0 <= x1) { SetPixel(x0, y, COLOR); x0++; } }}/*********************************************************** ** LCD_L0_DrawVLine optimized ** ** 16 bit bus, using BITBLT ** ***********************************************************/void LCD_L0_DrawVLine (int x, int y0, int y1) { if (GUI_Context.DrawMode & LCD_DRAWMODE_XOR) { while (y0 <= y1) { XorPixel(x, y0); y0++; } } else { while (y0 <= y1) { SetPixel(x, y0, COLOR); y0++; } }}/*********************************************************** ** LCD_FillRect ** ***********************************************************/void LCD_L0_FillRect(int x0, int y0, int x1, int y1) {#if !LCD_SWAP_XY for (; y0 <= y1; y0++) { LCD_L0_DrawHLine(x0,y0, x1); }#else for (; x0 <= x1; x0++) { LCD_L0_DrawVLine(x0,y0, y1); }#endif}/************************************************************ ** Draw a line ** ************************************************************/static void DrawBitLine1BPP(int x, int y, U8 const*p, int Diff, int xsize, const LCD_PIXELINDEX*pTrans) {// LCD_PIXELINDEX aColor[2]; U16 Pixels = ((*p) << 8) | (*(p + 1)); U8 RemPixels; p++;// aColor[0] = *pTrans;// aColor[1] = *(pTrans + 1); x += Diff; RemPixels = 16 - Diff; Pixels <<= Diff; if (GUI_Context.DrawMode & LCD_DRAWMODE_XOR) { do { if (RemPixels==0) { Pixels = ((*(p + 1)) << 8) | (*(p + 2)); p += 2; RemPixels = 16; } if (Pixels & 0x8000) { XorPixel(x, y); } RemPixels--; Pixels <<=1; x++; } while (--xsize); } else { do { if (RemPixels==0) { Pixels = ((*(p + 1)) << 8) | (*(p + 2)); p += 2; RemPixels = 16; } if (Pixels & 0x8000) { SetPixel(x, y, *(pTrans+1)); } RemPixels--; Pixels <<=1; x++; } while (--xsize); } }/* ********************************************* * * * Draw Bitmap 2 BPP * * * **********************************************/#if (LCD_MAX_LOG_COLORS > 2)static void DrawBitLine2BPP(int x, int y, U8 const*p, int Diff, int xsize, const LCD_PIXELINDEX*pTrans) { LCD_PIXELINDEX pixels;/*// Jump to right entry point*/ pixels = *p; if (GUI_Context.DrawMode & LCD_DRAWMODE_TRANS) switch (Diff&3) { case 0: goto WriteTBit0; case 1: goto WriteTBit1; case 2: goto WriteTBit2; default: goto WriteTBit3; } else switch (Diff&3) { case 0: goto WriteBit0; case 1: goto WriteBit1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -