/*----- i2cLCD_AQM0802A.c ------*/ #include "i2cLCD_AQM0802A.h" #define CONTRAST 0x18 // for 5.0V //#define CONTRAST 0x30 // for 3.3V #define BOOST 0x00 // for 5.0V Bon=off //#define BOOST 0x04 // for 3.3V Bon=on //-------- send data ------------------------- void LCD_dat(char chr){ I2C_Write1ByteRegister(I2CLCD_AQM0802A, 0x40, chr); __delay_us(30); // 30us } //-------- send command ------------------------- void LCD_cmd(char cmd){ I2C_Write1ByteRegister(I2CLCD_AQM0802A, 0x00, cmd); if(cmd & 0xFC) // bit6 = 1 __delay_us(30); // 30us else __delay_ms(2); // 2ms Clear or Home } //-------- clear LCD-------------------------- void LCD_clr(void){ LCD_cmd(0x01); } //--------- Home ----------------------------- void LCD_home(void){ LCD_cmd(0x02); } //--------- Cursor X,Y ----------------------- void LCD_cursor(int x, int y){ if (y == 0) LCD_cmd(0x80 + x); else if (y == 1) LCD_cmd(0xc0 + x); } //-------- display strings ------------------------- void LCD_str(char *str){ while(*str) LCD_dat(*str++); //pointer increment } //-------- write 1 character to LCD ---------------- void putch(char ch){ LCD_dat(ch); } //-------- LCD initialize --------------------------- void LCD_init(){ __delay_ms(40); //40ms wait LCD_cmd(0x38); //8bit,2line LCD_cmd(0x39); //IS=1 : extention mode LCD_cmd(0x14); //Internal OSC Frequency LCD_cmd(0x70+(CONTRAST & 0x0F)); LCD_cmd(0x58+BOOST+(CONTRAST>>4)); LCD_cmd(0x6C); //Follower control __delay_ms(200); //200ms wait LCD_cmd(0x38); //IS=0:extention mode cancel LCD_cmd(0x0C); //Display ON LCD_cmd(0x01); //Clear Display __delay_ms(2); //wait more than 1.08ms } /******** End of File ******/