📄 l.c
字号:
#include "Board.h"
#include "lcd.h"
//======================================================
extern unsigned char idata DisplayBuffer[16];
//======================================================
code unsigned char DisplayDecode[16]=
{
0xFC, //0
0x60, //1
0xDA, //2
0xF2, //3
0x66, //4
0xB6, //5
0xBE, //6
0xE0, //7
0xFE, //8
0xF6, //9
0xEE, //A
0x3E, //b
0x9C, //C
0x7A, //d
0x9E, //E
0x8E, //F
};
code unsigned char ManLog[16]=
{
0xFC, //0
0xFC, //0
0x61, //1.
0x38, //v
0xFC, //0
0xFC, //0
0x66, //4
0x02, //-
0x9E, //E
0x4E, //Y
0xCF, //P.
0x0A, //r
0x3A, //o
0x9C, //C
0x9F, //E.
0x1D, //L.
};
//======================================================
void LCD_TransRAM(void)
{
unsigned char idata bTmp;
MCU_DLD=1;
for (bTmp=0;bTmp<16;bTmp++) {
LCD_TransByte(DisplayBuffer[bTmp]);
}
MCU_DLD=0;
return;
}
void LCD_TransByte(unsigned char bData)
{
unsigned char idata bCt;
for (bCt=0;bCt<8;bCt++) {
MCU_DCLK=1;
if ( bData&0x01 ) {
MCU_DDAT = 1;
}
else {
MCU_DDAT = 0;
}
bData=bData>>1;
MCU_DCLK=0;
}
return;
}
void LCD_DisplayNumber(void)
{
unsigned char idata u;
MCU_DLD=1;
for (u=0;u<16;u++) {
if (DisplayBuffer[u]&0x80) {
LCD_TransByte(DisplayDecode[DisplayBuffer[u]&0x0F]|0x01); //小数点
}
else {
LCD_TransByte(DisplayDecode[DisplayBuffer[u]&0x0F]);
}
}
MCU_DLD=0;
return;
}
void LCD_DisplayString(unsigned char code *bStr)
{
unsigned char idata u;
MCU_DLD=1;
for (u=0;u<16;u++) {
LCD_TransByte(bStr[u]);
}
MCU_DLD=0;
return;
}
void LCD_DisplayError(unsigned char bErr)
{
unsigned char idata u,bTmp;
MCU_DLD=1;
if(bErr>99){
bErr=99;
}
bTmp=((bErr/10)<<4)|(bErr%10);
LCD_TransByte(DisplayDecode[bTmp&0x0F]);
LCD_TransByte(DisplayDecode[(bTmp>>4)&0x0F] );
LCD_TransByte(0x0B); //r.;
LCD_TransByte(0x9F); //E;
for (u=0;u<12;u++) {
LCD_TransByte(0x00);
}
MCU_DLD=0;
return;
}
void LCD_Clear(void)
{
unsigned char idata u;
MCU_DLD=1;
for (u=0;u<16;u++) {
LCD_TransByte(0);
}
MCU_DLD=0;
return;
}
void LCD_DisplayDirect(void)
{
unsigned char idata u;
MCU_DLD=1;
for (u=0;u<16;u++) {
LCD_TransByte(DisplayBuffer[u]);
}
MCU_DLD=0;
return;
}
void PutHexDisplayCode(unsigned char bNums,unsigned long lData)
{
if (bNums==0) { //第一个数字位置,在显示屏的最下一行,只有4位
DisplayBuffer[3]=DisplayDecode[(lData>>12)&0x0F];
DisplayBuffer[2]=DisplayDecode[(lData>>8)&0x0F];
DisplayBuffer[1]=DisplayDecode[(lData>>4)&0x0F];
DisplayBuffer[0]=DisplayDecode[lData&0x0F];
}
else if (bNums==1) { //第二个数字位置,在显示屏的最上一行,6位
DisplayBuffer[9]=DisplayDecode[(lData>>20)&0x0F];
DisplayBuffer[8]=DisplayDecode[(lData>>16)&0x0F];
DisplayBuffer[7]=DisplayDecode[(lData>>12)&0x0F];
DisplayBuffer[6]=DisplayDecode[(lData>>8)&0x0F];
DisplayBuffer[5]=DisplayDecode[(lData>>4)&0x0F];
DisplayBuffer[4]=DisplayDecode[lData&0x0F];
}
else {
DisplayBuffer[15]=DisplayDecode[(lData>>20)&0x0F];
DisplayBuffer[14]=DisplayDecode[(lData>>16)&0x0F];
DisplayBuffer[13]=DisplayDecode[(lData>>12)&0x0F];
DisplayBuffer[12]=DisplayDecode[(lData>>8)&0x0F];
DisplayBuffer[11]=DisplayDecode[(lData>>4)&0x0F];
DisplayBuffer[10]=DisplayDecode[lData&0x0F];
}
return;
}
void PutDecDisplayCode(unsigned char bNums,unsigned long lData)
{
if (bNums==0) { //第一个数字位置,在显示屏的最下一行,只有4位
if (lData>9999) {
lData=9999;
}
DisplayBuffer[3]=DisplayDecode[(lData/1000)];
DisplayBuffer[2]=DisplayDecode[(lData%1000)/100] | 0x01; //加上小数点
DisplayBuffer[1]=DisplayDecode[(lData%100)/10];
DisplayBuffer[0]=DisplayDecode[lData%10];
}
else if (bNums==1) { //第二个数字位置,在显示屏的最上一行,6位
if (lData>999999) {
lData=999999;
}
DisplayBuffer[9]=DisplayDecode[(lData/100000)];
DisplayBuffer[8]=DisplayDecode[(lData%100000)/10000];
DisplayBuffer[7]=DisplayDecode[(lData%10000)/1000];
DisplayBuffer[6]=DisplayDecode[(lData%1000)/100] | 0x01; //加上小数点
DisplayBuffer[5]=DisplayDecode[(lData%100)/10];
DisplayBuffer[4]=DisplayDecode[lData%10];
}
else {
DisplayBuffer[15]=DisplayDecode[(lData/100000)];
DisplayBuffer[14]=DisplayDecode[(lData%100000)/10000];
DisplayBuffer[13]=DisplayDecode[(lData%10000)/1000];
DisplayBuffer[12]=DisplayDecode[(lData%1000)/100] | 0x01; //加上小数点
DisplayBuffer[11]=DisplayDecode[(lData%100)/10];
DisplayBuffer[10]=DisplayDecode[lData%10];
}
return;
}
void PutStatusCode(unsigned char bStat)
{
DisplayBuffer[3]=0xB6;//"S"
DisplayBuffer[2]=0x8C;//"T"
DisplayBuffer[1]=0x02;//"-"
DisplayBuffer[0]=DisplayDecode[bStat];//显示码
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -