📄 lcd.c
字号:
//#include <util/delay.h>
//#include <avr/delay.h>
//#include <avr/pgmspace.h>
#include "p1.h"
#include "LCD.h"
//#include "config.h"
//#include "Global.h"
//#include "myrtc.h"
//#include "USARTProcess.h"
//#define BasePart3 0x80
//extern unsigned char index[index_No];
//extern unsigned char Temper_Show;
//extern unsigned char WordInEEP[];
//extern unsigned char index2[50];
unsigned char ParaSysTable8[]= {
0x30,0x87,0x07,0x27,0x43,0xf0,0x28,0x00 // P1-P8参数
};
unsigned char ParaScrTableA[]= {
0x00,BasePart1,0xF0,0x00,BasePart2,0xF0,0x00,BasePart3,0x00,BasePart4
};
//extern unsigned char Set_No;
//extern unsigned char TemperAlarm[8];
// USART0 Receiver buffer
/*
extern struct ShakeTemperData STC_Data[21];//20个
extern struct ShowData Sc2Data[9];
extern struct LocalShake SData[8];
extern struct LocalTemper TData[9]; //9个 第9个是环温
*/
//extern unsigned char Error_Beep;
//extern struct _RTC_ALL rtc_all;
//extern struct TimeData Time;
//extern unsigned char DSP_State[8];
//extern unsigned char MCU_State[9];
// External Interrupt 4 service routine
/*
extern struct ShakeTemperData *STC_Data; //20个
extern struct ShowData *Sc2Data; //9个
extern struct LocalShake *SData; //8个
extern struct LocalTemper *TData; //9个 第9个是环温
*/
/*
#if USING_POINTER
extern struct ShakeTemperData *STC_Data;//20个
extern struct ShowData *Sc2Data;
extern struct LocalShake *SData;
extern struct LocalTemper *TData;//9个 第9个是环温
#else
extern struct ShakeTemperData STC_Data[22];//20个
extern struct ShowData Sc2Data[9];
extern struct LocalShake SData[8];
extern struct LocalTemper TData[9]; //9个 第9个是环温
#endif
*/
//extern unsigned char screen4_buff_state;
//extern unsigned char Error_Beep_En;
//extern unsigned char index1[index1_No];
//unsigned char *index=0x7000;
//unsigned char *index1=0x7100;
//extern unsigned char Train_No[4];//车号
//extern unsigned char Train_Time[6];//时间
//extern unsigned char Train_Alert[2];//报警预警域值
//extern unsigned char Train_Viber[17];
//unsigned char Local_Addr;
//unsigned char Current_Number=0;//轴号
//unsigned char Current_Disp_No=1;//车厢号
//填黑
void black( unsigned int x0,unsigned char y0,unsigned int xt,unsigned char yt,unsigned char att,unsigned char locate)
{
unsigned int x;
for(x=x0;x<=xt;x++)
{
Linexy(x,y0,x,yt,att,locate);
}
}
void black_2( unsigned int x0,unsigned char y0,unsigned int length,unsigned char width,unsigned char att,unsigned char locate)
{
unsigned int xt;
unsigned char yt;
xt=x0+length;
yt=y0+width;
black(x0,y0,xt,yt,att,locate);
}
void PutWord8(unsigned int x,unsigned char y,unsigned char* index,unsigned char number,unsigned char locate)
{
unsigned char i;
for (i=0;i<number;i++)
{
PutCdotInGraph( x+i,y,*(index+i),8,locate);
}
}
void PutWord8_2(unsigned int x,unsigned char y,unsigned char* index,unsigned char number,unsigned char locate)
{
unsigned char i;
for (i=0;i<number;i++)
{
PutCdotInGraph_2( x+i,y,*(index+i),8,locate);
}
}
void PutWord12(unsigned int x,unsigned char y,unsigned char* index,unsigned char number,unsigned char locate)
{
unsigned char i;
for (i=0;i<number;i++)
{
PutCdotInGraph( x+i*2,y,*(index+i),12,locate);
}
}
void PutWord16_eep(unsigned int x,unsigned char y,unsigned char* index,unsigned char number,unsigned char locate)
{
unsigned char i;
for (i=0;i<number;i++)
{
PutCdotInGraph3( x+i*2,y,*(index+i),16,locate);
}
}
void PutWord16(unsigned int x,unsigned char y,unsigned char* index,unsigned char number,unsigned char locate)
{
unsigned char i;
for (i=0;i<number;i++)
{
PutCdotInGraph( x+i*2,y,*(index+i),16,locate);
}
}
void PutWord16_2(unsigned int x,unsigned char y,unsigned char* index,unsigned char number,unsigned char locate)
{
unsigned char i;
for (i=0;i<number;i++)
{
PutCdotInGraph_2( x+i*2,y,*(index+i),16,locate);
}
}
void PutWord24InGraph(void)
{
//x坐标以半个汉字定位左起0开始计算
//y坐标以像素行定位,顶部0开始计算
//汉字码以点阵码列表所对应32字节位单位进界,从0开始计算
unsigned char i;
for (i=0;i<4;i++)
{
//PutCdotInGraph( 1+i*2,7,i,16);
}
}
//---------------------------
// 写参数及显示数据子程序
void WriteData( unsigned char dataW )
{
*LcmWdataPort = dataW;
}
// 判忙标志BF子程序pr0
void WaitForBusy( void )
{
while ( *LcmStatusPort & Busy );
}
//---------------------------
// 写指令代码子程序pr1
void WriteCommand( unsigned char CommandByte )
{
*LcmCmdPort = CommandByte;
}
//---------------------------
// 读参数及显示数据子程序
unsigned char ReadDataLcm(void)
{
return *LcmRdataPort;
}
/*======================== 清显示 32K RAM区(清屏)子程序 ======================*/
void LcmClear( void )
{
unsigned int i1=9600;
WriteCommand( Ovlay ); // 显示合成方式设置
WriteData( 0x04 ); // 0000 0100 显示图形文本,三区文本属性,二重"或"合成
WriteCommand( DispOn ); // 写入指令代码
WriteData( 0x54 );
WriteCommand( CsrDirR ); // 光标移动方向定义:自动右移
WriteCommand( CsrW ); // 光标Locate,定位
WriteData( 0 ); // 写入参数CSRL设置参数光标指针低8位
WriteData( 0 ); // 写入参数CSRH设置参数光标指针高8位
WriteCommand( mWrite ); // 数据写入指令,代码0x42
while(i1--)
{
WriteData( 0x00); // 写入数据0
}
i1=9600;
WriteCommand( CsrDirR ); // 光标移动方向定义:自动右移
WriteCommand( CsrW ); // 光标Locate,定位
WriteData( 0 ); // 写入参数CSRL设置参数光标指针低8位
WriteData( 0+BasePart2 ); // 写入参数CSRH设置参数光标指针高8位
WriteCommand( mWrite ); // 数据写入指令,代码0x42
while(i1--)
{
WriteData( 0x00); // 写入数据0
}
i1=9600;
WriteCommand( CsrDirR ); // 光标移动方向定义:自动右移
WriteCommand( CsrW ); // 光标Locate,定位
WriteData( 0 ); // 写入参数CSRL设置参数光标指针低8位
WriteData( 0+BasePart3 ); // 写入参数CSRH设置参数光标指针高8位
WriteCommand( mWrite ); // 数据写入指令,代码0x42
while(i1--)
{
WriteData( 0x00); // 写入数据0
}
}
/*======================== 清显示 1 RAM区(清屏)子程序 ======================*/
void LcmClear0( void )
{
unsigned int i1=9600;
//WriteCommand( Ovlay ); // 显示合成方式设置
//WriteData( 0x04 ); // 0000 0100 显示图形文本,三区文本属性,二重"或"合成
//WriteCommand( DispOn ); // 写入指令代码
//WriteData( 0x56 );
WriteCommand( CsrDirR ); // 光标移动方向定义:自动右移
WriteCommand( CsrW ); // 光标Locate,定位
WriteData( 0 ); // 写入参数CSRL设置参数光标指针低8位
WriteData( 0 ); // 写入参数CSRH设置参数光标指针高8位
WriteCommand( mWrite ); // 数据写入指令,代码0x42
while(i1--)
{
WriteData( 0x00); // 写入数据0
}
/*
i1=9600;
WriteCommand( CsrDirR ); // 光标移动方向定义:自动右移
WriteCommand( CsrW ); // 光标Locate,定位
WriteData( 0 ); // 写入参数CSRL设置参数光标指针低8位
WriteData( 0+BasePart2 ); // 写入参数CSRH设置参数光标指针高8位
WriteCommand( mWrite ); // 数据写入指令,代码0x42
while(i1--) {
WriteData( 0x00); // 写入数据0
}
i1=9600;
WriteCommand( CsrDirR ); // 光标移动方向定义:自动右移
WriteCommand( CsrW ); // 光标Locate,定位
WriteData( 0 ); // 写入参数CSRL设置参数光标指针低8位
WriteData( 0+BasePart3 ); // 写入参数CSRH设置参数光标指针高8位
WriteCommand( mWrite ); // 数据写入指令,代码0x42
while(i1--) {
WriteData( 0x00); // 写入数据0
}
*/
}
/*======================== 清显示 2 RAM区(清屏)子程序 ======================*/
void LcmClear1( void )
{
unsigned int i1=9600;
//WriteCommand( Ovlay ); // 显示合成方式设置
//WriteData( 0x04 ); // 0000 0100 显示图形文本,三区文本属性,二重"或"合成
//WriteCommand( DispOn ); // 写入指令代码
//WriteData( 0x56 );
WriteCommand( CsrDirR ); // 光标移动方向定义:自动右移
WriteCommand( CsrW ); // 光标Locate,定位
WriteData( 0 ); // 写入参数CSRL设置参数光标指针低8位
WriteData( 0+BasePart2 ); // 写入参数CSRH设置参数光标指针高8位
WriteCommand( mWrite ); // 数据写入指令,代码0x42
while(i1--)
{
WriteData( 0x00); // 写入数据0
}
/*
i1=9600;
WriteCommand( CsrDirR ); // 光标移动方向定义:自动右移
WriteCommand( CsrW ); // 光标Locate,定位
WriteData( 0 ); // 写入参数CSRL设置参数光标指针低8位
WriteData( 0+BasePart2 ); // 写入参数CSRH设置参数光标指针高8位
WriteCommand( mWrite ); // 数据写入指令,代码0x42
while(i1--) {
WriteData( 0x00); // 写入数据0
}
i1=9600;
WriteCommand( CsrDirR ); // 光标移动方向定义:自动右移
WriteCommand( CsrW ); // 光标Locate,定位
WriteData( 0 ); // 写入参数CSRL设置参数光标指针低8位
WriteData( 0+BasePart3 ); // 写入参数CSRH设置参数光标指针高8位
WriteCommand( mWrite ); // 数据写入指令,代码0x42
while(i1--) {
WriteData( 0x00); // 写入数据0
}
*/
}
/*====================================================
; 绘点子程序,携入参数X坐标的最高位决定写或擦点
====================================================*/
void Point(unsigned int Px, unsigned char Py, unsigned char attr,unsigned char locate )
{
//unsigned int i;
unsigned int tempPtr;
unsigned char tempD,tempP;
tempD=0;
tempP=0;
tempPtr = (unsigned int)Py * paraP9 + (Px & 0x7fff)/8+locate*0x4000; // 去除最高位(显示属性)
//WriteCommand( DispOn ); // 写入指令代码
//WriteData( 0x56 ); // 显示 1~4 区开显示,光标显示FR/32闪烁
WriteCommand( CsrDirR ); // CSRDIR 代码(光标自动下移)
WriteCommand( CsrW ); // 设置光标地址
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -