Instructions

#
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)
def FillChar(code):
#fill the LCD display with a single ASCII character
#assumes a width of 15 characters x 4 lines = 60 chars total
for count in range(60):
UpdateCursor(count)
SendByte(code,True)
def CharTest(numCycles=4, delay=ANIMATIONDELAY):
#show screenfull of sequential symbols from character set
#starting with a random symbol
#delay = time between characters
LabelTest('Char')
for count in range(numCycles):
rand = random.randint(0,255)
firstChar = GetNextCharacter(rand)
FillScreen(firstChar,delay)
def NumberTest(delay=1):
#show an almost-full screen (60 chars) of each digit 0-9
#call with delay in seconds between each digit/screen
for count in range(10):
FillChar(ord('0')+count)
time.sleep(delay)
def TimeTest(numCycles=3):
#measures the time required to display 600 characters, sent
#60 characters at a time. The pause between screen displays
#is removed from the reported time.
pause = 0.5