stuff
This commit is contained in:
parent
b88fb8b436
commit
93ca674f93
1 changed files with 14 additions and 14 deletions
28
LCD.py
28
LCD.py
|
|
@ -42,14 +42,14 @@ class LCD:
|
|||
raise ValueError('pi_rev param must be 1 or 2')
|
||||
|
||||
# Initialise 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
|
||||
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
|
||||
|
||||
async def lcd_byte(self, bits, mode):
|
||||
def lcd_byte(self, bits, mode):
|
||||
# Send byte to data pins
|
||||
# bits = data
|
||||
# mode = 1 for data, 0 for command
|
||||
|
|
@ -59,18 +59,18 @@ class LCD:
|
|||
|
||||
# High bits
|
||||
self.bus.write_byte(self.I2C_ADDR, bits_high)
|
||||
await self.toggle_enable(bits_high)
|
||||
self.toggle_enable(bits_high)
|
||||
|
||||
# Low bits
|
||||
self.bus.write_byte(self.I2C_ADDR, bits_low)
|
||||
await self.toggle_enable(bits_low)
|
||||
self.toggle_enable(bits_low)
|
||||
|
||||
async def toggle_enable(self, bits):
|
||||
await asyncio.sleep(self.E_DELAY)
|
||||
def toggle_enable(self, bits):
|
||||
asyncio.sleep(self.E_DELAY)
|
||||
self.bus.write_byte(self.I2C_ADDR, (bits | self.ENABLE))
|
||||
await asyncio.sleep(self.E_PULSE)
|
||||
asyncio.sleep(self.E_PULSE)
|
||||
self.bus.write_byte(self.I2C_ADDR,(bits & ~self.ENABLE))
|
||||
await asyncio.sleep(self.E_DELAY)
|
||||
asyncio.sleep(self.E_DELAY)
|
||||
|
||||
async def async_message(self, string, line = 1):
|
||||
async with lock:
|
||||
|
|
@ -96,6 +96,6 @@ class LCD:
|
|||
for i in range(self.LCD_WIDTH):
|
||||
self.lcd_byte(ord(string[i]), self.LCD_CHR)
|
||||
|
||||
async def clear(self):
|
||||
def clear(self):
|
||||
# clear LCD display
|
||||
self.lcd_byte(0x01, self.LCD_CMD)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue