import machine
import time
from machine import SoftI2C, Pin
from lcd_api import LcdApi
from i2c_lcd import I2cLcd
I2C_ADDR = 0x27
totalRows = 2
totalColumns = 16
i2c = SoftI2C(scl=Pin(21), sda=Pin(22), freq=10000) #initializing the I2C method for ESP32
lcd = I2cLcd(i2c, I2C_ADDR, totalRows, totalColumns)
heart = bytearray([0x00,0x00,0x1B,0x1F,0x1F,0x0E,0x04,0x00])
face = bytearray([0x00,0x00,0x0A,0x00,0x11,0x0E,0x00,0x00])
lcd.custom_char(0, heart)
lcd.custom_char(1, face)
lcd.putstr(chr(0)+" ESP32 with I2C LCD "+chr(1))
time.sleep(2)
lcd.clear()
lcd.move_to(2,1)
lcd.putstr("3B013034")
lcd.clear()
lcd.move_to(0,0)
while(1):
for i in range(15):
lcd.move_to(i,0)
lcd.putstr("0")
lcd.move_to(15-i,1)
lcd.putstr("0")
time.sleep_ms(10)
lcd.clear()
for i in range(15):
lcd.move_to(15-i,0)
lcd.putstr("0")
lcd.move_to(i,1)
lcd.putstr("0")
time.sleep_ms(10)
lcd.clear()