This commit is contained in:
Benjamin Tayehanpour 2026-09-26 20:40:59 +00:00
parent 320eea6faa
commit b88fb8b436

16
LCD.py
View file

@ -42,12 +42,12 @@ class LCD:
raise ValueError('pi_rev param must be 1 or 2')
# Initialise display
self.lcd_byte(0x33, self.LCD_CMD) # 110011 Initialise
self.lcd_byte(0x32, self.LCD_CMD) # 110010 Initialise
self.lcd_byte(0x06, self.LCD_CMD) # 000110 Cursor move direction
self.lcd_byte(0x0C, self.LCD_CMD) # 001100 Display On,Cursor Off, Blink Off
self.lcd_byte(0x28, self.LCD_CMD) # 101000 Data length, number of lines, font size
self.lcd_byte(0x01, self.LCD_CMD) # 000001 Clear display
await self.lcd_byte(0x33, self.LCD_CMD) # 110011 Initialise
await self.lcd_byte(0x32, self.LCD_CMD) # 110010 Initialise
await self.lcd_byte(0x06, self.LCD_CMD) # 000110 Cursor move direction
await self.lcd_byte(0x0C, self.LCD_CMD) # 001100 Display On,Cursor Off, Blink Off
await self.lcd_byte(0x28, self.LCD_CMD) # 101000 Data length, number of lines, font size
await self.lcd_byte(0x01, self.LCD_CMD) # 000001 Clear display
async def lcd_byte(self, bits, mode):
# Send byte to data pins
@ -59,11 +59,11 @@ class LCD:
# High bits
self.bus.write_byte(self.I2C_ADDR, bits_high)
self.toggle_enable(bits_high)
await self.toggle_enable(bits_high)
# Low bits
self.bus.write_byte(self.I2C_ADDR, bits_low)
self.toggle_enable(bits_low)
await self.toggle_enable(bits_low)
async def toggle_enable(self, bits):
await asyncio.sleep(self.E_DELAY)