from machine import Pin, SoftI2C
from lcd_api import LcdApi
from i2c_lcd import I2cLcd
from time import sleep
# Define custom characters
# Each custom character is defined as an array of 8 bytes
custom_char1 = bytearray{
B00000,
B11011,
B10101,
B10001,
B10001,
B01010,
B00100,
B00000
} # Custom character 1
# Initialize I2C bus and LCD object
i2c = SoftI2C(scl=Pin(22), sda=Pin(21))
lcd = I2cLcd(i2c, 0x27, 16, 2)
# Define custom characters in CGRAM (Character Generator RAM)
lcd.custom_char(0, custom_char1) # Define custom character 1 at CGRAM address 0
lcd.custom_char(1, custom_char2) # Define custom character 2 at CGRAM address 1
# Display custom characters
lcd.putchar(chr(0)) # Display custom character 1
lcd.putchar(chr(1)) # Display custom character 2
# Wait for a moment
sleep(2)
# Clear the LCD display
lcd.clear()