
406
Platforms
©2000-2008 Tibbo Technology Inc.
Dim
dw1,dw2
As
dword
...
'Note so good! The user will see a noticeable delay between the first and
the second print.
lcd.print(str(dw1*100/200),0,0)
lcd.print(str(dw2*100/200),0,10)
In the second example we calculate values 1 and 2 first, then print them together:
Dim
dw1,dw2
As
dword
Dim
s1,s2
As
String
...
'Much better. The user will have a feeling that both values were
calculated and printed instantly!
s1=str(dw1*100/200)
s2=str(dw2*100/200)
lcd.print(s1,0,0)
lcd.print(s2,0,10)
Testing both examples shows that the perceived performance of the second code
snippet is much better, while, in fact, the total working time of the processor was
roughly the same. Why is there a difference? Because the output of the two values
in the second example was spaced closer!
Bottom line: keep all display output as close together as possible. Pre-calculate
everything first, then display all your items "at once".
Use display locking
No matter how hard you try to group all display-related output together, executing
lcd. object's methods one after another may still take considerable time. Perceived
performance can be improved on displays that allow you to "lock" display picture,
change display data, then unlock the display again. With this approach, the user
will see all changes appear instantly! Not all displays are suitable for this.
Typically, this works well for TFT panels which continue to display the image for
several seconds after the "refresh" was disabled. Other display types are not
suitable for locking. We have provided locking-related info for each
.
The display is locked/unlocked using the
and
methods.
You can place lcd.lock before the block of code that changes display data, and put
lcd.unlock at the end of this code block:
...
s1=str(dw1*100/200)
s2=str(dw2*100/200)
lcd.lock
'lock the display
lcd.print(s1,0,0)
lcd.print(s2,0,10)
lcd.unlock
'unlock the display
...
Display-related code is often nested, with one procedure calling another, and so
408
423
431