⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 splc501c.c

📁 测试STN LCM产品
💻 C
字号:
// Function for setting Column Address
void SetCA(uint8 CAddr)
{
	// CAddr's range is from 0 to LCD_CMAX
	//CAddr += 4;
	SendByte(iCmd, (CAddr >> 4) | 0x10);
	SendByte(iCmd, CAddr & 0x0F);
}

// Function for setting Page Address
void SetPA(uint8 PAddr)
{
	//PAddr's range is from 0 to LCD_PMAX
	SendByte(iCmd, LCD_P0 + PAddr);
}

// Goto xPage and yColumn
void Gotoxy(uint8 PAddr, CAddr)
{
	SetPA(PAddr);
	SetCA(CAddr);
}

// Function for setting Contrast
void SetContrast(uint8 CValue)
{
	// CValue <64
	SendByte(iCmd, 0x81);
	SendByte(iCmd, CValue);
}

#ifdef LCD_ICOMAX
	// Set LCD specific Icon ON/OFF
	void SetIcon(uint8 State, uint8 index)
	{
		Gotoxy(7, ICONS[index]);
		//Gotoxy(7, (131 - ICONS[index]));	// For Reversed Segments
		SendByte(iDat, State);
	}
	
	// Turn On/Off all icons
	void Allicons(bit State)
	{
		uint8 i;
		for (i = 0; i < LCD_ICOMAX; i++)
		{
			if (State)
				SetIcon(0xFF, i);
			else
				SetIcon(0x00, i);
		}
	}
	
	// Display each Icon and then hide them one by one
	void ICON_Test(void)
	{
		uint8 i;
		//Allicons(1);
		//delay1s();
		//Allicons(0);
		//delay1s();
		for (i = 0; i < 2*LCD_ICOMAX; i++)
		{
			if (i < LCD_ICOMAX)
			{
				SetIcon(0xFF, i);
			}
			else
			{
				SetIcon(0x00, i - LCD_ICOMAX);
			}
			DelayMs(50);
		}
		DelayMs(500);
	}
#endif

// Fill Page X with 2 datas
void FillPage(uint8 PAddr, uint8 fst, snd)
{
	uint8 i;
	Gotoxy(PAddr, 0);
	for (i = 0; i < LCD_CMAX/2; i++)
	{
		SendByte(iDat, fst);
		SendByte(iDat, snd);
	}
}

// Tile LCD screen with two datas
void Tile(uint8 fst, uint8 snd)
{
	uint8 i;
	//SendByte(iCmd, LCD_OFF);
	for (i = 0; i < LCD_PMAX; i++)
	{
		FillPage(i, fst, snd);
	}
	//SendByte(iCmd, LCD_ON);
}

// Clear LCD screen
void LCD_CLS(void)
{
	Tile(0x00, 0x00);
	DelayMs(5);
}

// Wait some time and Clear the screen
void wait_and_clear(void)
{
	DelayMs(1300);
	LCD_CLS();
}

// Function for initializing LCD
void LCD_Initial(void)
{
	PortConfig();
	LCD_Reset();
	
	SendByte(iCmd, LCD_ADC);	// Set ADC
	SendByte(iCmd, LCD_SHL);	// Set SHL
	SendByte(iCmd, 0xA2);		// Set LCD Bias Ratio
	
	SendByte(iCmd, 0x2C);	// Begin LCD Power Control Setting
	DelayMs(10);
	SendByte(iCmd, 0x2E);	// ... ... ...
	DelayMs(10);
	SendByte(iCmd, 0x2F);	// End LCD Power Control Setting
	
	SendByte(iCmd, 0x27);	
	//SetContrast(25);		// Vop = 11V for EG128064C-X
	SetContrast(15);		// Vop = 10V for EG32064M
	
	SendByte(iCmd, 0xD2);	// Set LCD Driving Mode
	SendByte(iCmd, 0xC0);
	// D[7:6] = 0xC0/0x00/0x40/0x80
	// High ---> Low
	
	LCD_CLS();
	SendByte(iCmd, LCD_ON);
}

⌨️ 快捷键说明

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