lcdop.c

来自「程序实现LC75823驱动」· C语言 代码 · 共 98 行

C
98
字号
#define _LCD_INCLUDE
#include "include.h"

//=======================Pin Define==========================
sbit LcdCL = P1^0;
sbit LcdDI = P1^1;
sbit LcdCE = P1^2;

code BYTE CCBADDR[]={0x41};
code BYTE StrDispOther[]={0x00,0x00,0x00,0x00,0x00};//remains 5 bytes inclued DR SC BU
code WORD StrDisp[]={0x6301,0x6000,0x4718,0x1234,0x2345,//0~4
						0x0000,0x6000,0x4718,0x1234,0x2345,//5~9
						0x0000,0x6000,0x4718,0x1234,0x2345,//A~E
						0x0000,0x6000,0x4718,0x1234,0x2345,//F~J
						0x0000,0x6000,0x4718,0x1234,0x2345,//K~O
						0x0000,0x6000,0x4718,0x1234,0x2345,//P~T
						0x0000,0x6000,0x4718,0x1234,0x2345,//U~Y
						0x2345};//Z
						
WORD *DispDataPstr = StrDisp;	
//====================================================
void LcdSendOneByte(BYTE Data)
{
	BYTE DataBit;

	for (DataBit = 0; DataBit < 8; DataBit++)
	{
		LcdCL = 0;
		if (Data & 0x01) //LSB send first
			LcdDI = 1;
		else
			LcdDI = 0;
		LcdCL = 1;
		Data >>= 1;
	}
}

void LcdSend15Bits(WORD Data)
{
	BYTE DataBit;

	for (DataBit = 0; DataBit < 15; DataBit++)
	{
		LcdCL = 0;
		if (Data & 0x01) //LSB send first
			LcdDI = 1;
		else
			LcdDI = 0;
		LcdCL = 1;
		Data >>= 1;
	}
}

void LcdDisplay(WORD *DataPstr)
{
	BYTE ByteCount, *StrDataPstr;

	//CCBADDR = 0x41
	LcdSendOneByte(*CCBADDR);

	//send data display	
	LcdCE = 1; //enable Lcd chip
	for (ByteCount = 0; ByteCount < 8; ByteCount++)
	{
		LcdSend15Bits(*DataPstr);
		DataPstr++;
		if (DataPstr > StrDisp + 35)		//0 will behind the z
			DataPstr = StrDisp; 			
	}

	//send others include DR SC BU
	StrDataPstr = StrDispOther;
	for (ByteCount = 0; ByteCount < sizeof(StrDispOther); ByteCount++)
	{
		LcdSendOneByte(*StrDataPstr);
		DataPstr++;
	}	

	LcdCE = 0; //disable Lcd chip
}

void LcdRollOver(BYTE RollFlag)
{
	LcdDisplay(DispDataPstr);
	if (RollFlag == LEFT)
	{
		DispDataPstr++;
		if (DispDataPstr > StrDisp + 35)
			DispDataPstr = StrDisp;
	}
	else
	{
		DispDataPstr--;
		if (DispDataPstr < StrDisp)
			DispDataPstr = StrDisp + 35;
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?