|
|
|
|
|
The RCX2 adds an eighth display mode - DISPLAY_USER. User display mode continuously reads a source value and updates the display. It can optionally display a decimal point at any position within the number. This allows the display to give the illusion of working with fractions even though all values are stored internally as integers. For example, the following call will set the user display to show the value 1234 with two digits appearing after the decimal point, resulting in "12.34" appearing on the LCD.
SetUserDisplay(1234, 2);
The following short program illustrates the update of the user display:
task main()
{
ClearTimer(0);
SetUserDisplay(Timer(0), 0);
until(false);
}
Because the user display mode continuously updates the LCD, there are certain restrictions on the source value. If a variable is used it must be assigned to a global storage location. The best way to ensure this is to make the variable a global one. There can also be some strange side effects. For example, if a variable is being displayed and later used as the target of a calculation, it is possible for the display to show some intermediate results of the calculation:
int x;
task main()
{
SetUserDisplay(x, 0);
while(true)
{
// display may briefly show 1!
x = 1 + Timer(0);
}
}
|