📄 s6d0128_main.c
字号:
#include "reg51.h"
#include<intrins.h>
#include "don.h"
#define CS1 P3_0
#define RS P3_1
#define RES P3_5
#define WRD P3_4
#define rStart_osc 0x00
#define rDriver_output 0x01
#define rDriving_waveform 0x02
#define rEntry_mode 0x03
#define rDisplay_control 0x07
#define rBlank_period_control 0x08
#define rExternal_IF_control 0x0c
#define rFrame_cycle_control 0x0b
#define rPower_control_1 0x10
#define rPower_control_2 0x11
#define rPower_control_3 0x13
#define rPower_control_4 0x14
#define rRam_add_set 0x21
#define rWR_data_gram 0x22
#define rGamma_control_1 0x30
#define rGamma_control_2 0x31
#define rGamma_control_3 0x32
#define rGamma_control_4 0x33
#define rGamma_control_5 0x34
#define rGamma_control_6 0x35
#define rGamma_control_7 0x36
#define rGamma_control_8 0x37
#define rGamma_control_9 0x38
#define rGamma_control_10 0x38
#define rGate_scan_pos 0x40
#define rVertical_scroll_control 0x41
#define rFirst_screen_driving_pos 0x42
#define rH_windows_add 0x44
#define rV_windows_add 0x45
void displayg1(char code *h);
void WCOM(unsigned char hibyte,unsigned char lobyte);
void WDAT(unsigned char hibyte,unsigned char lobyte);
void Delay(unsigned long value);
void FillBlock(unsigned char hibyte,unsigned char lobyte);
void FULL_R(void);
void FULL_G(void);
void FULL_B(void);
void Start_osc(unsigned char hibyte,unsigned char lobyte);
void Driver_output(unsigned char hibyte,unsigned char lobyte);
void Driving_waveform(unsigned char hibyte,unsigned char lobyte);
void Power_control_1(unsigned char hibyte,unsigned char lobyte);
void Entry_mode(unsigned char hibyte,unsigned char lobyte);
void Display_control(unsigned char hibyte,unsigned char lobyte);
void Blank_period_control(unsigned char hibyte,unsigned char lobyte);
void External_IF_control(unsigned char hibyte,unsigned char lobyte);
void Frame_cycle_control(unsigned char hibyte,unsigned char lobyte);
void Power_control_2(unsigned char hibyte,unsigned char lobyte);
void Power_control_3(unsigned char hibyte,unsigned char lobyte);
void Power_control_4(unsigned char hibyte,unsigned char lobyte);
void Gate_scan_pos(unsigned char hibyte,unsigned char lobyte);
void Vertical_scroll_control(unsigned char hibyte,unsigned char lobyte);
void First_screen_driving_pos(unsigned char hibyte,unsigned char lobyte);
void H_windows_add(unsigned char hibyte,unsigned char lobyte);
void V_windows_add(unsigned char hibyte,unsigned char lobyte);
void Ram_add_set(unsigned char hibyte,unsigned char lobyte);
void WR_data_gram(void);
void Gamma_control_1(unsigned char hibyte,unsigned char lobyte);
void Gamma_control_2(unsigned char hibyte,unsigned char lobyte);
void Gamma_control_3(unsigned char hibyte,unsigned char lobyte);
void Gamma_control_4(unsigned char hibyte,unsigned char lobyte);
void Gamma_control_5(unsigned char hibyte,unsigned char lobyte);
void Gamma_control_6(unsigned char hibyte,unsigned char lobyte);
void Gamma_control_7(unsigned char hibyte,unsigned char lobyte);
void Gamma_control_8(unsigned char hibyte,unsigned char lobyte);
void Gamma_control_9(unsigned char hibyte,unsigned char lobyte);
void Gamma_control_10(unsigned char hibyte,unsigned char lobyte);
int main (void)
{ CS1=0;
RES=0;
Delay(1);
RES=1;
Delay(1);
Start_osc(0x00,0x01);
Delay(1);
Power_control_2(0x3c,0x03);
Delay(1);
Power_control_4(0x20,0x23);
Delay(1);
Power_control_1(0x13,0x00);
Delay(5);
Power_control_3(0x00,0x70);
Delay(1);
Driver_output(0x01,0x1b);
Driving_waveform(0x07,0x00);
Entry_mode(0x10,0x30);////////////////////
Blank_period_control(0x02,0x02);
Frame_cycle_control(0x00,0x00);
External_IF_control(0x00,0x03);
Gate_scan_pos(0x00,0x00);
First_screen_driving_pos(0xdb,0x00);
H_windows_add(0xaf,0x00);
V_windows_add(0xdb,0x00);
Gamma_control_1(0x03,0x02);
Gamma_control_2(0x03,0x03);
Gamma_control_3(0x02,0x03);
Gamma_control_4(0x03,0x03);
Gamma_control_5(0x03,0x02);
Gamma_control_6(0x03,0x03);
Gamma_control_7(0x02,0x03);
Gamma_control_8(0x03,0x03);
Gamma_control_9(0x00,0x00);
Gamma_control_10(0x00,0x00);
Delay(5);
Display_control(0x10,0x17);
Delay(10);
while(1)
{
FULL_R();
Delay(750);
FULL_G();
Delay(750);
FULL_B();
Delay(750);
displayg1(mm);
Delay(2500);
}
}
void displayg1(char code *h) //图形
{
unsigned int i=0;
Ram_add_set(0x00,0x00);
WR_data_gram();
do{
WDAT(mm[i],mm[i+1]);i=i+2;
}while (i<25696);
i=0;
do{
WDAT(mm[i],mm[i+1]);i=i+2;
}while (i<25696);
i=0;
do{
WDAT(mm[i],mm[i+1]);i=i+2;
}while (i<25696);
}
void WCOM(unsigned char hibyte,unsigned char lobyte)
{ RS=0;
WRD=0;
P1=hibyte;
WRD=1;
WRD=0;
P1=lobyte;
WRD=1;
}
void WDAT(unsigned char hibyte,unsigned char lobyte)
{ RS=1;
WRD=0;
P1=hibyte;
WRD=1;
WRD=0;
P1=lobyte;
WRD=1;
}
void Delay(unsigned long value)
{
unsigned char i,j;
for (i=value;i>0;i++)
for (j=19400;j>0;j++);
}
void FillBlock(unsigned char hibyte,unsigned char lobyte)
{
unsigned char i,j;
Ram_add_set(0x00,0x00);
WR_data_gram();
for (i=0;i<=220;i++)
{
for(j=0;j<=176;j++)
{
WDAT(hibyte,lobyte);
}
}
}
void FULL_R(void)
{
FillBlock(0xfc,0x00);
}
void FULL_G(void)
{
FillBlock(0x03,0xc0);
}
void FULL_B(void)
{
FillBlock(0x00,0x1f);
}
void Start_osc(unsigned char hibyte,unsigned char lobyte)
{
WCOM(0x00,rStart_osc);
WDAT(hibyte,lobyte);
}
void Driver_output(unsigned char hibyte,unsigned char lobyte)
{
WCOM(0x00,rDriver_output);
WDAT(hibyte,lobyte);
}
void Driving_waveform(unsigned char hibyte,unsigned char lobyte)
{
WCOM(0x00,rDriving_waveform);
WDAT(hibyte,lobyte);
}
void Power_control_1(unsigned char hibyte,unsigned char lobyte)
{
WCOM(0x00,rPower_control_1);
WDAT(hibyte,lobyte);
}
void Entry_mode(unsigned char hibyte,unsigned char lobyte)
{
WCOM(0x00,rEntry_mode);
WDAT(hibyte,lobyte);
}
void Display_control(unsigned char hibyte,unsigned char lobyte)
{
WCOM(0x00,rDisplay_control);
WDAT(hibyte,lobyte);
}
void Blank_period_control(unsigned char hibyte,unsigned char lobyte)
{
WCOM(0x00,rBlank_period_control);
WDAT(hibyte,lobyte);
}
void External_IF_control(unsigned char hibyte,unsigned char lobyte)
{
WCOM(0x00,rExternal_IF_control);
WDAT(hibyte,lobyte);
}
void Frame_cycle_control(unsigned char hibyte,unsigned char lobyte)
{
WCOM(0x00,rFrame_cycle_control);
WDAT(hibyte,lobyte);
}
void Power_control_3(unsigned char hibyte,unsigned char lobyte)
{
WCOM(0x00,rPower_control_3);
WDAT(hibyte,lobyte);
}
void Power_control_4(unsigned char hibyte,unsigned char lobyte)
{
WCOM(0x00,rPower_control_4);
WDAT(hibyte,lobyte);
}
void Power_control_2(unsigned char hibyte,unsigned char lobyte)
{
WCOM(0x00,rPower_control_2);
WDAT(hibyte,lobyte);
}
void Gate_scan_pos(unsigned char hibyte,unsigned char lobyte)
{
WCOM(0x00,rGate_scan_pos);
WDAT(hibyte,lobyte);
}
void First_screen_driving_pos(unsigned char hibyte,unsigned char lobyte)
{
WCOM(0x00,rFirst_screen_driving_pos);
WDAT(hibyte,lobyte);
}
void H_windows_add(unsigned char hibyte,unsigned char lobyte)
{
WCOM(0x00,rH_windows_add);
WDAT(hibyte,lobyte);
}
void V_windows_add(unsigned char hibyte,unsigned char lobyte)
{
WCOM(0x00,rV_windows_add);
WDAT(hibyte,lobyte);
}
void WR_data_gram(void)
{
WCOM(0x00,rWR_data_gram);
}
void Ram_add_set(unsigned char hibyte,unsigned char lobyte)
{
WCOM(0x00,rRam_add_set);
WDAT(hibyte,lobyte);
}
void Gamma_control_1(unsigned char hibyte,unsigned char lobyte)
{
WCOM(0x00,rGamma_control_1);
WDAT(hibyte,lobyte);
}
void Gamma_control_2(unsigned char hibyte,unsigned char lobyte)
{
WCOM(0x00,rGamma_control_2);
WDAT(hibyte,lobyte);
}
void Gamma_control_3(unsigned char hibyte,unsigned char lobyte)
{
WCOM(0x00,rGamma_control_3);
WDAT(hibyte,lobyte);
}
void Gamma_control_4(unsigned char hibyte,unsigned char lobyte)
{
WCOM(0x00,rGamma_control_4);
WDAT(hibyte,lobyte);
}
void Gamma_control_5(unsigned char hibyte,unsigned char lobyte)
{
WCOM(0x00,rGamma_control_5);
WDAT(hibyte,lobyte);
}
void Gamma_control_6(unsigned char hibyte,unsigned char lobyte)
{
WCOM(0x00,rGamma_control_6);
WDAT(hibyte,lobyte);
}
void Gamma_control_7(unsigned char hibyte,unsigned char lobyte)
{
WCOM(0x00,rGamma_control_7);
WDAT(hibyte,lobyte);
}
void Gamma_control_8(unsigned char hibyte,unsigned char lobyte)
{
WCOM(0x00,rGamma_control_8);
WDAT(hibyte,lobyte);
}
void Gamma_control_9(unsigned char hibyte,unsigned char lobyte)
{
WCOM(0x00,rGamma_control_9);
WDAT(hibyte,lobyte);
}
void Gamma_control_10(unsigned char hibyte,unsigned char lobyte)
{
WCOM(0x00,rGamma_control_10);
WDAT(hibyte,lobyte);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -