📄 lcd.c
字号:
/****************************************************************************
File Name:lcd.c
Version:
Discription:
Author:
Date:
*****************************************************************************/
#include "key_display.h"
unsigned char lcd_byte = 0;//LC75823E的显示缓冲区中的byte计数
unsigned char lcd_bit = 0;//LC75823E的显示缓冲区中一个byte的bit计数
unsigned char lcd_cnt = 0;//用于全屏显示计数
bit vfd_flag = 0;//更新显示标志
typedef unsigned char BYTE;
BYTE disp_buff[SHADOW_LENGTH];//LC75823E的20byte的显示缓冲区
//下面的数组用于传送数据的每一个bit//
BYTE code Byte_Bit_Mask[8] = { /* Define the byte mark bit */
0x01, 0x02, 0x04, 0x08,
0x10, 0x20, 0x40, 0x80
};
/***************************************************************************************
* 函数名称:LCDDelay()
* 功 能:
* 输入参数:
* 输出参数:
* 说 明:
****************************************************************************************/
void LCDDelay(unsigned char n)
{
while(n--)
{
_nop_();
_nop_();
}
}
/***************************************************************************************
* 函数名称:VFD_Refresh()
* 功 能:更新显示函数,每一次都要发送CCB地址、20byte的数据与控制位
* 输入参数:
* 输出参数:
* 说 明:
****************************************************************************************/
void VFD_Refresh( void )
{
BYTE i,j;
BYTE TxData;
if(vfd_flag == 1)
{
vfd_flag = 0;
disp_buff[19] &= 0x0f; // clear the high-nibble
disp_buff[19] |= 0x10; // set it.(the high-nibble is the control nibble)
/* Send CCB address 41H */
FP_CE = 0;
TxData = 0x41;
for (i=0; i<8; i++)
{
FP_CLK = 0;
if (TxData & Byte_Bit_Mask[i])
{
FP_DAT = 1;
}
else
{
FP_DAT = 0;
}
LCDDelay(1);
FP_CLK = 1;
LCDDelay(1);
}
FP_CE = 1;
/* Send display data */
for (i=0; i<20; i++)
{
TxData = disp_buff[i];
for (j=0; j<8; j++)
{
FP_CLK = 0;
if (TxData & Byte_Bit_Mask[j])
{
FP_DAT = 1;
}
else
{
FP_DAT = 0;
}
LCDDelay(1);
FP_CLK = 1;
LCDDelay(1);
}
}
FP_CE = 0;
FP_DAT = 1;
FP_CLK = 1;
}
}
/***************************************************************************************
* 函数名称:test_lcd()
* 功 能:函数设置三个按键:KEY_NEXT用于显示下一个字段;KEY_PREV用于显示上一个字段
KEY_P_P用于恢复初始显示的字段;当前显示字段以闪烁形式显示
* 输入参数:
* 输出参数:
* 说 明:
****************************************************************************************/
void test_lcd(void)
{
unsigned char glb_InputKey;
glb_InputKey = get_msg();
for (lcd_cnt=0; lcd_cnt<SHADOW_LENGTH; lcd_cnt++) //全屏显示
{
disp_buff[lcd_cnt] = 0xff;
}
if ((glb_InputKey == KEY_NEXT) || (glb_InputKey == KEY_PREV)||(glb_InputKey == KEY_P_P))
{
if (glb_InputKey == KEY_NEXT) //显示下一个点
{
lcd_bit++;
if (lcd_bit > 7)
{
lcd_bit = 0;
lcd_byte++;
if (lcd_byte >= SHADOW_LENGTH) lcd_byte = 0;
}
}
if(glb_InputKey == KEY_PREV)//显示上一个点
{
if (lcd_bit) lcd_bit--;
else
{
lcd_bit = 7;
if (lcd_byte) lcd_byte--;
else
{
lcd_byte = SHADOW_LENGTH-1;
}
}
}
if(glb_InputKey == KEY_P_P)//恢复起始点
{
lcd_bit = 0;
lcd_byte = 0;
}
disp_buff[lcd_byte] |= (1<<lcd_bit);//显示当前字段
vfd_flag = 1;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -