📄 5408.c
字号:
//**********************************************************
// S9155 version 01
// data 20070208
//******************************************************************
#include "reg51.h"
#include <intrins.h>
#define DBH P0
#define DBL P1
/****DEMO 标准接口 *******/
sbit LCD_CS =P3^5; //模组片选信号引脚
sbit LCD_RES=P3^4; //模组复位信号引脚
sbit LCD_RS =P3^2; //模组命令/数据信号引脚
sbit LCD_WR =P3^1; //模组写信号引脚
sbit LCD_RD =P3^0;
sbit COE=P2^6;//FLASH 数据输出选择脚
sbit DOE=P2^7;//单片机数据输出选择脚
/*************************/
sbit AD18=P3^7;
sbit AD17=P3^6;
sbit AD16=P3^3;
sbit set5 =P2^0;
void Delay(unsigned int t)
{
unsigned int n,m;
for(n=0;n<t;n++)
for(m=0;m<1000;m++);
}
void WAIT_KEY(void)
{
repeat:
if (set5&0x01) goto repeat;
else Delay(4);
if (set5&0x01) goto repeat;
else
set5=1;
}
void showpic1()
{
unsigned int i;
AD16=0;
AD17=0;
AD18=0;
LCD_RS = 1;
LCD_CS = 0;
DOE=1;
COE=0;
for(i=0;i<0xffff;i++)
{
DBL = i;
DBH = i>>8;
LCD_WR = 0;
LCD_WR = 1;
}
DBL = 0xff;
DBH = 0xff;
LCD_WR = 0;
LCD_WR = 1;
AD16=1;
AD17=0;
AD18=0;
for(i=0x0000;i<0x2c00;i++)
{
DBL = i;
DBH = i>>8;
LCD_WR = 0;
LCD_WR = 1;
}
COE=1;
LCD_CS = 1;
}
void showpic2()
{
unsigned int i;
AD16=1;
AD17=0;
AD18=0;
LCD_RS = 1;
LCD_CS = 0;
DOE=1;
COE=0;
for(i=0x2c00;i<0xffff;i++)
{
DBL = i;
DBH = i>>8;
LCD_WR = 0;
LCD_WR = 1;
}
DBL = 0xff;
DBH = 0xff;
LCD_WR = 0;
LCD_WR = 1;
AD16=0;
AD17=1;
AD18=0;
for(i=0x0000;i<0x5800;i++)
{
DBL = i;
DBH = i>>8;
LCD_WR = 0;
LCD_WR = 1;
}
COE=1;
LCD_CS = 1;
}
/*********写寄存器ID的子程序*********************/
void LCD_WRITE_COMMAND(unsigned int COMMAND)
{
COE=1;
DOE=0;
LCD_RS=0;
LCD_CS=0;
DBL=COMMAND;//*****写寄存器ID的低位***
DBH=COMMAND>>8;//*****写寄存器ID的高位***/
LCD_WR=0;
LCD_WR=1;
LCD_CS=1;
}
/*************写数据的子程序**************************/
void LCD_WRITE_DATA(unsigned int REGDATA)
{
COE=1;
DOE=0;
LCD_RS=1;
LCD_CS=0;
DBL=REGDATA;//********写数据的低位**********
DBH=REGDATA>>8;//********写数据的高位**********
LCD_WR=0;
LCD_WR=1;
LCD_CS=1;
}
void wr_com(unsigned int i,unsigned int j)//write command
{
LCD_WRITE_COMMAND(i);
LCD_WRITE_DATA(j);
}
/****************************************/
void disp(unsigned int C1)//写单色画面
{
unsigned int i,m;
COE=1;
DOE=0;
LCD_RS=1;
LCD_CS=0;
DBL=C1;//********写数据的低位**********
DBH=C1>>8;//********写数据的高位*******
for(i=0;i<320;i++)
for(m=0;m<240;m++)
{
LCD_WR=0;
LCD_WR=1;
}
LCD_CS=1;
}
void disp_snow(void)//雪花画面
{
unsigned int n,m;
COE=1;
DOE=0;
LCD_RS=1;
LCD_CS=0;
DBL = 0;
DBH = 0;
for(n=0;n<320;n++)
{
for(m=0;m<240;m++)
{
LCD_WR = 0; LCD_WR = 1;
DBL = ~DBL;
DBH = ~DBH;
LCD_WR = 0; LCD_WR = 1;
DBL = ~DBL;
DBH = ~DBH;
}
DBL = ~DBL;
DBH = ~DBH;
}
LCD_CS = 1;
}
void disp_BLACK(void)
{
unsigned char i;
unsigned int n;
COE=1;
DOE=0;
LCD_RS=1;
LCD_CS=0;
P0=0xf8,P1=0x00,LCD_WR=0; LCD_WR=1;
for(i=0;i<238;i++){P0=0xFF,P1=0xFF,LCD_WR=0;LCD_WR=1;}
P0=0x00,P1=0x1f,LCD_WR=0;LCD_WR=1;
for(n=0;n<318;n++)//**132
{
P0=0xf8,P1=0x00,LCD_WR=0;LCD_WR=1;
for(i=0;i<238;i++){P0=0x00,P1=0x00,LCD_WR=0;LCD_WR=1;}
P0=0x00,P1=0x1F,LCD_WR=0;LCD_WR=1;
}
P0=0xf8,P1=0x00,LCD_WR=0;LCD_WR=1;
for(i=0;i<238;i++){P0=0xFF,P1=0xFF,LCD_WR=0;LCD_WR=1;}
P0=0x00,P1=0x1F,LCD_WR=0;LCD_WR=1;
LCD_RS=1;
LCD_CS=1;
}
////////////////////////
void IC_INIT(void)
{
//=======2.8v=============
wr_com(0x0000,0x0000);
wr_com(0x0001,0x0100);//0000
wr_com(0x0002,0x0700);
wr_com(0x0003,0x1030);//d0a0
wr_com(0x0004,0x0000);
wr_com(0x0008,0x0207);
wr_com(0x0009,0x0000);
wr_com(0x000a,0x0000);
wr_com(0x000C,0x0000);
wr_com(0x000D,0x0000);
wr_com(0x000F,0x0000);
wr_com(0x0007,0x0101);
wr_com(0x0010,0x12b0);
wr_com(0x0011,0x0007);
wr_com(0x0017,0x0001);
Delay(200);//200
wr_com(0x0012,0x01bb);
wr_com(0x0013,0x1c00);
Delay(50);
wr_com(0x0029,0x0019);//0012
Delay(50);
wr_com(0x0030,0x0102);
Delay(50);
wr_com(0x0031,0x0c21);//0c20
wr_com(0x0032,0x0b22);//0b21
wr_com(0x0033,0x2610);//250f
wr_com(0x0034,0x1e0b);//1d0b
wr_com(0x0035,0x0a04);
wr_com(0x0036,0x1701);
wr_com(0x0037,0x0617);
wr_com(0x0038,0x0305);
wr_com(0x0039,0x0a05);
wr_com(0x003a,0x0c04);//0f04
wr_com(0x003b,0x0c00);//0f00
wr_com(0x003c,0x000c); //000f
wr_com(0x003d,0x050c);//050f
wr_com(0x003e,0x0204);
wr_com(0x003f,0x0404);
wr_com(0x0050,0x0000);
wr_com(0x0051,0x00ef);
wr_com(0x0052,0x0000);
wr_com(0x0053,0x013F);
wr_com(0x0060,0x2700);
wr_com(0x0061,0x0001);
wr_com(0x006A,0x0000);
wr_com(0x0080,0x0000);
wr_com(0x0081,0x0000);
wr_com(0x0082,0x0000);
wr_com(0x0083,0x0000);
wr_com(0x0084,0x0000);
wr_com(0x0085,0x0000);
wr_com(0x0090,0x0010);
wr_com(0x0092,0x0000);
wr_com(0x0093,0x0103);
wr_com(0x0095,0x0210);
wr_com(0x0097,0x0000);
wr_com(0x0098,0x0000);
wr_com(0x00f0,0x5408);
wr_com(0x00f3,0x0005);
wr_com(0x00f4,0x001f);
wr_com(0x00f0,0x0000);
wr_com(0x0007,0x0173);
LCD_WRITE_COMMAND(0x22);
}
/****************主程序开始******************/
void main(void)
{
P0=0xff;
P1=0xff;
P2=0xff;
P3=0xff;
LCD_RES=1;
Delay(10);
LCD_RES=0;
Delay(20);
LCD_RES=1;
Delay(10);
IC_INIT();
while(1)
{
disp_BLACK();
WAIT_KEY();
disp(0xffff);
WAIT_KEY();
disp_snow();
WAIT_KEY(); //雪花
disp(0xF800);
WAIT_KEY(); //全蓝
disp(0x07E0);
WAIT_KEY(); //全蓝
disp(0x001F);
WAIT_KEY(); //全蓝
showpic1();
WAIT_KEY();
showpic2();
WAIT_KEY();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -