?? s6b0724.c
字號:
/*
********************************************
* Project: ???????? *
* Driver: KS0724 *
* Size: 128*32(FSTN) *
* Date: 2004-11-10 *
* Writer: /////???????? *
* Copyright: ??????????????. *
********************************************
*/
#include "reg51.h"
#include "intrins.h"
//
unsigned char code ImageCode[4][128]={
/*-- 寬度x高度=128x32 --*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,
0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x44,0x44,0x44,0x44,0x44,0x44,0x7F,0x7F,0x7F,
0x44,0x44,0x44,0x44,0x44,0x44,0x04,0x00,0x00,0x00,0x3C,0x24,0xFE,0xFF,0x27,0x23,
0x26,0xFE,0xFC,0x18,0x10,0xFE,0xFE,0x00,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x10,0xD2,
0xD3,0xFF,0xFF,0xFF,0x91,0x12,0x42,0xE7,0xFF,0xCE,0x00,0xFF,0xFF,0xFF,0x00,0x00,
0x00,0x00,0x04,0x84,0xFF,0xFF,0xFF,0x44,0x44,0x44,0x44,0x44,0x7F,0x7F,0x7F,0x44,
0xC4,0xC4,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0xFE,0xC2,0xC2,0xC2,0xC2,0xC2,0xC2,
0xC2,0xC2,0xC2,0xFE,0xFE,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x7F,0x60,0x64,
0x64,0x67,0x67,0x38,0x00,0x1F,0x5F,0x40,0x7F,0x7F,0x3F,0x00,0x00,0x00,0x1E,0x3F,
0x0F,0xFF,0xFF,0xFF,0x3F,0x1E,0x08,0x0C,0x07,0x05,0x04,0xFF,0xFF,0xFF,0x04,0x00,
0x00,0x00,0x01,0x43,0x7F,0x7F,0x7F,0x00,0x3C,0x44,0x42,0x42,0x62,0x36,0x1C,0x1F,
0x7F,0x7B,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
//
unsigned char bdata BitValue;
unsigned char i;
unsigned char f;
sbit LCD_CS=P3^0;
sbit LCD_A0=P3^2;
sbit LCD_SCK=P1^6;
sbit LCD_SDA=P1^7;
sbit LCD_RESET=P3^1;
sbit bBit7=BitValue^7;
//
void lcd_write_d(unsigned char c1);
void lcd_write_c(unsigned char c1);
void LcdFill(unsigned char A,unsigned char B,unsigned char C,unsigned char D);
void LcdInit();
void LcdView();
void Delay();
//
void main()
{
LcdInit();
while(1)
{
unsigned int n;
LcdView();
for (n=0;n<1600;n++) Delay();
LcdFill(0xaa,0xaa,0xaa,0xaa);
for (n=0;n<1600;n++) Delay();
LcdFill(0xff,0x00,0xff,0x00);
for (n=0;n<1600;n++) Delay();
LcdFill(0xaa,0x55,0xaa,0x55);
for (n=0;n<1600;n++) Delay();
LcdFill(0x00,0x00,0x00,0x00);
for (n=0;n<1600;n++) Delay();
LcdFill(0xff,0xff,0xff,0xff);
for (n=0;n<1600;n++) Delay();
LcdFill(0xcc,0xcc,0x33,0x33);
for (n=0;n<1600;n++) Delay();
}
}
void LcdInit()
{
LCD_RESET=0;//Hard Reset
Delay(); //LCD_RESET=0;LCD_RESET=0;
LCD_RESET=1;
Delay();
lcd_write_c(0xe2);//15.Software Reset
lcd_write_c(0xa2);//8.Set LCD Bias
lcd_write_c(0xa9);//20.Set Bias Ratio,TC Value,Osc.Freq
lcd_write_c(0xca);//20-1.The Data Byte=8 Bits
lcd_write_c(0xa0);//7.Set Segment Re_map
lcd_write_c(0xc8);//13.Set Com OutputScan Direction
lcd_write_c(0x2f);//4.Set Power Control Register
lcd_write_c(0xa4);//9.Set Entire Display On/Off
lcd_write_c(0x26);//3.Set Internal Regulator Resistor Ratio
lcd_write_c(0x81);//6.Set Contrast Control Register
lcd_write_c(40);//6->1.value=0x00+value&0x3f,
lcd_write_c(0xa6);//10.Set Normal/Reverse Display
lcd_write_c(0xaf);//11.Set Display On/Off
lcd_write_c(0xb0);//12.Set Page Address
}
/**************************
* LCD Veiw Image *
**************************/
void LcdView (void)
{
unsigned char t;
unsigned char l;
for(t=0;t<4;t++)
{
lcd_write_c(0xb0+t);
lcd_write_c(0x10);
lcd_write_c(0x00);
for(l=0;l<128;l++)
{
lcd_write_d(ImageCode[t][l]);
}
}
}
/**************************
* Fill Data to LCD *
**************************/
void LcdFill (unsigned char A,unsigned char B,unsigned char C,unsigned char D)
{
unsigned char t;
unsigned char l;
for(t=0;t<4;t++)
{
lcd_write_c(0xb0+t);
lcd_write_c(0x10);
lcd_write_c(0x00);
for(l=0;l<32;l++)
{
lcd_write_d(A);
lcd_write_d(B);
lcd_write_d(C);
lcd_write_d(D);
}
}
}
/****************************
* Send Commed To LCD *
****************************/
void lcd_write_c(unsigned char c1)
{
LCD_A0=0;//Command
LCD_CS=0;
//
BitValue=c1;
for(i=0;i<8;i++)
{
LCD_SCK=0;
_nop_();
LCD_SDA=bBit7;
BitValue<<=1;
_nop_();
LCD_SCK=1;
}
//
LCD_CS=1;
LCD_A0=1;//Data Byte
}
/****************************
* Send Date To LCD *
****************************/
void lcd_write_d(unsigned char c1)
{
LCD_A0=1;//Data Byte
LCD_CS=0;
//
BitValue=c1;
for(i=0;i<8;i++)
{
LCD_SCK=0;
_nop_();
LCD_SDA=bBit7;
BitValue<<=1;
_nop_();
LCD_SCK=1;
}
//
LCD_CS=1;
}
/***************************
* Delay 10ms@12MHz *
***************************/
void delay (void)
{
for(i=0;i<255;i++);
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -