from machine import I2C, Pin
from lcd_api import LcdApi
from i2c_lcd import I2cLcd
I2C_ADDR = 0x27
I2C_NUM_ROWS = 2
I2C_NUM_COLS = 16
#setup I2C connection
i2c = I2C(0, sda=Pin(22), scl=Pin(21), freq=400000)
#setup display parameters address rows and columns
lcd = I2cLcd(i2c, I2C_ADDR, I2C_NUM_ROWS, I2C_NUM_COLS)
# clear the screen
lcd.clear()
#write "hello world"on the display (default location is row 0 column 0
lcd.putstr("Hello World")
#set cursor to columns 0, Row 1 (second Row)
lcd.move_to(0,1)
#Display character https://peppe8o.com/download/pdf/HD44780%20datasheet.pdf Page 17
lcd.putchar(chr(247))
#turn on a blinking cursor
lcd.blink_cursor_on()
#set cursor to columns 5, Row 1 (second Row)
lcd.move_to(5,1)
#create custom character Generator https://maxpromer.github.io/LCD-Character-Creator/
heart = bytearray([0x00,
0x04,
0x04,
0x0E,
0x04,
0x0E,
0x1F,
0x04])
#set custom character to ID 0 (0-7 are free to use)
lcd.custom_char(0, heart)
#print custom character to position of the cursor
lcd.putchar(chr(0))