void WriteCOM(BYTE DBL)
{
RSB=0;
CSB=0;
RDB=1;
P0=DBL;
WRB=0;
WRB=1;
RSB=1;
CSB=1;
}
void WriteDAT(BYTE DBL)
{
RSB=1;
CSB=0;
RDB=1;
P0=DBL;
WRB=0;
WRB=1;
RSB=0;
CSB=1;
}
void Initial(void)
{
WriteCOM(0x01); //Software Reset
delayms(150); //delay 150ms
WriteCOM(0xD7); //Autoread control
WriteDAT(0xBF); //
WriteCOM(0xE0); //Control OTP/MTP
WriteDAT(0x00); //Read Mode
delayms(10); //delay 10ms
WriteCOM(0xE3); //Control OTP/MTP
delayms(20); //delay 20ms
WriteCOM(0xE1); //Close Read Mode
WriteCOM(0x11); //Sleep Out
WriteCOM(0x20); //Normal Display
WriteCOM(0xC3); //Bias Set
WriteDAT(0x03); //1/9
WriteCOM(0xC4); //Booster Set
WriteDAT(0x06); //
WriteCOM(0xC5); //Booster Efficiency Set
WriteDAT(0x01); //
WriteCOM(0xCB); //VG Booster Set
WriteDAT(0x01); //
WriteCOM(0xCC); //ID1 Set
WriteDAT(0x45); //
WriteCOM(0xCE); //ID3 Set
WriteDAT(0x00); //
WriteCOM(0xB7); //Glass Direction
WriteDAT(0xC0); //
WriteCOM(0xD0); //Follower Type set
WriteDAT(0x19); //
WriteCOM(0xD7); //Autoread control
WriteDAT(0xaf); //
WriteCOM(0xB5); //N-line Set
WriteDAT(0x83); //
WriteCOM(0xCD); //ID2 Set
WriteDAT(0xD2); //
WriteCOM(0xD0); //Set Vg Source
WriteDAT(0x19); //
WriteCOM(0xB4); //PTL Saving Mode Set
WriteDAT(0x18); //Power Normal Mode
WriteCOM(0x3A); //Pixel Format Set
WriteDAT(0x05); //
WriteCOM(0xB0); //Duty Set
WriteDAT(0x83); //
WriteCOM(0xB1); //First COM Set
WriteDAT(0x00); //
WriteCOM(0xB3); //OSC Div. Set
WriteDAT(0x00);
//V0=3.6V+{VOP[8:0]+(EV[6:0]-3Fh)*0.04}
WriteCOM(0x25); //EV[6:0]
WriteDAT(0x3F);
WriteCOM(0xC0); //VOP[8:0]
WriteDAT(0xef); //0xe4
WriteDAT(0x00); //
WriteCOM(0xC6); //V0 Bias Set
WriteDAT(0x00); //
WriteCOM(0xB7); //Glass Direction
WriteDAT(0x00); //0xC0
WriteCOM(0x36); //Memory Access Control
WriteDAT(0xC8); //0x08
//Gamma Table Set
WriteCOM(0xF9); //Gamma
WriteDAT(0x00); //
WriteDAT(0x03); //
WriteDAT(0x05); //
WriteDAT(0x07); //
WriteDAT(0x09); //
WriteDAT(0x0B); //
WriteDAT(0x0D); //
WriteDAT(0x0F); //
WriteDAT(0x11); //
WriteDAT(0x13); //
WriteDAT(0x15); //
WriteDAT(0x17); //
WriteDAT(0x19); //
WriteDAT(0x1B); //
WriteDAT(0x1D); //
WriteDAT(0x1F); //
WriteCOM(0x29); //Display On
}
void Set_address(void)
{
WriteCOM(0x2A); //Colulm address set
WriteDAT(0x04); //Start address
WriteDAT(0x83); //End address
WriteCOM(0x2B); //Colulm address set
WriteDAT(0x04); //start page
WriteDAT(0x83); //end page
WriteCOM(0x2C); //Write Data to GRAM
}
void Sleep_in(void)
{
WriteCOM(0x28); //Display Off
delayms(50); //delay 50ms
WriteCOM(0x10); //Sleep in & Booster off
}
void Sleep_out(void)
{
WriteCOM(0x11); //Sleep out & Booster on
delayms(50); //delay 50ms
WriteCOM(0x29); //Display Off
}