?? tl0324.c
字號:
// Functions written for TL0324
#include "delay.h"
// Function for sending a byte to LCD
void SendByte(bit DatCmd, uint8 dByte)
{
#ifdef LCD_8BIT
LCD_DataPort = 0x00; // Set the port as input
CS = 0;
A0 = DatCmd;
RW = 0;
E = 1;
LCD_DataPort = dByte;
//delay4us();
E = 0;
CS = 1;
#elif defined(LCD_4SPI)
uint8 i;
LCD_DataPort = 0x00; // Set the port as input
CS = 0;
A0 = DatCmd;
for (i = 0; i < 8; i++)
{
SCK = 0;
SID = (dByte<<i) & 0x80;
//delay4us();
SCK = 1;
}
CS = 1;
#endif
}
// Function for setting Column Address
void SetCA(uint8 CAddr)
{
//CAddr's range is from 0 to LCD_CMAX
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);
}
// Read a data from LCD DDRAM
uint8 ReadData(uint8 PAddr, uint8 CAddr)
{
uint8 dByte;
SetPA(PAddr);
SetCA(CAddr);
LCD_DataPort = 0xFF; // Set the port as input
CS = 0;
A0 = iDat;
RW = 1;
E = 1;
//delay4us(); // A dummy read
E = 0;
//delay4us();
E = 1;
//delay4us();
dByte = LCD_DataPort; // Actual read
E = 0;
CS = 1;
return dByte;
}
// 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)
{
SetPA(LCD_PMAX);
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++)
{
SetPA(i);
SetCA(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);
delay4us();
}
// Function for initializing LCD
void LCD_Initial (void)
{
RST = 0;
UsTime(8);
RST = 1;
SendByte(iCmd, LCD_ADC); // Set ADC
SendByte(iCmd, LCD_SHL); // Set SHL
SendByte(iCmd, LCD_BIAS); // Set LCD power supply Bias Ratio
SendByte(iCmd, 0x2C); // Start LCD Power Control Setting
DelayUs(1000);
SendByte(iCmd, 0x2E); // ... ... ...
DelayUs(1000);
SendByte(iCmd, 0x2F); // End LCD Power Control Setting
SendByte(iCmd, LCD_REG);
SetContrast(35);
SendByte(iCmd, LCD_ON);
Clear();
}
// Display LCD Test Graphics
void LCD_Test(void)
{
uint8 i;
for (i=0; i<8; i++)
{
/*
if ((i == 4)||(i == 5))
SetContrast(36);
else
SetContrast(17);
*/
Tile(TestData[i][0], TestData[i][1]);
delay1s();
Clear();
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -