User Manual
116
self.used_gpio = self.pins_db[:] # Note down the used gpio to easily clear
IO setting after the stop. pins_db[:] writes all in the pins_db list to the used_gpio
list; if here use used_gpio = self.pins_db, it means used_gpio call pins_db, in other
words, any change of pins_db will affect used_gpio.
self.used_gpio.append(pin_e)
self.used_gpio.append(pin_rs)
self.write4bits(0x33) # initialization
self.write4bits(0x32) # initialization
self.write4bits(0x28) # 2 line 5x7 matrix
self.write4bits(0x0C) # turn cursor off 0x0E to enable cursor
self.write4bits(0x06) # shift cursor right
""" Initialize to default text direction (for romance languages) """
self.displaymode = self.LCD_ENTRYLEFT | self.LCD_ENTRYSHIFTDECREMENT
self.write4bits(self.LCD_ENTRYMODESET | self.displaymode) # Set the entry
mode
def begin(self, cols, lines): # Start the LCD
def setCursor(self, col, row): # Set the cursor location
def message(self, text): # Send strings to the LCD. The new line wraps to the
second line
def destroy(self): # Clean up the used gpio
lcd = LCD(0, 2) # Create an lcd object
lcd.clear() # Clear the LCD display
for i in range(0, len(line0)): # i adds 1 each time within the length of the
character line0
lcd.setCursor(i, 0) # Locate the cursor at character No. i, Row 0
lcd.message(line0[i]) # Display the character on the screen
sleep(0.1)
for i in range(0, len(line1)): # i adds 1 each time within the length of the
character line0
lcd.setCursor(i, 1) # Locate the cursor at character No. i, Row 1
lcd.message(line1[i]) # Display the character on the LCD
You should see two lines of characters displayed on the LCD1602: " Welcome to ---> " ,"
sunfounder.com " and "---SUNFOUNDER--- ".
SunFounder