Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Initialization for 7inch 800x480 SSD1963
- //LCD ID READ: 01-57-61-01-FF
- //coldtears electronics
- //http://coldtearselectronics.wikispace.com
- unsigned int HDP=799; //Horizontal Display Period
- unsigned int HT=1000; //Horizontal Total
- unsigned int HPS=51; //LLINE Pulse Start Position
- unsigned int LPS=3; // Horizontal Display Period Start Position
- unsigned char HPW=8; // LLINE Pulse Width
- unsigned int VDP=479; //Vertical Display Period
- unsigned int VT=530; //Vertical Total
- unsigned int VPS=24; // LFRAME Pulse Start Position
- unsigned int FPS=23; //Vertical Display Period Start Positio
- unsigned char VPW=3; // LFRAME Pulse Width
- #define White 0xFFFF
- #define Black 0x0000
- #define Blue 0x001F
- #define Blue2 0x051F
- #define Red 0xF800
- #define Magenta 0xF81F
- #define Green 0x07E0
- #define Cyan 0x7FFF
- #define Yellow 0xFFE0
- #define Gray 0x2104
- #define PURPLE 0xF11F
- #define Orange 0xFD20
- void LCD_Init(void)
- {
- LCD_RST_0();
- _delay_ms(500);
- LCD_RST_1();
- LCD_CS_1();
- LCD_RD_1();
- LCD_RW_1();
- LCD_RS_1();
- _delay_ms(100);
- LCD_CS_0();
- LCD_Instruction(0x00E2);
- LCD_Data(0x0023);
- LCD_Data(0x0002);
- LCD_Data(0x0004);
- LCD_Instruction(0x00E0); // PLL enable
- LCD_Data(0x0001);
- _delay_ms(1);
- LCD_Instruction(0x00E0);
- LCD_Data(0x0003);
- _delay_ms(5);
- LCD_Instruction(0x0001); // software reset
- _delay_ms(5);
- LCD_Instruction(0x00E6);
- LCD_Data(0x0004);
- LCD_Data(0x0093);
- LCD_Data(0x00e0);
- LCD_Instruction(0x00B0); //LCD SPECIFICATION
- LCD_Data(0x0000);
- LCD_Data(0x0000);
- LCD_Data((HDP>>8)&0X00FF); //Set HDP
- LCD_Data(HDP&0X00FF);
- LCD_Data((VDP>>8)&0X00FF); //Set VDP
- LCD_Data(VDP&0X00FF);
- LCD_Data(0x0000);
- LCD_Instruction(0x00B4); //HSYNC
- LCD_Data((HT>>8)&0X00FF); //Set HT
- LCD_Data(HT&0X00FF);
- LCD_Data((HPS>>8)&0X00FF); //Set HPS
- LCD_Data(HPS&0X00FF);
- LCD_Data(HPW); //Set HPW
- LCD_Data((LPS>>8)&0X00FF); //Set HPS
- LCD_Data(LPS&0X00FF);
- LCD_Data(0x0000);
- LCD_Instruction(0x00B6); //VSYNC
- LCD_Data((VT>>8)&0X00FF); //Set VT
- LCD_Data(VT&0X00FF);
- LCD_Data((VPS>>8)&0X00FF); //Set VPS
- LCD_Data(VPS&0X00FF);
- LCD_Data(VPW); //Set VPW
- LCD_Data((FPS>>8)&0X00FF); //Set FPS
- LCD_Data(FPS&0X00FF);
- LCD_Instruction(0x00BA);
- LCD_Data(0x000F); //GPIO[3:0] out 1
- LCD_Instruction(0x00B8);
- LCD_Data(0x0007); //GPIO3=input, GPIO[2:0]=output
- LCD_Data(0x0001); //GPIO0 normal
- LCD_Instruction(0x0036); //rotation
- LCD_Data(0x0000);
- LCD_Instruction(0x00F0); //pixel data interface
- LCD_Data(0x0003);
- _delay_ms(5);
- LCD_Instruction(0x0026); //display on
- LCD_Data(0x0008);
- LCD_Instruction(0x0029); //display on
- LCD_Instruction(0x00BE); //set PWM for B/L
- LCD_Data(0x0001);
- LCD_Data(0x0088); //medium backlight
- LCD_Data(0x0001);
- LCD_Data(0x00F0);
- LCD_Data(0x0000);
- LCD_Data(0x0000);
- LCD_CS_1();
- LCD_RD_1();
- LCD_RW_1();
- LCD_RS_1();
- }
- void adjust_backlight()
- {
- // if(PWM_Value==255) PWM_Value=0;
- // else if (PWM_Value==0) PWM_Value=255;
- LCD_CS_0();
- LCD_Instruction(0x00BE); //set PWM for B/L
- LCD_Data(0x0001);
- LCD_Data(PWM_Value);
- LCD_Data(0x0001);
- LCD_Data(0x00F0);
- LCD_Data(0x0000);
- LCD_Data(0x0000);
- LCD_CS_1();
- }
- void LCD_Set_AREA(unsigned int x1,unsigned int y1,unsigned int x2,unsigned int y2)
- {
- LCD_CS_0();
- LCD_Instruction(0x002A);LCD_Data(x1>>8);
- LCD_Data(0x00FF&x1); LCD_Data(x2>>8);
- LCD_Data(0x00FF&x2);
- LCD_Instruction(0x002B);LCD_Data(y1>>8);
- LCD_Data(0x00FF&y1); LCD_Data(y2>>8);
- LCD_Data(0x00FF&y2);
- LCD_Instruction(WriteDatatoGRAM);
- LCD_CS_1();
- }
- void show_colour_bar(void)
- {
- unsigned int i,j;
- LCD_CS_0();
- LCD_Instruction(0x002C);
- for(i=0;i<480;i++)
- {
- for(j=0;j<800;j++)
- {
- if(i>400)LCD_Data(White);
- else if(i>350)LCD_Data(Blue);
- else if(i>300)LCD_Data(Green);
- else if(i>250)LCD_Data(Cyan);
- else if(i>200)LCD_Data(Red);
- else if(i>150)LCD_Data(Blue2);
- else if(i>100)LCD_Data(Magenta);
- else if(i>50)LCD_Data(Yellow);
- else LCD_Data(Black);
- }
- }
- LCD_CS_1();
- }
- void LCD_Fill(unsigned long color)
- {
- unsigned int j,m;
- unsigned long ia;
- LCD_CS_0();
- LCD_Instruction(0x002C);
- for(ia=0;ia<384000;ia++)
- {
- LCD_Data(color);
- }
- LCD_CS_1();
- }
- int main(void)
- {
- _delay_ms(100);
- Init_Coms();
- init_AVR();
- LCD_Init();
- while(1)
- {
- _delay_ms(400);
- LCD_Set_AREA(0,0,799,479);
- show_colour_bar();
- LCD_Fill(Black);
- _delay_ms(400);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement