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

📄 ht0610.c

📁 笔段型TN LCM测试
💻 C
字号:
// Functions for HT0610
// Function for setting Column Address
void SetCA(uint8 CAddr)
{
	SendByte(iCmd, 0x80 + CAddr);
}

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

// Goto specific position
void Gotoxy(uint8 page, uint8 col)
{
	SetPA(page);
	SetCA(col);
}

#ifdef LCD_8BIT
// Read a data from LCD DDRAM
uint8 ReadData(uint8 PAddr, uint8 CAddr)
{
	uint8 dByte;
	Gotoxy(PAddr, CAddr);
	LCD_DataPort = 0xFF;	// Set the port as input
	LCD_CS = 1;
	LCD_A0 = iDat;
	#ifdef MCU_6800
		LCD_RW = 1;
		LCD_E  = 1;
		//DelayUs(50);
		dByte = LCD_DataPort;	// Actual read
		LCD_E  = 0;
	#else
		LCD_WR = 1;
		LCD_RD = 0;
		//DelayUs(4);			// A dummy read
		LCD_RD = 1;
		//DelayUs(4);
		LCD_RD = 0;
		//DelayUs(4);
		dByte = LCD_DataPort;	// Actual read
		LCD_RD = 1;
	#endif
	LCD_CS = 0;
	return dByte;
}

// Reverse display of Page PAddr
void ReversePage(uint8 PAddr)
{
	uint8 col, Original;
	for (col = 0; col < LCD_CMAX; col++)
	{
		Original = ReadData(PAddr, col);
		SetCA(col);
		SendByte(iDat, ~Original);
	}
}
#endif
// Function for setting Contrast
void SetContrast(uint8 CValue)
{
	// CValue < 16
	SendByte(iCmd, 0x10 + CValue);
}

#ifdef LCD_ICOMAX
	// Set LCD specific Icon ON/OFF
	void SetIcon(uint8 State, uint8 index)
	{
		SetPA(4);	// Goto Icon Page
		SetCA(ICONS[index]);
		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);
			}
			delay100ms();
		}
		delay500ms();
	}
#endif

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

// Clear LCD screen
void Clear(void)
{
	//Tile(0x00, 0x00);
	SendByte(iCmd, 0x36);	// Clear Master BGDRAM(P1~P4)
	SendByte(iDat, 0x00);	// Dummy Write
	//SendByte(iCmd, 0x37);	// Clear Master Icon Page(P5)
	//DelayMs(2);
}

// Clear page X
void ClearPage(uint8 PAddr)
{
	uint8 Col = LCD_CMAX;
	Gotoxy(PAddr, 0);
	while(Col-- != 0)
	{
		SendByte(iDat, 0x00);
		//delay100ms();
	}
	SetCA(0);
}

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

// Function for initializing LCD
void LCD_Initial(void)
{
	//PortConfig();	
	LCD_Reset();
	SendByte(iCmd, 0x33);		// Set clock freq.(0x33: 50KHz; 0x32: 38.4KHz)
	SendByte(iCmd, 0x7A);		// Select Oscillator(0x7A: INT; 0x7B: EXT)	
	SendByte(iCmd, 0x7F);		// Start internal OSC
	DelayMs(50);
	
	SendByte(iCmd, 0x3D);		// Enable ICON line(0x3D: enable; 0x3C: disable)
	SendByte(iCmd, 0x68);		// Set LCD Duty Cycle(0x68: 1/32; 0x69: 1/16)
	SendByte(iCmd, 0x38);		// Set LCD Bias(0x38: 1/7 0x39: 1/5)
	SendByte(iCmd, 0x2B);		// Turn on DC/DC converter
	DelayMs(100);
	SendByte(iCmd, 0x2D);		// Turn on internal Regulator
	DelayMs(100);
	SendByte(iCmd, 0x2F);		// Turn on internal voltage divider
	DelayMs(100);
	
	SendByte(iCmd, 0x6D);		// Temperature coefficient(0x6D: -0.18%)
	SendByte(iCmd, 0x31);		// Turn on internal contrast control
	DelayMs(100);
	SendByte(iCmd, 0x20);		// Set Booster(0x20: 3x; 0x21: 2x)
	DelayMs(100);
	SetContrast(15);			// Vop should be set to 9.0V for EG120032C
	
	
	SendByte(iCmd, LCD_ADC);	// Set ADC
	SendByte(iCmd, LCD_SHL);	// Set SHL
	SendByte(iCmd, 0x6A);		// IDD Mode (0x6A: inc; 0x6B: dec)
	
	Clear();
	SendByte(iCmd, LCD_ON);
}

// Display LCD Test Graphics
void LCD_Test(void)
{
	uint8 i;
	uint8 code TestData[][2] =
	{
		// Standard graphics for LCD Testing
		{0xFF,0xFF},	// 1. All
		{0x00,0x00},	// 2. None	
		{0xFF,0x00},	// 3. Virtical 1
		{0x00,0xFF},	// 4. Virtical 2
		{0xAA,0xAA},	// 5. Horizontal 1
		{0x55,0x55},	// 6. Horizontal 2
		{0xAA,0x55},	// 7. Stars 2
		{0x55,0xAA},	// 8. Stars 2
	};
	for (i = 0; i < 8; i++)
	{
		Tile(TestData[i][0], TestData[i][1]);
		wait_and_clear();
	}
	/*
	#ifdef LCD_ICOMAX
		ICON_Test();
	#endif
	*/
}

⌨️ 快捷键说明

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