📄 sys_lcd.c.svn-base
字号:
/****************************************************************************
Copyright (c) 深圳市民德电子科技有限公司 http://www.szminde.cn
文件名称:sys_LCD.c
版本号: 1.0
日期: 2005-05-25
说明: 此文件包含ES-TAD7100开发板上的LCD模块操作的函数。
调用列表:--
修改历史:--
****************************************************************************/
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "def.h"
#include "44b.h"
#include "sys_LCD.h"
#include "bmp2array.h"
/*对控制位的宏定义*/
#define LCDCON1_ENVID (1)
#define LCDCON1_INVVD (1<<1)
#define LCDCON1_INVFRAME (1<<2)
#define LCDCON1_INVLINE (1<<3)
#define LCDCON1_INVCLK (1<<4)
#define LCDCON1_MMODE (1<<7)
/*常数宏定义*/
#define L248 (8)
#define CLKVAL (20)
/*一个操作的宏定义*/
#define M5D(n) ((n) & 0x1fffff)
/*文本模式下一些LCD信息的宏定义*/
#define LCDColumn 40
#define LCDRow 20
#define LCDTxtMode_TxtWidth 8
#define LCDTxtMode_TxtHeight 12
/*延时函数*/
extern void Delay(int time);
/*用于在LCD上显示ASCII字符的数组*/
U8 LCDTxtData[128][12]={
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1c,0x10,0x10,0x10,0x10,0x10,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf0,0x10,0x10,0x10,0x10,0x10,
0x10,0x10,0x10,0x10,0x10,0x10,0x1c,0x0, 0x0, 0x0, 0x0, 0x0,
0x10,0x10,0x10,0x10,0x10,0x10,0xf0,0x0, 0x0, 0x0, 0x0, 0x0,
0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfc,0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x30,0x78,0x78,0x78,0x30,0x0, 0x0, 0x0, 0x0,
0xfc,0xfc,0xfc,0xcc,0x84,0x84,0x84,0xcc,0xfc,0xfc,0xfc,0xfc,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x1c,0xc, 0xc, 0x14,0x10,0x30,0x48,0x48,0x30,0x0, 0x0,
0x0, 0x38,0x44,0x44,0x38,0x10,0x7c,0x10,0x10,0x10,0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0xc, 0x34,0x2c,0x34,0x24,0x24,0x2c,0x6c,0x60,0x0, 0x0,
0x0, 0x54,0x54,0x28,0x28,0x6c,0x28,0x28,0x54,0x54,0x0, 0x0,
0x10,0x10,0x10,0x10,0x10,0x10,0xfc,0x10,0x10,0x10,0x10,0x10,
0x0, 0x4, 0xc, 0x1c,0x3c,0x7c,0x3c,0x1c,0xc, 0x4, 0x0, 0x0,
0x10,0x38,0x10,0x10,0x10,0x10,0x10,0x10,0x38,0x10,0x0, 0x0,
0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x0, 0x28,0x28,0x0, 0x0,
0x3c,0x54,0x54,0x54,0x34,0x14,0x14,0x14,0x14,0x14,0x0, 0x0,
0x10,0x10,0x10,0x10,0x10,0x10,0xfc,0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfc,0x10,0x10,0x10,0x10,0x10,
0x10,0x10,0x10,0x10,0x10,0x10,0xf0,0x10,0x10,0x10,0x10,0x10,
0x10,0x38,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x0, 0x0,
0x10,0x10,0x10,0x10,0x10,0x10,0x1c,0x10,0x10,0x10,0x10,0x10,
0x0, 0x0, 0x0, 0x0, 0x8, 0x7c,0x8, 0x0, 0x0, 0x0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, 0x20,0x0, 0x0,
0x0, 0x0, 0x70,0x88,0x98,0xa8,0xa8,0xb8,0x80,0x78,0x0, 0x0,
0x0, 0x0, 0x20,0x20,0x30,0x50,0x50,0x78,0x48,0xcc,0x0, 0x0,
0x0, 0x0, 0xf0,0x48,0x48,0x70,0x48,0x48,0x48,0xf0,0x0, 0x0,
0x0, 0x0, 0x78,0x88,0x80,0x80,0x80,0x80,0x88,0x70,0x0, 0x0,
0x0, 0x0, 0xf0,0x48,0x48,0x48,0x48,0x48,0x48,0xf0,0x0, 0x0,
0x0, 0x0, 0xf8,0x48,0x50,0x70,0x50,0x40,0x48,0xf8,0x0, 0x0,
0x0, 0x0, 0xf8,0x48,0x50,0x70,0x50,0x40,0x40,0xe0,0x0, 0x0,
0x0, 0x0, 0x38,0x48,0x80,0x80,0x9c,0x88,0x48,0x30,0x0, 0x0,
0x0, 0x0, 0xcc,0x48,0x48,0x78,0x48,0x48,0x48,0xcc,0x0, 0x0,
0x0, 0x0, 0xf8,0x20,0x20,0x20,0x20,0x20,0x20,0xf8,0x0, 0x0,
0x0, 0x0, 0x7c,0x10,0x10,0x10,0x10,0x10,0x10,0x90,0xe0,0x0,
0x0, 0x0, 0xec,0x48,0x50,0x60,0x50,0x50,0x48,0xec,0x0, 0x0,
0x0, 0x0, 0xe0,0x40,0x40,0x40,0x40,0x40,0x44,0xfc,0x0, 0x0,
0x0, 0x0, 0xd8,0xd8,0xd8,0xd8,0xa8,0xa8,0xa8,0xa8,0x0, 0x0,
0x0, 0x0, 0xdc,0x48,0x68,0x68,0x58,0x58,0x48,0xe8,0x0, 0x0,
0x0, 0x0, 0x70,0x88,0x88,0x88,0x88,0x88,0x88,0x70,0x0, 0x0,
0x0, 0x0, 0xf0,0x48,0x48,0x70,0x40,0x40,0x40,0xe0,0x0, 0x0,
0x0, 0x0, 0x70,0x88,0x88,0x88,0x88,0xe8,0x98,0x70,0x18,0x0,
0x0, 0x0, 0xf0,0x48,0x48,0x70,0x50,0x48,0x48,0xec,0x0, 0x0,
0x0, 0x0, 0x78,0x88,0x80,0x60,0x10,0x8, 0x88,0xf0,0x0, 0x0,
0x0, 0x0, 0xf8,0xa8,0x20,0x20,0x20,0x20,0x20,0x70,0x0, 0x0,
0x0, 0x0, 0xcc,0x48,0x48,0x48,0x48,0x48,0x48,0x30,0x0, 0x0,
0x0, 0x0, 0xcc,0x48,0x48,0x50,0x50,0x30,0x20,0x20,0x0, 0x0,
0x0, 0x0, 0xa8,0xa8,0xa8,0x70,0x50,0x50,0x50,0x50,0x0, 0x0,
0x0, 0x0, 0xd8,0x50,0x50,0x20,0x20,0x50,0x50,0xd8,0x0, 0x0,
0x0, 0x0, 0xd8,0x50,0x50,0x20,0x20,0x20,0x20,0x70,0x0, 0x0,
0x0, 0x0, 0xf8,0x90,0x10,0x20,0x20,0x40,0x48,0xf8,0x0, 0x0,
0x0, 0x38,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x38,0x0,
0x0, 0x40,0x40,0x40,0x20,0x20,0x10,0x10,0x10,0x8, 0x0, 0x0,
0x0, 0x70,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x70,0x0,
0x0, 0x20,0x50,0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfc,
0x0, 0x20,0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x30,0x48,0x38,0x48,0x3c,0x0, 0x0,
0x0, 0x0, 0xc0,0x40,0x40,0x70,0x48,0x48,0x48,0x70,0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x38,0x48,0x40,0x40,0x38,0x0, 0x0,
0x0, 0x0, 0x18,0x8, 0x8, 0x38,0x48,0x48,0x48,0x3c,0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x30,0x48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x0, 0x0, 0x0, 0x0, 0xd8,0x50,0x20,0x50,0xd8,0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0xec,0x48,0x50,0x30,0x20,0x20,0xc0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x78,0x10,0x20,0x20,0x78,0x0, 0x0,
0x0, 0x18,0x10,0x10,0x10,0x20,0x10,0x10,0x10,0x10,0x18,0x0,
0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
0x0, 0x60,0x20,0x20,0x20,0x10,0x20,0x20,0x20,0x20,0x60,0x0,
0x40,0xa4,0x18,0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
};
U32* pLCDBuffer16=(U32*)0xc000000; //LCD显示缓存起始地址
//U32 LCDBuffer[LCDHEIGHT][LCDWIDTH]; //LCD显示缓存数组
U32 LCDdspMode=DspTxtMode;
U8 LCDTxtBuffer[LCDRow][LCDColumn]; //文本模式文字缓冲区数组
S32 LCDCurrentPrnTxt=0;
U8 LCDIsprnOverPage=FALSE;
char tbuf[256];
/****************************************************************************
函数名称:LCD_Off()
说明: 关闭LCD显示。
调用函数:Delay()
输入参数:无
输出参数:无
****************************************************************************/
void LCD_Off(void)
{
Delay(100);
rPDATC = ( rPDATC | (1<<8) );
Delay(100);
}
/****************************************************************************
函数名称:LCD_On()
说明: 打开LCD显示。
调用函数:Delay()
输入参数:无
输出参数:无
****************************************************************************/
void LCD_On(void)
{
Delay(100);
rPDATC = ( rPDATC & (~(1<<8)) );
Delay(100);
}
/****************************************************************************
函数名称:LCD_Init()
说明: 初始化LCD。
调用函数:LCD_Off()
LCD_On()
输入参数:无
输出参数:无
****************************************************************************/
void LCD_Init()
{
S32 i;
U32 LCDBASEU,LCDBASEL,LCDBANK;
LCD_Off();
for(i=0;i<40*240;i++)
*(pLCDBuffer16+i)=0x0;
rBLUELUT=0xfa40;
rDITHMODE=0x0;
rDP1_2 = 0xa5a5;
rDP4_7 = 0xba5da65;
rDP3_5 = 0xa5a5f;
rDP2_3 = 0xd6b;
rDP5_7 = 0xeb7b5ed;
rDP3_4 = 0x7dbe;
rDP4_5 = 0x7ebdf;
rDP6_7 = 0x7fdfbfe;
rLCDCON1=(0)|(1<<5)|(0<<7)|(0x3<<8)|(0x3<<10)|(10<<12);
rLCDCON2=(240-1)|(79<<10)|(10<<21);
LCDBANK=0xc000000>>22;
LCDBASEU=0x0;
LCDBASEL=LCDBASEU+(160)*240;
rLCDSADDR1= (0x2<<27) | ( ((U32)pLCDBuffer16>>22)<<21 ) | M5D((U32)pLCDBuffer16>>1);
rLCDSADDR2= M5D((((U32)pLCDBuffer16+(LCDWIDTH*LCDHEIGHT/2))>>1)) | (13<<21);
rLCDSADDR3= (320/4) | ( 0<<9 );
rLCDCON1=(1)|(1<<5)|(0<<7)|(0x3<<8)|(0x3<<10)|(10<<12);
Delay(1000);
LCD_On();
}
/****************************************************************************
函数名称:LCD_TxtRefresh()
说明: 将文字缓冲区的内容显示在LCD屏幕上。
调用函数:无
输入参数:LCDCurrentDspTxt 发生卷屏时,从第几行开始显示
输出参数:无
****************************************************************************/
void LCD_TxtRefresh(S32 LCDCurrentDspTxt)
{
S32 i,j,k,showrow;
U32 data;
U8 txtdata;
for(j=0;j<LCDHEIGHT;j++)
{
for(i=0;i<LCDColumn;i++)
{
data=0;
showrow=LCDCurrentDspTxt+j/LCDTxtMode_TxtHeight;
if(showrow>LCDRow-1)
showrow-=LCDRow;
txtdata=LCDTxtBuffer[showrow][i];
if(txtdata>128)
txtdata=' ';
txtdata=LCDTxtData[txtdata][j%LCDTxtMode_TxtHeight];
for(k=7;k>=0;k--)
{
data<<=4;
data|=((txtdata>>k)&0x1)*0xf; //改变8bit的txtdata为32bit
}
*((U32*)pLCDBuffer16+i+(j)*40)=data;
}
}
}
/****************************************************************************
函数名称:LCD_Printf()
说明: 在LCD屏幕上输出的格式化字符。
调用函数:va_start()
vsprintf()
va_end()
LCD_TxtRefresh()
输入参数:*format 要输出的格式化字符串
输出参数:无
****************************************************************************/
void LCD_Printf(const S8 *format,...)
{
S32 i,j=0;
S32 LCDCurrentDspTxt=0;
va_list v_list;
S8 *ptr;
va_start(v_list, format);
vsprintf(tbuf, format, v_list);
va_end(v_list);
ptr= tbuf;
for(i=0;ptr[i]!=0;i++)
{
if(ptr[i]=='\n')
{
LCDCurrentPrnTxt++;
if(LCDCurrentPrnTxt>LCDRow-1)
{
LCDCurrentPrnTxt-=LCDRow;
LCDIsprnOverPage=TRUE;
}
if(LCDIsprnOverPage)
LCDCurrentDspTxt=LCDCurrentPrnTxt;
for(;j<LCDColumn;j++) //补齐空格
LCDTxtBuffer[LCDCurrentPrnTxt][j]=0;
j=0;
}
else if(ptr[i]=='\b')
{
for(;j<LCDColumn;j++) //补齐空格
LCDTxtBuffer[LCDCurrentPrnTxt][j]=0;
j=0;
}
else{
if(j<LCDColumn)
LCDTxtBuffer[LCDCurrentPrnTxt][j++]=ptr[i];
}
}
LCD_TxtRefresh(LCDCurrentDspTxt);
}
/****************************************************************************
函数名称:LCD_Cls()
说明: 文本模式下清除屏幕。
调用函数:memset()
输入参数:无
输出参数:无
****************************************************************************/
void LCD_Cls()
{
LCDCurrentPrnTxt=0;
LCDIsprnOverPage=FALSE;
memset(LCDTxtBuffer,0,LCDRow*LCDColumn);
}
/****************************************************************************
函数名称:LCD_ChangeMode()
说明: LCD转换显示模式。
调用函数:无
输入参数:无
输出参数:无
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -