/******************************************************************
*                                                                 *
*              Library to use the LC03 on I2C mode                *
*                                                                 *
*           Author:      Ángel Hernández Mejías (Mif)             *
*           Contact:     angel@tupperbot.es                       *
*           Web:         www.tupperbot.es                         *
*           Date:        20/08/2007                               *
*           Version:     1.0                                      *
*                                                                 *
*******************************************************************
*                                                                 *
*                        Licence                                  *
*   This Library is under Creative Commons Licence in             *
* Attribution and share Alike Version, you are freely authorized  *
* to copy, edit and share without modifying the Author's Name     *
* and not changing the licence                                    *
*                                                                 *
*******************************************************************
*                                                                 *
*   This library is useful to use the LCD03 using I2C mode.       *
*                                                                 *
*  Requirements:                                                  *
*  -I2C                                                           *
*                                                                 *
******************************************************************/


char  LCD_Txt[21];         //Text String
int1  Luz=0;               //Light State Variable

//*** LCD initialization ***
void LCD_Start(void)       //
{
   i2c_start();            //Starting Signal
   i2c_write(0xC6);        //I2C Address
   i2c_write(0x00);        //Writing address
}

//*** New Cursor location ***
void LCD_Cursor(int Position)
{
   LCD_Start();
   i2c_write(0x02);        //Set cursor Command
   i2c_write(Position);    //New Location
   i2c_stop();
}

//*** Printing on the Screen ***
void LCD_Print(char *p)
{
   LCD_Start();

     while(*p)
   {
      i2c_write(*p++);
      delay_us(10);
   }
   i2c_stop();
}

//*** Clear the Screen ***
void LCD_Clrscn(void)
{
   LCD_Start();
   i2c_write(12);    //Clearing command
   i2c_write(4);     //Turn off the Cursor
   i2c_stop();
}

//*** Light switching ***
void LCD_Light(void)
{
   LCD_Start();

   if (Luz == 1)           //If the Light is turned on
   {
      i2c_write(20);       //Turn the light off
      Luz = 0;
   }

   else                    //If the light is turned Off
   {
      i2c_write(19);       //Turn the light on
      Luz = 1;
   }

   i2c_stop();

}

//*** Nex line ***
void LCD_Nex_Line(void)
{
   LCD_Start();
   i2c_write(13);
   i2c_stop();
}
