/************** OLED.C ** ******************** US2011 P3.7=RS ,P3.6=R/W P3.5=EN ,P1=DATA_BUS ************************************************/ //#include #include "LCD_US2011.h" void LCD_Init_68(void); void LCD_CGRAM_68(void); void LCD_Cmd_68(uchar comm); void LCD_Data_68(uchar Data); void DISP_Chra_68(uchar col,uchar stra); void DISP_Chr_68(uchar col,uchar chrx); void DISP_Str_68(uchar col,uchar *str); void DISP_left_68(char col); void Chk_Busy_68(); //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= // Read/Write Sequence //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= void LCD_Init_68(void) // LCD { LCD_Cmd_68(0x38); //DLY(50); LCD_Cmd_68(0x38); //DLY(50); LCD_Cmd_68(0x08); LCD_Cmd_68(0x01); DLY(200); LCD_Cmd_68(0xEF); //Enter Command Table2 oled set LCD_Cmd_68(0xFA); LCD_Cmd_68(0x6E); //Divide Ratio/Oscillator Frequency Data Set LCD_Cmd_68(0x40); //Contrast Set LCD_Cmd_68(0xFC); //0xFF 100% 0x80 50% 0x6D 30% LCD_Cmd_68(0xFE); //Exit Command Table2 LCD_Cmd_68(0xEB); //0615*/ LCD_Cmd_68(0x06); LCD_Cmd_68(0x10); LCD_Cmd_68(0x80); LCD_Cmd_68(0x0C); LCD_CGRAM_68(); DLY(200); } void LCD_CGRAM_68(void) // { uchar i; LCD_Cmd_68(0x40); // CGRAM for (i=0 ; i<40; i++) LCD_Data_68(Table_0[i]); } void DISP_Chr_68(uchar col,uchar chrx) // { uchar i; LCD_Cmd_68(col); // DDRAM for (i=0 ; i<40; i++) LCD_Data_68(chrx); } void DISP_Chra_68(uchar col,uchar stra) // { uchar i; LCD_Cmd_68(col); // DDRAM for (i=0 ; i<40; i++) LCD_Data_68(stra+i); } void DISP_Str_68(uchar col,uchar *str) // { LCD_Cmd_68(col); // DDRAM while(*str!=0) LCD_Data_68(*str++); } void DISP_left_68(char col) // { uchar i; for (i=0 ; i<20; i++){ LCD_Cmd_68(col); // DDRAM delay10ms(50); } LCD_Cmd_68(0x02); LCD_Cmd_68(0x10); } void LCD_Cmd_68(uchar comm) //LCD { Chk_Busy_68(); //LCD RS=0 ;RW=0 ;EN=1 ; // P1=comm ;DLY(2); //LCD EN=0 ;DLY(5); } void LCD_Data_68(uchar Data) //LCD { Chk_Busy_68(); //LCD RS=1 ;RW=0 ;EN=1 ; // P1=Data ;DLY(2); //LCD EN=0 ;DLY(5); } void Chk_Busy_68() { uchar status ; P1=0xff ; // P1 do{ RS=0 ;RW=1 ;EN=1 ; // LCD status= P1 ;DLY(10); // EN=0 ; // LCD } while(status&0x80) ; // (BF) }