User manual
########################################################################
#
# Basic HD44780/LCD Test Routines
#
#
def LabelTest(label):
#Label the current Test
ClearDisplay()
GotoXY(1,20-len(label)); ShowMessage(label)
GotoXY(2,16); ShowMessage('test')
def CommandTest():
LabelTest('Command')
while (True):
st = raw_input("Enter a string or command: ")
if len(st)==2:
SendByte(int(st,16))
else:
ShowMessage(st)
def AnimateCharTest(numCycles=8,delay=0.1):
LabelTest('Animation')
LoadSymbolBlock(battery) #get all battery symbols
GotoXY(1,3) #where to put battery
for count in range(numCycles):
for count in range(len(battery)): #sequence thru all symbols
SendByte(count,True) #display the symbol
CursorLeft() #keep cursor on same char
time.sleep(delay) #control animation speed
time.sleep(1) #wait between cycles
def UpdateCursor(count):
WIDTH = 15
if count==0:
GotoLine(0)
elif count==WIDTH:
GotoLine(1)
elif count==WIDTH*2:
GotoLine(2)
elif count==WIDTH*3:
GotoLine(3)
def GetNextCharacter(code):
#for a given CODE, returns the next displayable ASCII character
#for example, calling with 'A' will return 'B'
#removes nondisplayable characters in HD44780 character set
if (code<0x20) or (code>=0xFF):
code = 0x20
elif (code>=0x7F) and (code<0xA0):
code = 0xA0
else:
code += 1
return code
def FillScreen(code,delay=0):
#fill the LCD display with ASCII characters, starting with CODE,
#assumes a width of 15 characters x 4 lines = 60 chars total
for count in range(60):
UpdateCursor(count)
SendByte(code,True)
code = GetNextCharacter(code)
time.sleep(delay)