| 9 | class lcd: |
| 10 | # initializes objects and lcd |
| 11 | def __init__(self, ADDR, I2C): |
| 12 | self.i2c = I2C |
| 13 | self.address = ADDR |
| 14 | self.BKLIGHT = 0x08 # Set Backlight ON |
| 15 | self.lcd_write(0x03) |
| 16 | self.lcd_write(0x03) |
| 17 | self.lcd_write(0x03) |
| 18 | self.lcd_write(0x02) |
| 19 | |
| 20 | self.lcd_write(0x20 | 0x08 | 0x04 | 0x00) # Set Functions 2Line,5x8,4Bit Mode |
| 21 | self.lcd_write(0x08 | 0x04) # Turn Display On |
| 22 | self.lcd_write(0x01) # Clear Screen |
| 23 | self.lcd_write(0x04 | 0x02) # Set Entry Mode Left -> Right |
| 24 | sleep_ms(300) |
| 25 | |
| 26 | def lcd_strobe(self, data): |
| 27 | self.i2c.writeto(self.address, bytes([data | Enable | self.BKLIGHT])) |