MCPcopy Create free account
hub / github.com/RetiredWizard/PyDOS / __init__

Method __init__

cpython/lib/circuitpython_i2c_lcd.py:22–41  ·  view source on GitHub ↗
(self, i2c, i2c_addr, num_lines, num_columns)

Source from the content-addressed store, hash-verified

20class I2cLcd(LcdApi):
21 """Implements a HD44780 character LCD connected via PCF8574 on I2C."""
22 def __init__(self, i2c, i2c_addr, num_lines, num_columns):
23 self.i2c = i2c
24 self.i2c_addr = i2c_addr
25 self.i2c.writeto(self.i2c_addr, bytearray([0]))
26 sleep(0.02) # Allow LCD time to powerup
27 # Send reset 3 times
28 self.hal_write_init_nibble(self.LCD_FUNCTION_RESET)
29 sleep(0.005) # need to delay at least 4.1 msec
30 self.hal_write_init_nibble(self.LCD_FUNCTION_RESET)
31 sleep(0.001)
32 self.hal_write_init_nibble(self.LCD_FUNCTION_RESET)
33 sleep(0.001)
34 # Put LCD into 4 bit mode
35 self.hal_write_init_nibble(self.LCD_FUNCTION)
36 sleep(0.001)
37 LcdApi.__init__(self, num_lines, num_columns)
38 cmd = self.LCD_FUNCTION
39 if num_lines > 1:
40 cmd |= self.LCD_FUNCTION_2LINES
41 self.hal_write_command(cmd)
42
43 def hal_write_init_nibble(self, nibble):
44 """Writes an initialization nibble to the LCD.

Callers

nothing calls this directly

Calls 2

hal_write_init_nibbleMethod · 0.95
hal_write_commandMethod · 0.95

Tested by

no test coverage detected