/*
 * LAB Name: Arduino I2C LCD 20x4 Custom Characters Display
 * Author: Khaled Magdy
 * For More Info Visit: www.DeepBlueMbedded.com
*/
#include <Wire.h> 
#include <LiquidCrystal_I2C.h>
 
LiquidCrystal_I2C MyLCD(0x27, 20, 4); // Creates I2C LCD Object With (Address=0x27, Cols=20, Rows=4)
// LCD Custom Characters
uint8_t HeartChar[] = {0x00, 0x00, 0x0a, 0x15, 0x11, 0x0a, 0x04, 0x00};
uint8_t SpeakerChar[] = {0x01, 0x03, 0x07, 0x1f, 0x1f, 0x07, 0x03, 0x01};
uint8_t SmilyFaceChar[] = {0x00, 0x00, 0x0a, 0x00, 0x1f, 0x11, 0x0e, 0x00};
uint8_t BellChar[] = {0x04, 0x0e, 0x0a, 0x0a, 0x0a, 0x1f, 0x00, 0x04};
uint8_t Battery1Char[] = {0x0e, 0x1b, 0x11, 0x11, 0x11, 0x11, 0x11, 0x1f};
uint8_t Battery2Char[] = {0x0e, 0x1b, 0x11, 0x11, 0x11, 0x11, 0x1f, 0x1f};
uint8_t Battery3Char[] = {0x0e, 0x1b, 0x11, 0x11, 0x11, 0x1f, 0x1f, 0x1f};
uint8_t Battery4Char[] = {0x0e, 0x1b, 0x11, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f};
 
void setup() 
{
  MyLCD.init();
  MyLCD.backlight();
  // Send The Custom Characters To LCD's CGRAM
  MyLCD.createChar(0, HeartChar);
  MyLCD.createChar(1, SpeakerChar);
  MyLCD.createChar(2, SmilyFaceChar);
  MyLCD.createChar(3, BellChar);
  MyLCD.createChar(4, Battery1Char);
  MyLCD.createChar(5, Battery2Char);
  MyLCD.createChar(6, Battery3Char);
  MyLCD.createChar(7, Battery4Char);
  // Clear The LCD Dispaly
  MyLCD.clear();
  MyLCD.print("Custom Characters:");
  // Print The Custom Characters
  MyLCD.setCursor(0, 1);
  MyLCD.write(byte(0));
  MyLCD.setCursor(2, 1);
  MyLCD.write(byte(1));
  MyLCD.setCursor(4, 1);
  MyLCD.write(byte(2));
  MyLCD.setCursor(6, 1);
  MyLCD.write(byte(3));
  MyLCD.setCursor(8, 1);
  MyLCD.write(byte(4));
  MyLCD.setCursor(10, 1);
  MyLCD.write(byte(5));
  MyLCD.setCursor(12, 1);
  MyLCD.write(byte(6));
  MyLCD.setCursor(14, 1);
  MyLCD.write(byte(7));
}
 
void loop() 
{
  // DO NOTHING!
}