User manual

#Check status of all four switches on the LCD board
#Returns four boolean values as a tuple.
val1 = not GPIO.input(SW1)
val2 = not GPIO.input(SW2)
val3 = not GPIO.input(SW3)
val4 = not GPIO.input(SW4)
return (val4,val1,val2,val3)
def PulseEnableLine():
#Pulse the LCD Enable line; used for clocking in data
GPIO.output(LCD_E, GPIO.HIGH) #pulse E high
GPIO.output(LCD_E, GPIO.LOW) #return E low
def SendNibble(data):
#sends upper 4 bits of data byte to LCD data pins D4-D7
GPIO.output(LCD_D4, bool(data & 0x10))
GPIO.output(LCD_D5, bool(data & 0x20))
GPIO.output(LCD_D6, bool(data & 0x40))
GPIO.output(LCD_D7, bool(data & 0x80))
def SendByte(data,charMode=False):
#send one byte to LCD controller
GPIO.output(LCD_RS,charMode) #set mode: command vs. char
SendNibble(data) #send upper bits first
PulseEnableLine() #pulse the enable line
data = (data & 0x0F)<< 4 #shift 4 bits to left
SendNibble(data) #send lower bits now
PulseEnableLine() #pulse the enable line
########################################################################
#
# Higher-level routines for diplaying data on the LCD.
#
def ClearDisplay():
#This command requires 1.5mS processing time, so delay is needed
SendByte(CLEARDISPLAY)
time.sleep(0.0015) #delay for 1.5mS
def CursorOn():
SendByte(CURSORON)
def CursorOff():
SendByte(CURSOROFF)
def CursorBlink():
SendByte(CURSORBLINK)
def CursorLeft():
SendByte(CURSORLEFT)
def CursorRight():
SendByte(CURSORRIGHT)
def InitLCD():
#initialize the LCD controller & clear display
SendByte(0x33) #initialize
SendByte(0x32) #initialize/4-bit
SendByte(0x28) #4-bit, 2 lines, 5x8 font
SendByte(LEFTTORIGHT) #rightward moving cursor
CursorOff()
ClearDisplay()