📄 lcd_func.c
字号:
#include <sp6608.h>
#include <Lcd_C.h>
void Init_IOA(void)
{
REG(P_IOA_Dir) = 0xff;
REG(P_IOA_Buf) = 0x00;
REG(P_IOA_Data) = 0x00;
}
void BackLight_Init(void)
{
REG(P_IOA_Dir) = REG(P_IOA_Dir)|BLA_Ctr_Mask ; //output
}
void BackLight_On(void)
{
REG(P_IOA_Data) = REG(P_IOA_Buf)|BLA_Ctr_Mask ;
}
void BackLight_Off(void)
{
REG(P_IOA_Data) = REG(P_IOA_Buf)&(~BLA_Ctr_Mask) ;
}
void Lcd_Reset_Init(void)
{
REG(P_IOA_Dir) = REG(P_IOA_Dir)|Lcd_Reset_Mask; //output
REG(P_IOA_Data) = REG(P_IOA_Buf)|Lcd_Reset_Mask; //set this IO high
}
void Lcd_Reset(void)
{
REG(P_IOA_Data) = REG(P_IOA_Buf)&(~Lcd_Reset_Mask);
Lcd_A_DelayBusTime();
Lcd_A_DelayBusTime();
REG(P_IOA_Data) = REG(P_IOA_Buf)|Lcd_Reset_Mask;
}
void Lcd_OutI(byte c)
{
*(volatile unsigned int*)P_Lcd501Ctrl = (0x0a00|(c&0x00ff));
}
void Lcd_OutD(byte c)
{
*(volatile unsigned int*)P_Lcd501Ctrl = (0x0e00|(c&0x00ff));
}
void Lcd_WaitCmd(void)
{
byte i;
for(i=0;i<20;i++)
{}
}
void Lcd_DiaplayOn(void)
{
Lcd_OutI(0xaf); //dispaly on
Lcd_WaitCmd();
}
void Lcd_DiaplayOff(void)
{
Lcd_OutI(0xae); //dispaly off
Lcd_WaitCmd();
}
void Lcd_Init(void)
{
BackLight_Init();
Lcd_Reset_Init();
/*
MSET0(g_LcdData);
g_LcdData.m_nFlag.IN_REVERSE =0;
g_LcdData.m_nFlag.FOUR_LINE =0;
g_LcdData.m_nFlag.ASC_6X12 =0;
g_LcdData.m_nFlag.HZ_DOT =0;
*/
//Lcd_A_Init_IC(); //LCD 初始化
//0001-Select 6800 MPU interface 0000-Select 8080 MPU interface
Lcd_Reset();
*(volatile unsigned int*)(P_Lcd501BdySelect) =0x0001;
Lcd_WaitCmd();
// [0x0Ae2] 复位 初始化显示起始行、起始列地址、起始页地址、正常输出模式。
// 结束读/改/写模式和测试模式。此命令不影响显示RAM中的数据
/* Lcd_OutI(0xe2); //internal reset
Lcd_WaitCmd();
Lcd_OutI(0xae); //dispaly off
Lcd_WaitCmd();
Lcd_OutI(0xa0); //ADC select RAM address
Lcd_WaitCmd();
Lcd_OutI(0xc0); //common output mode select
Lcd_WaitCmd();
Lcd_OutI(0xa6); //diplay normal ,a7 reverse
Lcd_WaitCmd();
Lcd_OutI(0xa4); //normal display
Lcd_WaitCmd();
Lcd_OutI(0xa2); //Lcd bias set 1/9
Lcd_WaitCmd();
Lcd_OutI(0x2f); // power control set
Lcd_WaitCmd();
Lcd_OutI(0xf8); // booster ratio set
Lcd_WaitCmd();
Lcd_OutI(0x00); //select booster ratio
Lcd_WaitCmd();
Lcd_OutI(0x81); //electronic volume mode set
Lcd_WaitCmd();
Lcd_OutI(0x2f); //electronic volume register set
Lcd_WaitCmd();
Lcd_OutI(0xaf); //dispaly on
Lcd_WaitCmd();
Lcd_OutI(0xae); //dispaly off
Lcd_WaitCmd();
Lcd_OutI(0xb0); //set page address
Lcd_WaitCmd();
Lcd_OutI(0x40); //set the start line
Lcd_WaitCmd();
Lcd_OutI(0x10); //set Column address msb
Lcd_WaitCmd();
Lcd_OutI(0x00); //set Column address lsb
Lcd_WaitCmd();
Lcd_OutI(0xa5); //all points on
Lcd_WaitCmd();
Lcd_OutI(0xa4); //normal display
Lcd_WaitCmd();
*/
Lcd_OutI(0xA2); //internal reset
Lcd_WaitCmd();
Lcd_OutI(0xe2);
Lcd_WaitCmd();
Lcd_OutI(0xA0);
Lcd_WaitCmd();
Lcd_OutI(0xC8);
Lcd_WaitCmd();
Lcd_OutI(0x2f);
Lcd_WaitCmd();
Lcd_OutI(0x81);
Lcd_WaitCmd();
Lcd_OutI(0x16);
Lcd_WaitCmd();
Lcd_OutI(0xAF);
Lcd_WaitCmd();
Lcd_OutI(0x60);
Lcd_WaitCmd();
//wom12864e17对比度最佳值在0x10~0x23之间
/* if(g_Par_data.m_Contrast>63||g_Par_data.m_Contrast<25)
g_Par_data.m_Contrast=40;//防止调整的对比度过大
Lcd_A_Set_Contrast(g_Par_data.m_Contrast);
Lcd_Clr_Icon();//clr icon
//Lcd_Disp_Bmp((char *)bmp_vol,3,16,16,8);
Lcd_Clr();
*/
}
void Lcd_Set_Page(byte PageNo)
{
PageNo = PageNo & 0x0f;
if(PageNo >=4)
{
PageNo = PageNo - 4;
Lcd_OutI(0xb0|PageNo);
Lcd_WaitCmd();
}
else
{
PageNo = PageNo + 4;
Lcd_OutI(0xb0|PageNo);
Lcd_WaitCmd();
}
}
void Lcd_Set_Col(byte ColNo)
{
byte temp;
temp = ColNo;
ColNo =( temp >> 4)&0x0f;
Lcd_OutI(0x10|ColNo);
Lcd_WaitCmd();
ColNo =temp&0x0f;
Lcd_OutI(0x00|ColNo);
Lcd_WaitCmd();
}
void Lcd_Set_PageCol(byte PageNo, byte ColNo)
{
Lcd_Set_Page( PageNo);
Lcd_Set_Col( ColNo);
}
void Lcd_StartLine(byte StartLine)
{
StartLine = StartLine & 0x3f;
Lcd_OutI(0x40|StartLine);
Lcd_WaitCmd();
}
void Lcd_Fill
(byte flag)
{
int i,j;
if(flag == 1)
{
for(i=0; i<8; i++)
{
Lcd_Set_PageCol(i, 0);
for(j=0; j<132; j++)
{
Lcd_OutD(0xff);
Lcd_WaitCmd();
}
}
}
if(flag == 0)
{
for(i=0; i<8; i++)
{
Lcd_Set_PageCol(i, 0);
for(j=0; j<132; j++)
{
Lcd_OutD(0x00);
Lcd_WaitCmd();
}
}
}
}
void Lcd_Set_Contrast(byte ContrastNo)
{
Lcd_OutI(0x81); //electronic volume mode set
Lcd_WaitCmd();
ContrastNo = ContrastNo & 0x3f;
Lcd_OutI(ContrastNo); //electronic volume register set
Lcd_WaitCmd();
}
void Lcd_OutputHZ()
{
int i,j,page;
char temp;
char temp1;
int LcdPage = 0;
int LcdLine = 0;
int Kinstars[6][16]=
{
{0x0410, 0xfc61, 0x0386, 0x0060, 0x4208, 0x8108, 0x7fff, 0x4088,
0x3008, 0x0ffe, 0x0022, 0x0022, 0xffe2, 0x0022, 0x0022, 0x0000}, //浙
{0x0410, 0x0460, 0x7e01, 0x01c6, 0x2030, 0x2000, 0x2004, 0x2004,
0x2004, 0x3ffc, 0x2004, 0x2004, 0x2004, 0x2004, 0x2000, 0x0000}, //江
{0x4040, 0x4040, 0x4220, 0x4220, 0x4a50, 0x7248, 0x4244, 0x7fc3,
0x4244, 0x6248, 0x5a50, 0x4250, 0x4220, 0x4060, 0x4020, 0x0000},
{0x0020, 0x8020, 0x4020, 0x2020, 0x1020, 0x0c20, 0x03a0, 0x007f,
0x01a0, 0x0620, 0x0820, 0x3020, 0x6020, 0xc020, 0x4020, 0x0000},
{0x0410, 0x0212, 0x0192, 0x0072, 0xfffe, 0x0051, 0x0491, 0x0400,
0x0422, 0x02cc, 0x0200, 0x0200, 0xffff, 0x0100, 0x0100, 0x0000},
{0x0108, 0x4108, 0x8088, 0x7fff, 0x0048, 0x4028, 0x4000, 0x20c8,
0x1348, 0x0c48, 0x0c7f, 0x1248, 0x21c8, 0x6048, 0x2008, 0x0000}
};
// Set_CS1(1);
// Set_CS2(1);
// LcdChip_Sel(1);
for(page=0; page<8; page +=2)
{
for(i=0; i<6; i++)
{
Lcd_Set_PageCol(page,LcdLine);
for(j=0; j<16; j++)
{
temp = Kinstars[i][j] & 0x00ff;
// WriteData(Font_Change(temp));
// temp1 = Font_Change(temp);
Lcd_OutD(temp);
}
Lcd_Set_PageCol(page+1,LcdLine);
for(j=0; j<16; j++)
{
temp = (Kinstars[i][j] >> 8) & 0x00ff;
// temp1 = Font_Change(temp);
Lcd_OutD(temp);
}
LcdLine += 16;
}
LcdLine = 0;
}
}
void Lcd_GuiYin(void)
{
int i,j;
// LcdChip_Sel(3);
//Lcd_Set_PageCol();
for(i=0; i<6; i++)
{
Lcd_Set_PageCol(i,64);
for(j=0; j<32; j++)
{
Lcd_OutD(0xff);
}
}
for(i=7; i<8; i++)
{
Lcd_Set_PageCol(i,64);
for(j=0; j<32; j++)
{
Lcd_OutD(0xff);
}
}
// LcdChip_Sel(2);
for(i=0; i<8; i++)
{
Lcd_Set_PageCol(i,96);
for(j=0; j<10; j++)
{
Lcd_OutD(0xff);
}
}
for(i=0; i<8; i++)
{
Lcd_Set_PageCol(i,115);
for(j=0; j<14; j++)
{
Lcd_OutD(0xff);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -