User manual

]
########################################################################
#
# Low-level routines for configuring the LCD module.
# These routines contain GPIO read/write calls.
#
def InitIO():
#Sets GPIO pins to input & output, as required by LCD board
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
for lcdLine in OUTPUTS:
GPIO.setup(lcdLine, GPIO.OUT)
for switch in INPUTS:
GPIO.setup(switch, GPIO.IN, pull_up_down=GPIO.PUD_UP)
def CheckSwitches():
#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 displaying 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():